Revision c6a0f442
Von Christian Ehringfeld vor fast 8 Jahren hinzugefügt
samples/simple/address.cpp | ||
---|---|---|
#include "address.h"
|
||
#include "pupil.h"
|
||
|
||
Address::Address(QString label, QString street, QString postcode,
|
||
QString city) {
|
||
this->label = label;
|
||
this->street = street;
|
||
this->postcode = postcode;
|
||
this->city = city;
|
||
}
|
||
|
||
QString Address::getLabel() const {
|
||
return label;
|
||
}
|
||
|
||
void Address::setLabel(const QString &value) {
|
||
label = value;
|
||
}
|
||
|
||
QString Address::getStreet() const {
|
||
return street;
|
||
}
|
||
|
||
void Address::setStreet(const QString &value) {
|
||
street = value;
|
||
}
|
||
|
||
QString Address::getPostcode() const {
|
||
return postcode;
|
||
}
|
||
|
||
void Address::setPostcode(const QString &value) {
|
||
postcode = value;
|
||
}
|
||
|
||
QString Address::getCity() const {
|
||
return city;
|
||
}
|
||
|
||
void Address::setCity(const QString &value) {
|
||
city = value;
|
||
}
|
||
|
||
QList<QSharedPointer<Person> > Address::getPersons() const {
|
||
return persons;
|
||
}
|
||
|
||
void Address::setPersons(const QList<QSharedPointer<Person> > &value) {
|
||
persons = value;
|
||
}
|
||
|
||
const QHash<QString, CuteEntityManager::Relation> Address::getRelations()
|
||
const {
|
||
auto hash = Entity::getRelations();
|
||
hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("addresses")));
|
||
return hash;
|
||
}
|
||
|
||
QList<QSharedPointer<Pupil> > Address::getPupils() const {
|
||
return pupils;
|
||
}
|
||
|
||
void Address::setPupils(const QList<QSharedPointer<Pupil> > &value) {
|
||
pupils = value;
|
||
}
|
||
|
||
|
samples/simple/address.h | ||
---|---|---|
#ifndef ADDRESS_H
|
||
#define ADDRESS_H
|
||
|
||
#include <QString>
|
||
#include <QHash>
|
||
#include "entity.h"
|
||
|
||
class Person;
|
||
class Relation;
|
||
class Pupil;
|
||
class Address: public CuteEntityManager::Entity {
|
||
Q_OBJECT
|
||
EM_MACRO(Address)
|
||
Q_PROPERTY(QString label READ getLabel WRITE setLabel)
|
||
Q_PROPERTY(QString street READ getStreet WRITE setStreet)
|
||
Q_PROPERTY(QString postcode READ getPostcode WRITE setPostcode)
|
||
Q_PROPERTY(QString city READ getCity WRITE setCity)
|
||
Q_PROPERTY(QList<QSharedPointer<Person>> persons READ
|
||
getPersons WRITE setPersons)
|
||
|
||
public:
|
||
Q_INVOKABLE Address() {}
|
||
Address(QString label, QString street, QString postcode, QString city);
|
||
|
||
QString getLabel() const;
|
||
void setLabel(const QString &value);
|
||
|
||
QString getStreet() const;
|
||
void setStreet(const QString &value);
|
||
|
||
QString getPostcode() const;
|
||
void setPostcode(const QString &value);
|
||
|
||
QString getCity() const;
|
||
void setCity(const QString &value);
|
||
|
||
QList<QSharedPointer<Person> > getPersons() const;
|
||
void setPersons(const QList<QSharedPointer<Person> > &value);
|
||
|
||
const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
|
||
QList<QSharedPointer<Pupil> > getPupils() const;
|
||
void setPupils(const QList<QSharedPointer<Pupil> > &value);
|
||
|
||
protected:
|
||
QString label;
|
||
QString street;
|
||
QString postcode;
|
||
QString city;
|
||
QList<QSharedPointer<Person>> persons;
|
||
QList<QSharedPointer<Pupil>> pupils;
|
||
};
|
||
|
||
#endif // ADDRESS_H
|
samples/simple/contact.cpp | ||
---|---|---|
#include "contact.h"
|
||
#include "pupil.h"
|
||
|
||
Contact::Contact(QString label, Category category, QString content) {
|
||
this->label = label;
|
||
this->category = category;
|
||
this->content = content;
|
||
}
|
||
|
||
const QHash<QString, CuteEntityManager::Relation> Contact::getRelations()
|
||
const {
|
||
auto hash = Entity::getRelations();
|
||
hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("contacts")));
|
||
return hash;
|
||
}
|
||
|
||
QString Contact::getContent() const {
|
||
return content;
|
||
}
|
||
|
||
void Contact::setContent(const QString &value) {
|
||
content = value;
|
||
}
|
||
|
||
QString Contact::getLabel() const {
|
||
return label;
|
||
}
|
||
|
||
void Contact::setLabel(const QString &value) {
|
||
label = value;
|
||
}
|
||
Contact::Category Contact::getCategory() const {
|
||
return category;
|
||
}
|
||
|
||
void Contact::setCategory(const Category &value) {
|
||
category = value;
|
||
}
|
||
|
||
QList<QSharedPointer<Person> > Contact::getPersons() const {
|
||
return persons;
|
||
}
|
||
|
||
void Contact::setPersons(const QList<QSharedPointer<Person> > &value) {
|
||
persons = value;
|
||
}
|
||
|
||
QList<QSharedPointer<Pupil> > Contact::getPupils() const {
|
||
return pupils;
|
||
}
|
||
|
||
void Contact::setPupils(const QList<QSharedPointer<Pupil> > &value) {
|
||
pupils = value;
|
||
}
|
samples/simple/contact.h | ||
---|---|---|
#ifndef CONTACT_H
|
||
#define CONTACT_H
|
||
|
||
#include <QString>
|
||
#include "entity.h"
|
||
|
||
class Relation;
|
||
class Person;
|
||
class Pupil;
|
||
class Contact: public CuteEntityManager::Entity {
|
||
Q_OBJECT
|
||
EM_MACRO(Contact)
|
||
Q_PROPERTY(QString content READ getContent WRITE setContent)
|
||
Q_PROPERTY(Category category READ getCategory WRITE setCategory)
|
||
Q_PROPERTY(QString label READ getLabel WRITE setLabel)
|
||
Q_PROPERTY(QList<QSharedPointer<Person>> persons READ
|
||
getPersons WRITE setPersons)
|
||
|
||
public:
|
||
enum Category {EMAIL, MOBILE, LANDLINE, MESSENGER, EXTRA} ;
|
||
Q_INVOKABLE Contact() {}
|
||
Contact(QString label, Category category, QString content);
|
||
const QHash<QString, CuteEntityManager::Relation> getRelations() const
|
||
override;
|
||
|
||
QString getContent() const;
|
||
void setContent(const QString &value);
|
||
|
||
QString getLabel() const;
|
||
void setLabel(const QString &value);
|
||
|
||
Category getCategory() const;
|
||
void setCategory(const Category &value);
|
||
|
||
QList<QSharedPointer<Person> > getPersons() const;
|
||
void setPersons(const QList<QSharedPointer<Person> > &value);
|
||
|
||
QList<QSharedPointer<Pupil> > getPupils() const;
|
||
void setPupils(const QList<QSharedPointer<Pupil> > &value);
|
||
|
||
protected:
|
||
QString content;
|
||
Category category;
|
||
QString label;
|
||
QList<QSharedPointer<Person>> persons;
|
||
QList<QSharedPointer<Pupil>> pupils;
|
||
};
|
||
|
||
#endif // CONTACT_H
|
samples/simple/datacreation.cpp | ||
---|---|---|
def2_1p->setPanelRow(1);
|
||
resultList.append(def2_1p);
|
||
rateSystem2Definitions.append(resultList.last().objectCast<RatingMarkDefinition>());
|
||
ratingSystem2->setRatingMarkDefinitions(rateSystem2Definitions);
|
||
ratingSystem2->setAdditionalInfo("sys2");
|
||
auto now = QDateTime::currentDateTime();
|
||
ratingSystem2->setBookedAt(now);
|
||
ratingSystem2->setBookedFor(now);
|
||
return resultList;
|
||
}
|
samples/simple/incident.cpp | ||
---|---|---|
const QHash<QString, Relation> Incident::getRelations() const
|
||
{
|
||
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
||
|
||
hash.insert("pupil",CuteEntityManager::Relation(
|
||
"pupil",CuteEntityManager::RelationType::MANY_TO_ONE));
|
||
hash.insert("group",CuteEntityManager::Relation(
|
samples/simple/incident.h | ||
---|---|---|
Q_PROPERTY(QDateTime cancelledAt READ cancelledAt WRITE setCancelledAt)
|
||
|
||
Q_PROPERTY(QSharedPointer<Pupil> pupil READ pupil WRITE setPupil)
|
||
// Q_PROPERTY(QSharedPointer<AppData> appData READ appData WRITE setAppData)
|
||
Q_PROPERTY(QSharedPointer<Group> group READ group WRITE setGroup)
|
||
// Q_PROPERTY(QSharedPointer<Room> room READ room WRITE setRoom)
|
||
// Q_PROPERTY(QSharedPointer<SeatingPlan> seatingPlan READ seatingPlan WRITE setSeatingPlan)
|
||
|
||
Q_PROPERTY(QString additionalInfo READ additionalInfo WRITE setAdditionalInfo)
|
||
Q_PROPERTY(QSharedPointer<Incident> predecessor READ predecessor WRITE setPredecessor)
|
||
... | ... | |
QDateTime m_bookedAt;
|
||
QDateTime m_cancelledAt;
|
||
QSharedPointer<Pupil> m_pupil;
|
||
// QSharedPointer<AppData> m_appData;
|
||
QSharedPointer<Group> m_group;
|
||
// QSharedPointer<Room> m_room;
|
||
// QSharedPointer<SeatingPlan> m_seatingPlan;
|
||
bool m_cancelled = false;
|
||
bool m_locked = false;
|
||
QString m_additionalInfo;
|
samples/simple/main.cpp | ||
---|---|---|
#include "person.h"
|
||
#include "pupil.h"
|
||
#include "group.h"
|
||
#include "address.h"
|
||
#include "contact.h"
|
||
|
||
#include "occasion.h"
|
||
#include "ratingmarkdefinition.h"
|
||
#include "ratingmarksystem.h"
|
||
#include "ratingmarkincident.h"
|
||
... | ... | |
using namespace CuteEntityManager;
|
||
int main(int argc, char *argv[]) {
|
||
Q_UNUSED(argc) Q_UNUSED(argv);
|
||
EntityInstanceFactory::registerClass<Address>();
|
||
EntityInstanceFactory::registerClass<Contact>();
|
||
EntityInstanceFactory::registerClass<Person>();
|
||
EntityInstanceFactory::registerClass<Pupil>();
|
||
EntityInstanceFactory::registerClass<Group>();
|
||
EntityInstanceFactory::registerClass<Occasion>();
|
||
EntityInstanceFactory::registerClass<Incident>();
|
||
EntityInstanceFactory::registerClass<RatingMarkDefinition>();
|
||
EntityInstanceFactory::registerClass<RatingMarkIncident>();
|
||
... | ... | |
QSharedPointer<CuteEntityManager::EntityManager> e =
|
||
QSharedPointer<CuteEntityManager::EntityManager>(new
|
||
CuteEntityManager::EntityManager("QSQLITE",
|
||
QDir::currentPath() + "/db.sqlite"));
|
||
QDir::currentPath() + "/db.sqlite","","","","",true));
|
||
qDebug()<<QDir::currentPath();
|
||
QStringList inits = QStringList() << "Address" << "Contact" << "Person" << "Pupil" << "Group" << "Incident" << "Occasion" << "RatingMarkDefinition" << "RatingMarkIncident" << "RatingMarkSystem";
|
||
QStringList inits = QStringList() << "Person" << "Pupil" << "Group" << "Incident" << "RatingMarkDefinition" << "RatingMarkIncident" << "RatingMarkSystem";
|
||
e->startup("0.1", inits);
|
||
|
||
try {
|
||
... | ... | |
firstGroup->addPerson(pupil1);
|
||
e->save(QList<QSharedPointer<Entity>>()<<pupil1<<firstGroup);
|
||
|
||
QSharedPointer<Occasion> occasion = QSharedPointer<Occasion>(new Occasion(""));
|
||
QSharedPointer<RatingMarkIncident> firstInc = QSharedPointer<RatingMarkIncident>(new RatingMarkIncident());
|
||
firstInc->setAdditionalInfo("addInf");
|
||
firstInc->setBookedAt(QDateTime::currentDateTime());
|
||
firstInc->setBookedFor(QDateTime::currentDateTime());
|
||
firstInc->setOccasion(occasion);
|
||
firstInc->setPupil(pupil1);
|
||
firstInc->setRateable(true);
|
||
auto system = e->findAll<RatingMarkSystem>().first();
|
||
... | ... | |
inc->setWeight(1.0);
|
||
inc->setRateable(true);
|
||
inc->setSignatureNeeded(false);
|
||
inc->setOccasion(e->findById<Occasion>(1));
|
||
auto rateSys = e->findById<RatingMarkSystem>(1);
|
||
e->refresh(rateSys);
|
||
inc->setRatingMarkSystem(rateSys);
|
||
// ---------------------------------------------------------------------
|
||
|
||
bool success;
|
||
success = oldInc.isNull() || e->save(oldInc);
|
||
success &= e->save(inc);
|
||
success = !oldInc.isNull() && e->save(oldInc);
|
||
// only save new version if old version could is successfully cancelled
|
||
if (success) {
|
||
success &= e->save(inc);
|
samples/simple/occasion.cpp | ||
---|---|---|
#include "occasion.h"
|
||
|
||
Occasion::Occasion() : Entity()
|
||
{
|
||
m_text.clear();
|
||
}
|
||
|
||
Occasion::Occasion(QString text)
|
||
{
|
||
m_text=text;
|
||
}
|
||
QString Occasion::text()
|
||
{
|
||
return m_text;
|
||
}
|
||
|
||
void Occasion::setText(QString &text)
|
||
{
|
||
m_text = text;
|
||
}
|
||
|
||
|
samples/simple/occasion.h | ||
---|---|---|
#ifndef OCCASION_H
|
||
#define OCCASION_H
|
||
|
||
#include "entity.h"
|
||
#include <QObject>
|
||
|
||
using namespace CuteEntityManager;
|
||
class Occasion : public Entity
|
||
{
|
||
Q_OBJECT
|
||
EM_MACRO(Occasion)
|
||
Q_PROPERTY(QString text READ text WRITE setText)
|
||
public:
|
||
Q_INVOKABLE explicit Occasion();
|
||
Occasion(QString text);
|
||
QString text();
|
||
void setText(QString &text);
|
||
|
||
protected:
|
||
QString m_text;
|
||
|
||
};
|
||
|
||
#endif // OCCASION_H
|
||
|
samples/simple/person.cpp | ||
---|---|---|
#include "person.h"
|
||
#include "contact.h"
|
||
#include "address.h"
|
||
|
||
Person::Person(QObject *parent): Entity(parent) {
|
||
}
|
||
... | ... | |
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
||
hash.insert("groups", CuteEntityManager::Relation("groups",
|
||
RelationType::MANY_TO_MANY));
|
||
hash.insert("contacts", CuteEntityManager::Relation("contacts",
|
||
RelationType::MANY_TO_MANY));
|
||
hash.insert("addresses", CuteEntityManager::Relation("addresses",
|
||
RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
||
|
||
... | ... | |
void Person::setCustomPictureFileName(const QString &value) {
|
||
customPictureFileName = value;
|
||
}
|
||
QList<QSharedPointer<Contact> > Person::getContacts() const {
|
||
return contacts;
|
||
}
|
||
|
||
void Person::setContacts(const QList<QSharedPointer<Contact> > &value) {
|
||
contacts = value;
|
||
}
|
||
QList<QSharedPointer<Address> > Person::getAddresses() const {
|
||
return addresses;
|
||
}
|
||
|
||
void Person::setAddresses(const QList<QSharedPointer<Address> > &value) {
|
||
addresses = value;
|
||
}
|
||
QList<QSharedPointer<Group> > Person::getGroups() const {
|
||
return groups;
|
||
}
|
||
... | ... | |
void Person::setGroups(const QList<QSharedPointer<Group> > &value) {
|
||
groups = value;
|
||
}
|
||
|
||
void Person::addContact(Contact *contact) {
|
||
this->contacts.append(QSharedPointer<Contact>(contact));
|
||
}
|
||
|
||
void Person::addAddress(Address *address) {
|
||
this->addresses.append(QSharedPointer<Address>(address));
|
||
}
|
samples/simple/person.h | ||
---|---|---|
setCustomPictureFileName)
|
||
Q_PROPERTY(QDate birthday READ getBirthday WRITE setBirthday)
|
||
Q_PROPERTY(QList<QSharedPointer<Group>> groups READ getGroups WRITE setGroups)
|
||
Q_PROPERTY(QList<QSharedPointer<Contact>> contacts READ getContacts WRITE
|
||
setContacts)
|
||
Q_PROPERTY(QList<QSharedPointer<Address>> addresses READ
|
||
getAddresses WRITE setAddresses)
|
||
|
||
public:
|
||
enum class NameOrder {FIRST_FAMILY_NAME_ORDER, FAMILY_FIRST_NAME_ORDER};
|
||
... | ... | |
QString getCustomPictureFileName() const;
|
||
void setCustomPictureFileName(const QString &value);
|
||
|
||
QList<QSharedPointer<Contact> > getContacts() const;
|
||
void setContacts(const QList<QSharedPointer<Contact> > &value);
|
||
|
||
QList<QSharedPointer<Address> > getAddresses() const;
|
||
void setAddresses(const QList<QSharedPointer<Address> > &value);
|
||
|
||
QList<QSharedPointer<Group> > getGroups() const;
|
||
void setGroups(const QList<QSharedPointer<Group> > &value);
|
||
|
||
void addContact(Contact *contact);
|
||
void addAddress(Address *address);
|
||
|
||
|
||
|
||
protected:
|
||
QString firstName;
|
||
QString familyName;
|
||
... | ... | |
QString nickName;
|
||
QDate birthday;
|
||
QString customPictureFileName;
|
||
QList <QSharedPointer<Contact>> contacts;
|
||
QList <QSharedPointer<Address>> addresses;
|
||
QList <QSharedPointer<Group>> groups;
|
||
|
||
};
|
samples/simple/ratingmarkincident.cpp | ||
---|---|---|
m_rateable = rateable;
|
||
}
|
||
|
||
QSharedPointer<Occasion> RatingMarkIncident::occasion() const
|
||
{
|
||
return m_occasion;
|
||
}
|
||
|
||
void RatingMarkIncident::setOccasion(const QSharedPointer<Occasion> &occasion)
|
||
{
|
||
m_occasion = occasion;
|
||
}
|
||
|
||
const QHash<QString, Relation> RatingMarkIncident::getRelations() const
|
||
{
|
||
auto hash = Incident::getRelations();
|
||
hash.insert("occasion",Relation("occasion",CuteEntityManager::RelationType::MANY_TO_ONE));
|
||
hash.insert("ratingMarkSystem", Relation("ratingMarkSystem",RelationType::MANY_TO_ONE));
|
||
return hash;
|
||
}
|
samples/simple/ratingmarkincident.h | ||
---|---|---|
#include <QObject>
|
||
|
||
#include "incident.h"
|
||
#include "occasion.h"
|
||
#include "ratingmarksystem.h"
|
||
|
||
class AppData;
|
||
... | ... | |
Q_PROPERTY(qreal weight READ weight WRITE setWeight)
|
||
Q_PROPERTY(bool rateable READ rateable WRITE setRateable)
|
||
Q_PROPERTY(bool signatureNeeded READ signatureNeeded WRITE setSignatureNeeded)
|
||
Q_PROPERTY(QSharedPointer<Occasion> occasion READ occasion WRITE setOccasion)
|
||
// ratingMarkSystem scheint auf den ersten Blick ein Duplikat zu sein, da man es aus AppData
|
||
// (zu AppRatingData gecastet) ermitteln könnte. In der TimeMachine ist es jedoch wichtig, dass
|
||
// bei einem für die App geänderten RatingMarkSystem ein alter RatingMarkIncident noch sein
|
||
... | ... | |
bool rateable() const;
|
||
void setRateable(bool rateable);
|
||
|
||
QSharedPointer<Occasion> occasion() const;
|
||
void setOccasion(const QSharedPointer<Occasion> &occasion);
|
||
|
||
virtual const QHash<QString, CuteEntityManager::Relation> getRelations() const override;
|
||
virtual InheritanceStrategy getInheritanceStrategy() const override { return InheritanceStrategy::PER_CLASS_TABLE; }
|
||
|
||
|
||
QSharedPointer<RatingMarkSystem> ratingMarkSystem() const;
|
||
void setRatingMarkSystem(const QSharedPointer<RatingMarkSystem> &ratingMarkSystem);
|
||
|
||
... | ... | |
qreal m_weight = 1;
|
||
bool m_rateable = true;
|
||
bool m_signatureNeeded = false;
|
||
QSharedPointer<Occasion> m_occasion = QSharedPointer<Occasion>();
|
||
QSharedPointer<RatingMarkSystem> m_ratingMarkSystem = QSharedPointer<RatingMarkSystem>();
|
||
};
|
||
|
samples/simple/ratingmarksystem.cpp | ||
---|---|---|
#include "ratingmarksystem.h"
|
||
#include "ratingmarkincident.h"
|
||
#include "occasion.h"
|
||
|
||
#include <QDebug>
|
||
#include <QtMath>
|
||
... | ... | |
{
|
||
auto hash = Incident::getRelations();
|
||
hash.insert("ratingMarkDefinitions",Relation("ratingMarkDefinitions",CuteEntityManager::RelationType::ONE_TO_MANY,QString("ratingMarkSystem")));
|
||
|
||
return hash;
|
||
}
|
||
|
||
... | ... | |
return list;
|
||
}
|
||
|
||
bool RatingMarkSystem::shallBeCalculated(QSharedPointer<RatingMarkIncident> inc, QSharedPointer<Occasion> occasion, bool respectRateabilityProperty) {
|
||
if (!occasion.isNull() && (occasion != inc->occasion())) {
|
||
return false;
|
||
}
|
||
if (respectRateabilityProperty && !inc->rateable()) {
|
||
return false;
|
||
}
|
||
return true;
|
||
|
||
}
|
||
|
||
qreal RatingMarkSystem::averageSomeFloatProperty(QList<QSharedPointer<RatingMarkIncident> > list,
|
||
QString propertyName,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits,
|
||
Enums::RoundingOption rounding,
|
||
bool respectWeight,
|
||
bool respectRateabilityProperty)
|
||
{
|
||
qreal sum = 0;
|
||
qreal weightSum = 0;
|
||
QListIterator<QSharedPointer<RatingMarkIncident> > iter(list);
|
||
bool ok = true;
|
||
|
||
while (ok && iter.hasNext()) {
|
||
QSharedPointer<RatingMarkIncident> inc = iter.next();
|
||
qreal addValue;
|
||
QVariant var = inc->getProperty(propertyName);
|
||
if (var.isValid() && !var.isNull()) {
|
||
addValue = var.toFloat(&ok);
|
||
if (!ok) {
|
||
qDebug()<<"RatingMarkSystem::averageSomeFloatProperty: Float conversion of "<<propertyName<<" was not successful. ";
|
||
}
|
||
} else {
|
||
ok = false;
|
||
qDebug()<<"RatingMarkSystem::averageSomeFloatProperty: "<<propertyName<<" was not found - typo?";
|
||
}
|
||
if (ok && this->shallBeCalculated(inc, occasion, respectRateabilityProperty)) {
|
||
qreal weight = respectWeight ? inc->weight() : 1;
|
||
if (weight < -Enums::EPSILON_CALCULATION) {
|
||
ok = true;
|
||
}
|
||
sum += weight * addValue;
|
||
weightSum += weight;
|
||
}
|
||
}
|
||
Q_ASSERT(ok);
|
||
return !ok? -1 : ((qAbs(weightSum) < Enums::EPSILON_CALCULATION)? -1 : this->shortenNumber(sum / weightSum, digits, rounding));
|
||
}
|
||
|
||
qreal RatingMarkSystem::averagePercent(const QList<QSharedPointer<RatingMarkIncident> > list,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits,
|
||
Enums::RoundingOption rounding,
|
||
bool respectWeight,
|
||
bool respectRateabilityProperty)
|
||
{
|
||
return this->averageSomeFloatProperty(list,"percentValue", occasion, digits, rounding, respectWeight, respectRateabilityProperty);
|
||
}
|
||
|
||
qreal RatingMarkSystem::averageValueSimple(QList<QSharedPointer<RatingMarkIncident> > list,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits,
|
||
Enums::RoundingOption rounding,
|
||
bool respectWeight,
|
||
bool respectRateabilityProperty)
|
||
{
|
||
return this->averageSomeFloatProperty(list,"value", occasion, digits, rounding, respectWeight, respectRateabilityProperty);
|
||
}
|
||
|
||
qreal RatingMarkSystem::symbolToPercent(QString symbol)
|
||
{
|
samples/simple/ratingmarksystem.h | ||
---|---|---|
#include "ratingmarkdefinition.h"
|
||
|
||
class RatingMarkIncident;
|
||
class Occasion;
|
||
////////////////////////////////////////////////
|
||
/// \brief The RatingMarkSystem class
|
||
///
|
||
... | ... | |
static bool moreThanValue(const QSharedPointer<RatingMarkIncident> &a, const QSharedPointer<RatingMarkIncident> &b);
|
||
virtual QList<QSharedPointer<RatingMarkIncident>> sortPercent(QList<QSharedPointer<RatingMarkIncident>> list, Qt::SortOrder sortOrder);
|
||
virtual QList<QSharedPointer<RatingMarkIncident>> sortValue(QList<QSharedPointer<RatingMarkIncident>> list, Qt::SortOrder sortOrder);
|
||
|
||
|
||
virtual qreal averagePercent(QList<QSharedPointer<RatingMarkIncident>> list,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits = -1,
|
||
Enums::RoundingOption rounding = Enums::RoundingOption::ROUND,
|
||
bool respectWeight = true,
|
||
bool respectRateabilityProperty = true);
|
||
virtual qreal averageValueSimple(QList<QSharedPointer<RatingMarkIncident>> list,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits = -1,
|
||
Enums::RoundingOption rounding = Enums::RoundingOption::ROUND,
|
||
bool respectWeight = true,
|
||
bool respectRateabilityProperty = true);
|
||
virtual bool shallBeCalculated(QSharedPointer<RatingMarkIncident> inc,
|
||
QSharedPointer<Occasion> occasion,
|
||
bool respectRateabilityProperty = true);
|
||
|
||
|
||
qreal symbolToPercent(QString symbol);
|
||
QString percentToSymbol(qreal percent);
|
||
qreal shortenNumber(qreal nr, int digits, Enums::RoundingOption rounding);
|
||
protected:
|
||
qreal averageSomeFloatProperty(QList<QSharedPointer<RatingMarkIncident>> list,
|
||
QString propertyName,
|
||
QSharedPointer<Occasion> occasion,
|
||
int digits = -1,
|
||
Enums::RoundingOption rounding = Enums::RoundingOption::ROUND,
|
||
bool respectWeight = true,
|
||
bool respectRateabilityProperty = true);
|
||
|
||
QString m_name;
|
||
QList<QSharedPointer<RatingMarkDefinition>> m_ratingMarkDefinitions;
|
||
bool m_valuesComputable = false;
|
samples/simple/simple.pro | ||
---|---|---|
ratingmarksystem.h \
|
||
ratingmarkdefinition.h \
|
||
enums.h \
|
||
occasion.h \
|
||
datacreation.h \
|
||
address.h \
|
||
contact.h \
|
||
group.h \
|
||
person.h \
|
||
pupil.h \
|
||
... | ... | |
incident.cpp \
|
||
ratingmarksystem.cpp \
|
||
ratingmarkdefinition.cpp \
|
||
occasion.cpp \
|
||
datacreation.cpp \
|
||
address.cpp \
|
||
contact.cpp \
|
||
group.cpp \
|
||
person.cpp \
|
||
pupil.cpp
|
src/entitymanager.cpp | ||
---|---|---|
EntityManager::connectionNames.removeOne(name);
|
||
}
|
||
|
||
QSharedPointer<Entity> EntityManager::findById(const qint64 &id,
|
||
QSharedPointer<Entity> EntityManager:: findById(const qint64 &id,
|
||
QSharedPointer<Entity> &e,
|
||
const bool refresh) {
|
||
QSharedPointer<Entity> r;
|
Auch abrufbar als: Unified diff
argh...