2 #include <QtCore/QDateTime>
3 #include <QtCore/QVector>
4 #include <QtCore/QDebug> //Debug pro informace
8 Calendar::Calendar(QObject *parent) :
14 Add event into calendar
16 \param des desctription
18 \param SDate start date
21 void Calendar::AddEvent(QString id, QString des ,QString sum, QDateTime SDate, QDateTime EDate)
24 if((event_new = findEvent(id)) == NULL){
25 event_new = new Event(this);
26 vector_calendars_events.append(event_new);
27 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "Create new event ";
28 connect(event_new,SIGNAL(s_event_change(Event*)),this,SLOT(EventChanged(Event*)));
29 event_new->SetTime(id, des, sum, SDate, EDate);
36 void Calendar::DeleteEvent(QString id)
38 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "Delete event " << id;
39 for(int i = 0; i < vector_calendars_events.size();++i)
41 if(vector_calendars_events.at(i)->GetId() == id){
42 delete vector_calendars_events.at(i);
43 vector_calendars_events.remove(i);
48 /** Delete all old events
50 void Calendar::DeleteOldEvents()
52 ////qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "delete all old events ";
53 QMutableVectorIterator<Event *> i(vector_calendars_events);
55 Event *val = i.next();
56 if (val->isOld() == true) {
57 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "Event is old delete ";
65 Slot for change in event
68 void Calendar::EventChanged(Event * ev)
71 emit s_eventStart(ev);
77 find all event for now
78 \returns vector of events
80 QVector<Event *> Calendar::FindEventsNow()
82 QVector<Event *> vector;
83 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Search for now events ";
84 foreach(Event *evt, vector_calendars_events )
87 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Select event";
97 Event * Calendar::findEvent(QString i)
99 foreach(Event * evt, vector_calendars_events)
101 if(evt->GetId() == i) return evt;
109 void Calendar::SetName(QString n)
111 name_of_calendar = n;
112 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << " jmeno kalendare je " << n;
116 \param ico icon of cal
118 void Calendar::SetIcon(QIcon ico)
120 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Setting icon fo cal" ;
127 void Calendar::SetId(int i)
129 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Id_cal:" << Id_cal;
135 int Calendar::GetId()
137 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Id_cal:" << Id_cal;
143 QIcon Calendar::GetIcon()
145 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "return icon";
151 QString Calendar::GetName()
153 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Text:" << "Get name:" << name_of_calendar;
154 return name_of_calendar;