Ignore:
Timestamp:
01/29/10 11:06:55 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
5007fde
Parents:
8b0bf22
Message:

possible to have multiple conferences in the DB

  • possible to switch among them
  • conference schedules have to follow FOSDEM conference xml structure
  • 'select Conference' bar is visible only if there are more than one conference available
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    r8b0bf22 r1fb7a33  
    4444    connect(tabWidget, SIGNAL(infoIconClicked()), SLOT(aboutApp()));
    4545
    46     if(Conference::getAll().count())
     46    selectConference->setDuplicatesEnabled(false);
     47    int confCount = Conference::getAll().count();
     48    if(confCount)
    4749    {
    4850        initTabs();
    4951        fillAndShowConferenceHeader();
    5052        setWindowTitle(Conference::getById(confId).title());
     53
     54        if(confCount==1) // don't have to show 'selectConference' widget, if there is only one conference in the DB
     55            selectConferenceWidget->hide();
     56        else
     57        {
     58            // have to fill comboBox with available conferences
     59            QList<Conference> confs = Conference::getAll();
     60            QListIterator<Conference> i(confs);
     61            while(i.hasNext())
     62            {
     63                Conference conf = i.next();
     64                selectConference->addItem(conf.title(),conf.id());
     65            }
     66            int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
     67            selectConference->setCurrentIndex(idx);
     68        }
     69        connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
    5170    }
    5271    else
    5372    {
    5473        conferenceHeader->hide();
     74        selectConferenceWidget->hide();
    5575        // go to the 'conferenceTab', so the user can import the schedule
    5676        tabWidget->setCurrentIndex(6); // 6 - conference tab
     
    7595    Q_UNUSED(aConfId);
    7696
    77     QList<Conference> confs = Conference::getAll();
    78     if(confs.count())
     97    Conference conf = Conference::getById(aConfId);
     98    if( selectConference->findText(conf.title()) < 0 ) // item doesn't exist
    7999    {
    80         initTabs();
    81         fillAndShowConferenceHeader();
    82         setWindowTitle(Conference::getById(Conference::activeConference()).title());
     100        disconnect(selectConference, SIGNAL(currentIndexChanged(int)), this, SLOT(conferenceChanged(int)));
     101        selectConference->addItem(conf.title(),conf.id());
     102        connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
     103    }
     104    int confCount = Conference::getAll().count();
     105    if(confCount)
     106    {
     107        int idx = selectConference->findText(conf.title());
     108        selectConference->setCurrentIndex(idx);
     109
     110        if(confCount>1)
     111            selectConferenceWidget->show();
     112
     113        conferenceChanged(idx);
    83114    }
    84115}
     
    144175}
    145176
     177void MainWindow::conferenceChanged(int aIndex)
     178{
     179    Conference::getById(Conference::activeConference()).update("active",0);
     180    Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
     181
     182    initTabs();
     183    fillAndShowConferenceHeader();
     184    setWindowTitle(Conference::getById(Conference::activeConference()).title());
     185}
     186
Note: See TracChangeset for help on using the changeset viewer.