- Timestamp:
- 10/17/12 20:49:16 (10 years ago)
- Branches:
- master, qt5
- Children:
- 908b4ce
- Parents:
- 95257a6
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/alarm/alarm.cpp
r95257a6 r8bd618c 58 58 alarm_action_set_label(alarmAction, "ConfClerk"); 59 59 60 QString command = QFileInfo(*qApp->argv()).absoluteFilePath() + QString(" %1 ").arg(QString::number(eventId));60 QString command = QFileInfo(*qApp->argv()).absoluteFilePath() + QString(" %1 %2").arg(conferenceId, eventId); 61 61 qDebug() << "Setting alarm: " << command; 62 62 alarm_action_set_exec_command(alarmAction, command.toLocal8Bit().data()); -
src/app/main.cpp
r95257a6 r8bd618c 45 45 QCoreApplication::setApplicationName("ConfClerk"); 46 46 QCoreApplication::setApplicationVersion(VERSION); 47 48 QWidget *window;49 window = new MainWindow;50 47 48 QWidget* window = new MainWindow; 51 49 52 50 #ifdef MAEMO … … 60 58 if( connection.registerService("at.priv.toastfreeware.confclerk") == false) 61 59 { 62 if(argc>1)60 if(argc==3) 63 61 { 64 62 QDBusInterface *interface = new QDBusInterface("at.priv.toastfreeware.confclerk", … … 66 64 "at.priv.toastfreeware.confclerk.AlarmInterface", 67 65 connection); 68 interface->call("Alarm",atoi(argv[1]));66 interface->call("Alarm",atoi(argv[2])); 69 67 return 0; 70 68 } 71 69 } 72 70 } 71 #endif 73 72 74 if(argc > 1) 75 { 76 EventDialog dialog(atoi(argv[1]), window); 73 // If we were started with the parameters confernceid and eventid, show the corresponding event (alarm) 74 if (argc == 3) { 75 QString conferenceIdStr = argv[1]; 76 QString eventIdStr = argv[2]; 77 EventDialog dialog(conferenceIdStr.toInt(), eventIdStr.toInt(), window); 77 78 dialog.exec(); 78 79 } 79 #endif80 81 80 window->show(); 82 81 -
src/gui/eventdialog.cpp
r95257a6 r8bd618c 27 27 #endif 28 28 29 EventDialog::EventDialog(const int &aEventId, QWidget *aParent) 30 : QDialog(aParent) 31 , mEventId(aEventId) 32 { 29 EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) { 33 30 setupUi(this); 34 31 … … 39 36 #endif 40 37 41 Event event = Event::getById(mEventId, Conference::activeConference());38 Event event = Event::getById(mEventId, mConferenceId); 42 39 43 40 title->setText(event.title()); … … 66 63 void EventDialog::favouriteClicked() 67 64 { 68 Event event = Event::getById(mEventId, Conference::activeConference());65 Event event = Event::getById(mEventId, mConferenceId); 69 66 70 QList<Event> conflicts = Event::conflictEvents(event.id(), Conference::activeConference());67 QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId); 71 68 if(event.isFavourite()) 72 69 { … … 84 81 { 85 82 // event has became 'favourite' and so 'conflicts' list may have changed 86 conflicts = Event::conflictEvents(event.id(), Conference::activeConference());83 conflicts = Event::conflictEvents(event.id(), mConferenceId); 87 84 } 88 85 … … 98 95 void EventDialog::alarmClicked() 99 96 { 100 Event event = Event::getById(mEventId, Conference::activeConference());97 Event event = Event::getById(mEventId, mConferenceId); 101 98 102 99 if(event.hasAlarm()) -
src/gui/eventdialog.h
r95257a6 r8bd618c 29 29 Q_OBJECT 30 30 public: 31 EventDialog( const int &aEventId, QWidget *aParent = NULL);31 EventDialog(int conferencdId, int eventId, QWidget *parent = 0); 32 32 ~EventDialog() {} 33 33 private slots: … … 37 37 void eventChanged(int aEventId, bool favouriteChanged); // emited when user changes some event details, eg. sets it Favourite 38 38 private: 39 int mConferenceId; 39 40 int mEventId; 40 41 }; -
src/gui/mainwindow.cpp
r95257a6 r8bd618c 51 51 const QString PROXY_PASSWD; 52 52 53 MainWindow::MainWindow( int aEventId, QWidget *aParent): QMainWindow(aParent) {53 MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) { 54 54 setupUi(this); 55 55 … … 76 76 AppSettings::setDirectConnection(true); 77 77 78 /*79 if(AppSettings::isDirectConnection())80 {81 qDebug() << "Setting-up proxy: " << AppSettings::proxyAddress() << ":" << AppSettings::proxyPort();82 }83 */84 78 QNetworkProxy proxy( 85 79 AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy, … … 117 111 } 118 112 119 // open dialog for given Event ID120 // this is used in case Alarm Dialog request application to start121 if(aEventId)122 {123 try124 {125 EventDialog dialog(aEventId,this);126 dialog.exec();127 }128 catch(OrmNoObjectException&) {} // just start application129 catch(...) {} // just start application130 }131 132 113 connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(networkQueryFinished(QNetworkReply*))); 133 134 114 connect(mXmlParser, SIGNAL(parsingScheduleBegin()), conferenceModel, SLOT(newConferenceBegin())); 135 115 connect(mXmlParser, SIGNAL(parsingScheduleEnd(int)), conferenceModel, SLOT(newConferenceEnd(int))); … … 227 207 228 208 229 void MainWindow::useConference(int id)230 { 231 if ( id == -1) // in case no conference is active209 void MainWindow::useConference(int conferenceId) 210 { 211 if (conferenceId == -1) // in case no conference is active 232 212 { 233 213 unsetConference(); … … 235 215 } 236 216 try { 237 Conference::getById(Conference::activeConference()).update("active",0); 238 Conference new_active = Conference::getById(id); 239 new_active.update("active",1); 217 int oldActiveConferenceId = Conference::activeConference(); 218 bool switchActiveConference = conferenceId != oldActiveConferenceId; 219 if (switchActiveConference) Conference::getById(oldActiveConferenceId).update("active", 0); 220 Conference activeConference = Conference::getById(conferenceId); 221 if (switchActiveConference) activeConference.update("active",1); 240 222 241 223 // looks like it does not work at n900 242 setWindowTitle( new_active.title());224 setWindowTitle(activeConference.title()); 243 225 244 226 // optimization. -
src/gui/mainwindow.h
r95257a6 r8bd618c 35 35 Q_OBJECT 36 36 public: 37 // aEventId is used to inform widget to automatically open 38 // Event dialog for given Event ID 39 MainWindow(int aEventId = 0, QWidget *aParent = NULL); 40 ~MainWindow() {} 37 MainWindow(QWidget *parent = 0); 41 38 signals: 42 39 void conferenceRemoved(); … … 60 57 void changeConferenceUrl(int, const QString&); 61 58 62 void useConference(int id);59 void useConference(int conferenceId); 63 60 void unsetConference(); 64 61 -
src/gui/tabcontainer.cpp
r95257a6 r8bd618c 66 66 return; 67 67 68 EventDialog dialog( static_cast<Event*>(aIndex.internalPointer())->id(),this);68 EventDialog dialog(Conference::activeConference(), static_cast<Event*>(aIndex.internalPointer())->id(),this); 69 69 #ifdef N810 70 70 dialog.setFixedWidth(static_cast<QWidget*>(parent())->width()); -
src/mvc/conference.cpp
r95257a6 r8bd618c 52 52 } 53 53 54 int Conference::activeConference() 55 { 56 { 57 QSqlQuery query("SELECT id FROM conference WHERE active = 1"); 58 query.exec(); 59 60 // TODO: change it so that it will select somw existing ID 61 62 if (query.next()) { 63 return query.record().value("id").toInt(); 64 } 65 } 66 67 QSqlQuery query2("SELECT id FROM conference ORDER BY id"); 68 if (query2.next()) { 69 return query2.record().value("id").toInt(); 70 } 71 72 return -1; 54 int Conference::activeConference() { 55 QSqlQuery query("SELECT id FROM conference ORDER BY active DESC, id LIMIT 1"); 56 if (!query.exec() || !query.first()) return -1; 57 return query.record().value("id").toInt(); 73 58 } 74 59 -
src/mvc/conference.h
r95257a6 r8bd618c 36 36 static Conference getById(int id); 37 37 static QList<Conference> getAll(); 38 static int activeConference(); ///< returns -1 if no conference is active 38 39 /// Returns the active conference. If no active conference can be found, it returns the conference with the lowest id. 40 /// If no conference exists or database errors occur, it returns -1. 41 static int activeConference(); 39 42 40 43 public:
Note: See TracChangeset
for help on using the changeset viewer.