- Timestamp:
- 01/21/10 23:03:07 (13 years ago)
- Branches:
- master, qt5
- Children:
- d336730
- Parents:
- 1735f55
- Location:
- src/mvc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mvc/eventmodel.cpp
r1735f55 rc718a77 1 1 #include "eventmodel.h" 2 #include <appsettings.h> 2 3 #include <conference.h> 3 4 #include <track.h> … … 220 221 } 221 222 222 void EventModel::emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight) 223 { 224 emit(dataChanged(aTopLeft,aBottomRight)); 225 } 226 223 void EventModel::updateModel(int aEventId) 224 { 225 for(int i=0; i<mEvents.count(); i++) 226 { 227 if(mEvents[i].id() == aEventId) 228 mEvents[i] = Event::getById(aEventId,AppSettings::confId()); 229 } 230 231 // find the ModelIndex for given aEventId 232 for(int i=0; i<mGroups.count(); i++) 233 { 234 QModelIndex groupIndex = index(i,0,QModelIndex()); 235 for(int j=0; j<mGroups[i].mChildCount; j++) 236 { 237 QModelIndex eventIndex = index(j,0,groupIndex); 238 if(static_cast<Event*>(eventIndex.internalPointer())->id() == aEventId) 239 { 240 emit(dataChanged(eventIndex,eventIndex)); 241 } 242 } 243 } 244 } 245 -
src/mvc/eventmodel.h
r1735f55 rc718a77 21 21 void loadEventsByTrack(const QDate &aDate, int aConferenceId); // loads Events grouped by Track from the DB 22 22 int loadSearchResultEvents(const QDate &aDate, int aConferenceId); 23 // a method to force 'EventModel' emit signal 'dataChanged()'24 // a 'view', eg. 'TreeView' listens for this signal and redraws changed items(indexes)25 void emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);26 23 27 24 private: … … 46 43 void clearModel(); 47 44 45 public slots: 46 void updateModel(int aEventId); 47 48 48 private: 49 49 QList<Event> mEvents; -
src/mvc/mvc.pro
r1735f55 rc718a77 8 8 # module dependencies 9 9 LIBS += -L$$DESTDIR -lorm 10 INCLUDEPATH += ../orm 10 INCLUDEPATH += ../orm ../app 11 11 DEPENDPATH += . ../orm 12 12 TARGETDEPS += $$DESTDIR/liborm.a -
src/mvc/treeview.cpp
r1735f55 rc718a77 49 49 Event event = Event::getById(aIndex.data().toInt(),1); 50 50 if(event.isFavourite()) 51 { 52 static_cast<Event*>(aIndex.internalPointer())->setFavourite(false); // list of events 53 event.setFavourite(false); // update DB 54 } 51 event.setFavourite(false); 55 52 else 56 {57 static_cast<Event*>(aIndex.internalPointer())->setFavourite(true); // list of events58 53 event.setFavourite(true); 59 }54 event.update("favourite"); 60 55 qDebug() << " FAVOURITE [" << qVariantValue<QString>(aIndex.data()) << "] -> " << event.isFavourite(); 61 event.update("favourite");62 // since the Favourite icon has changed, update TreeView accordingly63 static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);56 // since the Favourite icon has changed, update TreeViews accordingly 57 // all TreeViews have to listen on this signal 58 emit(eventHasChanged(event.id())); 64 59 handled = true; 65 60 } … … 72 67 if(event.hasAlarm()) 73 68 { 74 static_cast<Event*>(aIndex.internalPointer())->setHasAlarm(false); // list of events75 69 event.setHasAlarm(false); // update DB 76 70 #ifdef MAEMO … … 83 77 else 84 78 { 85 static_cast<Event*>(aIndex.internalPointer())->setHasAlarm(true); // list of events86 79 event.setHasAlarm(true); 87 80 #ifdef MAEMO … … 92 85 #endif /* MAEMO */ 93 86 } 87 event.update("alarm"); 94 88 qDebug() << " ALARM [" << qVariantValue<QString>(aIndex.data()) << "] -> " << event.hasAlarm(); 95 event.update("alarm");96 89 // since the Alarm icon has changed, update TreeView accordingly 97 static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex); 90 // all TreeViews have to listen on this signal 91 emit(eventHasChanged(event.id())); 98 92 handled = true; 99 93 } -
src/mvc/treeview.h
r1735f55 rc718a77 18 18 void requestForMap(const QModelIndex &aIndex); 19 19 void requestForWarning(const QModelIndex &aIndex); 20 void eventHasChanged(int aEventId); // emited when user changes some event details, eg. sets it Favourite 20 21 }; 21 22
Note: See TracChangeset
for help on using the changeset viewer.