Changeset 0bb39f5 for src


Ignore:
Timestamp:
01/27/10 16:31:10 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
a790a90
Parents:
07ae23a
Message:

removed appsettings

  • created 'active' column in 'conference' table
Location:
src
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • src/app/app.pro

    r07ae23a r0bb39f5  
    1717}
    1818
    19 SOURCES += main.cpp \
    20            appsettings.cpp
    21 
    22 HEADERS += appsettings.h
     19SOURCES += main.cpp
    2320
    2421RESOURCES += ../icons.qrc \
  • src/gui/alarmdialog.cpp

    r07ae23a r0bb39f5  
    11#include "alarmdialog.h"
    2 #include <appsettings.h>
     2#include <conference.h>
    33
    44#include <QApplication>
     
    4747    try
    4848    {
    49         Event event = Event::getById(mEventId,AppSettings::confId());
     49        Event event = Event::getById(mEventId,Conference::activeConference());
    5050        titleStr = "Event alarm";
    5151        messageStr = event.title();
     
    8989    try
    9090    {
    91         Event event = Event::getById(mEventId,AppSettings::confId());
     91        Event event = Event::getById(mEventId,Conference::activeConference());
    9292        event.setHasAlarm(false);
    9393        event.update("alarm");
  • src/gui/eventdialog.cpp

    r07ae23a r0bb39f5  
    11#include "eventdialog.h"
    2 #include <appsettings.h>
     2#include <conference.h>
    33
    44#include <QScrollBar>
     
    1818#endif
    1919
    20     Event event = Event::getById(mEventId,AppSettings::confId());
     20    Event event = Event::getById(mEventId,Conference::activeConference());
    2121
    2222    title->setText(event.title());
     
    4242void EventDialog::favouriteClicked()
    4343{
    44     Event event = Event::getById(mEventId,AppSettings::confId());
     44    Event event = Event::getById(mEventId,Conference::activeConference());
    4545
    4646    if(event.isFavourite())
     
    6565void EventDialog::alarmClicked()
    6666{
    67     Event event = Event::getById(mEventId,AppSettings::confId());
     67    Event event = Event::getById(mEventId,Conference::activeConference());
    6868
    6969    if(event.hasAlarm())
  • src/gui/favtabcontainer.cpp

    r07ae23a r0bb39f5  
    1 /*
    2  * favtabcontainer.cpp
    3  *
    4  *  Created on: Jan 27, 2010
    5  *      Author: maemo
    6  */
    71
    82#include "favtabcontainer.h"
     
    2216    // we need to reload favourites, because some favourite could be deleted
    2317    //static_cast<EventModel*>(favTreeView->model())->updateModel(aEventId);
    24     QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    25     QDate aEndDate = Conference::getById(AppSettings::confId()).end();
    26     dayNavigator->setDates(aStartDate, aEndDate);
    27     updateTreeView( Conference::getById(AppSettings::confId()).start() );
     18    int confId = Conference::activeConference();
     19    QDate startDate = Conference::getById(confId).start();
     20    QDate endDate = Conference::getById(confId).end();
     21    dayNavigator->setDates(startDate, endDate);
     22    updateTreeView( Conference::getById(confId).start() );
    2823}
     24
  • src/gui/mainwindow.cpp

    r07ae23a r0bb39f5  
    11#include "mainwindow.h"
    2 #include <appsettings.h>
    32
    43#include <QTreeView>
     
    2827    setupUi(this);
    2928
    30     // Sanity check for existence of any Conference in the DB
    31     // it AppSettings::confId() is 0, but there are any Conference(s) in the DB
    32     // set the confId in the AppSettings for the ID of the first conference in the DB
     29    int confId = Conference::activeConference();
     30
    3331    QList<Conference> confs = Conference::getAll();
    34     if(!confs.count()) // no conference(s) in the DB
     32    if(confs.count())
    3533    {
    36         AppSettings::setConfId(0); // no conference in the DB
    37     }
    38     else
    39     {
    40         if(AppSettings::confId() == 0)
    41             AppSettings::setConfId(confs[0].id());
    42 
    4334        setWindowTitle(confs[0].title());
    4435    }
     
    6253    if(Conference::getAll().count()) // no conference(s) in the DB
    6354    {
    64         QDate startDate = Conference::getById(AppSettings::confId()).start();
    65         QDate endDate = Conference::getById(AppSettings::confId()).end();
     55        QDate startDate = Conference::getById(confId).start();
     56        QDate endDate = Conference::getById(confId).end();
    6657        //
    6758        dayTabContainer->setDates(startDate, endDate);
     
    7162        searchTabContainer->setDates(startDate, endDate);
    7263        //
    73         conferenceTitle->setText(Conference::getById(AppSettings::confId()).title());
    74         conferenceSubtitle->setText(Conference::getById(AppSettings::confId()).subtitle());
    75         conferenceWhere->setText(Conference::getById(AppSettings::confId()).city() + ", " + Conference::getById(AppSettings::confId()).venue());
     64        conferenceTitle->setText(Conference::getById(confId).title());
     65        conferenceSubtitle->setText(Conference::getById(confId).subtitle());
     66        conferenceWhere->setText(Conference::getById(confId).city() + ", " + Conference::getById(confId).venue());
    7667        conferenceWhen->setText(
    77                 Conference::getById(AppSettings::confId()).start().toString("dd-MM-yyyy")
     68                Conference::getById(confId).start().toString("dd-MM-yyyy")
    7869                + ", " +
    79                 Conference::getById(AppSettings::confId()).end().toString("dd-MM-yyyy"));
     70                Conference::getById(confId).end().toString("dd-MM-yyyy"));
    8071    }
    8172
     
    9990
    10091    QList<Conference> confs = Conference::getAll();
    101     if(!confs.count()) // no conference(s) in the DB
     92    if(confs.count())
    10293    {
    103         AppSettings::setConfId(0); // no conference in the DB
    104     }
    105     else
    106     {
    107         if(AppSettings::confId() == 0)
    108             AppSettings::setConfId(confs[0].id());
    109 
    11094        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
    111         QDate startDate = Conference::getById(AppSettings::confId()).start();
    112         QDate endDate = Conference::getById(AppSettings::confId()).end();
     95        QDate startDate = Conference::getById(Conference::activeConference()).start();
     96        QDate endDate = Conference::getById(Conference::activeConference()).end();
    11397        dayTabContainer->setDates(startDate, endDate);
    11498        tracksTabContainer->setDates(startDate, endDate);
  • src/gui/searchtabcontainer.cpp

    r07ae23a r0bb39f5  
    1 
    2 #include <appsettings.h>
    31
    42#include "searchtabcontainer.h"
     
    6563    QString keyword = searchHeader->searchEdit->text().replace( QString("%"), QString("\\%") );
    6664    qDebug() << "\nKeyword to search: " << keyword;
    67     SqlEngine::searchEvent( AppSettings::confId(), columns, keyword );
    6865
    69     QDate startDate = Conference::getById(AppSettings::confId()).start();
    70     QDate endDate = Conference::getById(AppSettings::confId()).end();
     66    int confId = Conference::activeConference();
     67    SqlEngine::searchEvent( confId, columns, keyword );
     68
     69    QDate startDate = Conference::getById(confId).start();
     70    QDate endDate = Conference::getById(confId).end();
    7171    dayNavigator->setDates(startDate, endDate);
    72     updateTreeView( Conference::getById(AppSettings::confId()).start() );
     72    updateTreeView( Conference::getById(confId).start() );
    7373}
    7474
  • src/gui/tabcontainer.cpp

    r07ae23a r0bb39f5  
    3636    else
    3737    {
    38         QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    39         QDate aEndDate = Conference::getById(AppSettings::confId()).end();
     38        QDate aStartDate = Conference::getById(Conference::activeConference()).start();
     39        QDate aEndDate = Conference::getById(Conference::activeConference()).end();
    4040        dayNavigator->setDates(aStartDate, aEndDate);
    4141    }
     
    4545{
    4646    dayNavigator->show();
    47     loadEvents( aDate, AppSettings::confId() );
     47    loadEvents( aDate, Conference::activeConference() );
    4848    treeView->reset();
    4949}
     
    102102}
    103103
    104 
    105 
  • src/gui/tabcontainer.h

    r07ae23a r0bb39f5  
    55#include "ui_tabcontainer.h"
    66
    7 #include <appsettings.h>
     7#include <conference.h>
    88#include <sqlengine.h>
    99#include <conference.h>
  • src/mvc/conference.cpp

    r07ae23a r0bb39f5  
    1111    << QSqlField("days", QVariant::Int)
    1212    << QSqlField("day_change", QVariant::Int)
    13     << QSqlField("timeslot_duration", QVariant::Int));
     13    << QSqlField("timeslot_duration", QVariant::Int)
     14    << QSqlField("active", QVariant::Bool));
    1415
    1516QString const Conference::sTableName = QString("conference");
     
    3031}
    3132
     33int Conference::activeConference()
     34{
     35    QSqlQuery query("SELECT id FROM conference WHERE active = 1");
     36    query.exec();
     37
     38    QList<int> activeConfs;
     39    while(query.next())
     40        activeConfs.append(query.record().value("id").toInt());
     41
     42    if(activeConfs.count()==0) // no active DB
     43        return 1;
     44    else // even if there are more active confs, the first from the list is confidered active
     45        return activeConfs[0];
     46}
     47
  • src/mvc/conference.h

    r07ae23a r0bb39f5  
    1717    static Conference getById(int id);
    1818    static QList<Conference> getAll();
     19    static int activeConference();
    1920
    2021public:
     
    2930    int dayChange() const { return value("day_change").toInt(); } // in seconds from 00:00
    3031    int timeslotDuration() const { return value("timeslot_duration").toInt(); } // in seconds
     32    bool isActive() const { return value("active").toBool(); }
    3133
    3234    void setId(int id) { setValue("id", id); }
     
    3537    void setVenue(const QString& venue) { setValue("venue", venue); }
    3638    void setCity(const QString& city) { setValue("city", city); }
    37     //void setStart(const QDate& start) { setValue("start", QDateTime(start)); }
    3839    void setStart(const QDate& start) { setValue("start", start); }
    39     //void setEnd(const QDate& end) { setValue("end", QDateTime(end)); }
    4040    void setEnd(const QDate& end) { setValue("end", end); }
    4141    void setDays(int days) { setValue("days", days); }
    4242    void setDayChange(int dayChange) { setValue("day_change", dayChange); }
    4343    void setTimeslotDuration(int timeslotDuration) { setValue("timeslot_duration", timeslotDuration); }
     44    void setActive(bool active) { setValue("active", (int)((active))); }
    4445};
    4546
  • src/mvc/eventmodel.cpp

    r07ae23a r0bb39f5  
    11#include "eventmodel.h"
    2 #include <appsettings.h>
    32#include <conference.h>
    43#include <track.h>
     
    281280    {
    282281        if(mEvents[i].id() == aEventId)
    283             mEvents[i] = Event::getById(aEventId,AppSettings::confId());
     282            mEvents[i] = Event::getById(aEventId,Conference::activeConference());
    284283    }
    285284
  • src/sql/sqlengine.cpp

    r07ae23a r0bb39f5  
    77
    88#include <QDir>
    9 #include <appsettings.h>
    109#include "sqlengine.h"
    1110#include <track.h>
     
    9594                             .arg(-QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))) \
    9695                             .arg(-QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0)));
    97 
    98             QString query = QString("INSERT INTO CONFERENCE (title,subtitle,venue,city,start,end,days,day_change,timeslot_duration) VALUES (%1)").arg(values);
     96                             values.append(QString(", '%1'").arg(confsList.count()>0?"0":"1"));
     97
     98            QString query = QString("INSERT INTO CONFERENCE (title,subtitle,venue,city,start,end,days,day_change,timeslot_duration,active) VALUES (%1)").arg(values);
    9999            QSqlQuery result (query, db);
    100100            aConference["id"] = result.lastInsertId().toString(); // 'id' is assigned automatically
    101 
    102             if(!AppSettings::confId()) // default conf Id isn't set yet => set it up
    103                 AppSettings::setConfId(confId);
    104101        }
    105102    }
     
    241238            "days INTEGER, "
    242239            "day_change INTEGER, "
    243             "timeslot_duration INTEGER);");
     240            "timeslot_duration INTEGER, "
     241            "active INTEGER DEFAULT 0);");
    244242
    245243        query.exec("CREATE TABLE TRACK ( "
Note: See TracChangeset for help on using the changeset viewer.