2 #include <QtCore/QDebug> //Debug pro informace
3 #include <QtCore/QSettings>
4 #include <QtCore/QTimer>
7 Set pointers to NULL and create timer
9 Event::Event(QObject *parent) :
14 timer = new QTimer(this);
15 timer->setSingleShot(true);//A single-shot timer fires only once
16 connect(timer,SIGNAL(timeout()),this,SLOT(TimerTimeout()));
20 Returns the summary of event
23 QString Event::GetSummary()
32 QString Event::GetId()
38 Returns if profile is now
39 \returns bool is event now
43 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Is profil now? " << is_now;
48 Returns if profile is old
49 \returns bool is event old
53 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Is profil old? " << is_old;
58 Set time and data of event
60 \param des desctription
62 \param SDate start date
65 void Event::SetTime(QString I, QString des ,QString sum, QDateTime SDate,QDateTime EDate)
70 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "Setting date time events name" << sum ;
77 Check event start end end
79 void Event::timerSet()
81 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "timer will be now set for event " << description ;
83 if(start_Date > QDateTime::currentDateTime()){ //id start date in future
84 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "date in future" ;
85 timer->start(QDateTime::currentDateTime().secsTo(start_Date) * 1000 ); // wait to event start
86 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "sec to event start" << QDateTime::currentDateTime().secsTo(start_Date) ;
87 } else if(( end_Date <= QDateTime::currentDateTime()) ) { //is end date in past
88 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "event is old" ;
90 } else if((start_Date <= QDateTime::currentDateTime()) && ( end_Date >= QDateTime::currentDateTime()) ) { //is now ?
92 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "event is now" ;
93 timer->start(QDateTime::currentDateTime().secsTo(end_Date) * 1000);
94 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "sec to event end" << QDateTime::currentDateTime().secsTo(end_Date) ;
95 emit s_event_change(this); //emit signal
102 void Event::TimerTimeout()
104 if((is_now == false) && (is_old == false )){//not not and not old
106 timer->start(start_Date.secsTo(end_Date) * 1000);//timer to end of event
107 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "sec to event end" << start_Date.secsTo(end_Date) ;
108 emit s_event_change(this); //emit signal
109 } else if((is_now == true) && (is_old == false)) {
110 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << " end of event " ;
113 emit s_event_change(this);//emit signal