Changeset 8bd618c in confclerk_git


Ignore:
Timestamp:
10/17/12 20:49:16 (10 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
908b4ce
Parents:
95257a6
Message:

We added the conferenceId to some alarm related methods (ticket #41).

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/alarm/alarm.cpp

    r95257a6 r8bd618c  
    5858    alarm_action_set_label(alarmAction, "ConfClerk");
    5959
    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);
    6161    qDebug() << "Setting alarm: " << command;
    6262    alarm_action_set_exec_command(alarmAction, command.toLocal8Bit().data());
  • src/app/main.cpp

    r95257a6 r8bd618c  
    4545    QCoreApplication::setApplicationName("ConfClerk");
    4646    QCoreApplication::setApplicationVersion(VERSION);
    47  
    48     QWidget *window;
    49     window = new MainWindow;
    5047
     48    QWidget* window = new MainWindow;
    5149
    5250#ifdef MAEMO
     
    6058        if( connection.registerService("at.priv.toastfreeware.confclerk") == false)
    6159        {
    62                 if(argc>1)
     60            if(argc==3)
    6361                {
    6462                        QDBusInterface *interface = new QDBusInterface("at.priv.toastfreeware.confclerk",
     
    6664                                                                       "at.priv.toastfreeware.confclerk.AlarmInterface",
    6765                                                                       connection);
    68                         interface->call("Alarm",atoi(argv[1]));
     66                interface->call("Alarm",atoi(argv[2]));
    6967                        return 0;
    7068                }
    7169        }
    7270    }
     71#endif
    7372
    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);
    7778        dialog.exec();
    7879    }
    79 #endif
    80 
    8180    window->show();
    8281
  • src/gui/eventdialog.cpp

    r95257a6 r8bd618c  
    2727#endif
    2828
    29 EventDialog::EventDialog(const int &aEventId, QWidget *aParent)
    30     : QDialog(aParent)
    31     , mEventId(aEventId)
    32 {
     29EventDialog::EventDialog(int conferenceId, int eventId, QWidget *parent): QDialog(parent), mConferenceId(conferenceId), mEventId(eventId) {
    3330    setupUi(this);
    3431
     
    3936#endif
    4037
    41     Event event = Event::getById(mEventId,Conference::activeConference());
     38    Event event = Event::getById(mEventId, mConferenceId);
    4239
    4340    title->setText(event.title());
     
    6663void EventDialog::favouriteClicked()
    6764{
    68     Event event = Event::getById(mEventId,Conference::activeConference());
     65    Event event = Event::getById(mEventId, mConferenceId);
    6966
    70     QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
     67    QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
    7168    if(event.isFavourite())
    7269    {
     
    8481    {
    8582        // 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);
    8784    }
    8885
     
    9895void EventDialog::alarmClicked()
    9996{
    100     Event event = Event::getById(mEventId,Conference::activeConference());
     97    Event event = Event::getById(mEventId, mConferenceId);
    10198
    10299    if(event.hasAlarm())
  • src/gui/eventdialog.h

    r95257a6 r8bd618c  
    2929    Q_OBJECT
    3030public:
    31     EventDialog(const int &aEventId, QWidget *aParent = NULL);
     31    EventDialog(int conferencdId, int eventId, QWidget *parent = 0);
    3232    ~EventDialog() {}
    3333private slots:
     
    3737    void eventChanged(int aEventId, bool favouriteChanged); // emited when user changes some event details, eg. sets it Favourite
    3838private:
     39    int mConferenceId;
    3940    int mEventId;
    4041};
  • src/gui/mainwindow.cpp

    r95257a6 r8bd618c  
    5151const QString PROXY_PASSWD;
    5252
    53 MainWindow::MainWindow(int aEventId, QWidget *aParent): QMainWindow(aParent) {
     53MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) {
    5454    setupUi(this);
    5555
     
    7676        AppSettings::setDirectConnection(true);
    7777
    78     /*
    79     if(AppSettings::isDirectConnection())
    80     {
    81         qDebug() << "Setting-up proxy: " << AppSettings::proxyAddress() << ":" << AppSettings::proxyPort();
    82     }
    83     */
    8478    QNetworkProxy proxy(
    8579            AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
     
    117111    }
    118112
    119     // open dialog for given Event ID
    120     // this is used in case Alarm Dialog request application to start
    121     if(aEventId)
    122     {
    123         try
    124         {
    125             EventDialog dialog(aEventId,this);
    126             dialog.exec();
    127         }
    128         catch(OrmNoObjectException&) {} // just start application
    129         catch(...) {} // just start application
    130     }
    131 
    132113    connect(mNetworkAccessManager, SIGNAL(finished(QNetworkReply*)), SLOT(networkQueryFinished(QNetworkReply*)));
    133 
    134114    connect(mXmlParser, SIGNAL(parsingScheduleBegin()), conferenceModel, SLOT(newConferenceBegin()));
    135115    connect(mXmlParser, SIGNAL(parsingScheduleEnd(int)), conferenceModel, SLOT(newConferenceEnd(int)));
     
    227207
    228208
    229 void MainWindow::useConference(int id)
    230 {
    231     if (id == -1)  // in case no conference is active
     209void MainWindow::useConference(int conferenceId)
     210{
     211    if (conferenceId == -1)  // in case no conference is active
    232212    {
    233213        unsetConference();
     
    235215    }
    236216    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);
    240222
    241223        // looks like it does not work at n900
    242         setWindowTitle(new_active.title());
     224        setWindowTitle(activeConference.title());
    243225
    244226        // optimization.
  • src/gui/mainwindow.h

    r95257a6 r8bd618c  
    3535    Q_OBJECT
    3636public:
    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);
    4138signals:
    4239    void conferenceRemoved();
     
    6057    void changeConferenceUrl(int, const QString&);
    6158
    62     void useConference(int id);
     59    void useConference(int conferenceId);
    6360    void unsetConference();
    6461
  • src/gui/tabcontainer.cpp

    r95257a6 r8bd618c  
    6666        return;
    6767
    68     EventDialog dialog(static_cast<Event*>(aIndex.internalPointer())->id(),this);
     68    EventDialog dialog(Conference::activeConference(), static_cast<Event*>(aIndex.internalPointer())->id(),this);
    6969#ifdef N810
    7070    dialog.setFixedWidth(static_cast<QWidget*>(parent())->width());
  • src/mvc/conference.cpp

    r95257a6 r8bd618c  
    5252}
    5353
    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;
     54int 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();
    7358}
    7459
  • src/mvc/conference.h

    r95257a6 r8bd618c  
    3636    static Conference getById(int id);
    3737    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();
    3942
    4043public:
Note: See TracChangeset for help on using the changeset viewer.