Changeset 04acaf9 for src


Ignore:
Timestamp:
04/15/10 14:50:23 (12 years ago)
Author:
kirilma <kirilma@…>
Branches:
master, qt5
Children:
2eda137
Parents:
d97bcab
Message:

fix deletion of last conference

implement for cleaning all views in the tabs
clean the models when no active conference found
fix cleaning model and signalling views

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    rd97bcab r04acaf9  
    5151    setupUi(this);
    5252
     53    saved_title = windowTitle();
     54
    5355#ifdef N810
    5456    tabWidget->setTabText(1,"Favs");
     
    99101        setWindowTitle(Conference::getById(confId).title());
    100102
    101         if(confCount==1) // don't have to show 'selectConference' widget, if there is only one conference in the DB
    102             selectConferenceWidget->hide();
    103         else
     103        QList<Conference> confs = Conference::getAll();
     104        QListIterator<Conference> i(confs);
     105        while(i.hasNext())
    104106        {
    105             // have to fill comboBox with available conferences
    106             QList<Conference> confs = Conference::getAll();
    107             QListIterator<Conference> i(confs);
    108             while(i.hasNext())
    109             {
    110                 Conference conf = i.next();
    111                 selectConference->addItem(conf.title(),conf.id());
    112             }
    113             int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
    114             selectConference->setCurrentIndex(idx);
     107            Conference conf = i.next();
     108            selectConference->addItem(conf.title(),conf.id());
    115109        }
     110        int idx = selectConference->findText(Conference::getById(Conference::activeConference()).title());
     111        selectConference->setCurrentIndex(idx);
    116112        connect(selectConference, SIGNAL(currentIndexChanged(int)), SLOT(conferenceChanged(int)));
     113        conferenceChanged(idx);
    117114    }
    118115    else
     
    155152        selectConference->setCurrentIndex(idx);
    156153
    157         if(confCount>1)
    158             selectConferenceWidget->show();
     154        selectConferenceWidget->show();
    159155
    160156        conferenceChanged(idx);
     
    169165        // should not happen
    170166        qWarning() << __PRETTY_FUNCTION__ << "removed non-existent item:" << title;
     167        // this happens when you remove the only conference (the list is not ptoperly inited in this case)
     168        // now make sure that conferencet
     169        if (selectConference->count() > 0) {
     170            selectConference->setCurrentIndex(0);
     171            conferenceChanged(0);
     172        } else {
     173            conferenceChanged(-1);
     174        }
    171175    } else {
    172176        // will it signal "changed"?
     
    238242}
    239243
     244void MainWindow::unsetConference()
     245{
     246    dayTabContainer->clearModel();
     247    tracksTabContainer->clearModel();
     248    roomsTabContainer->clearModel();
     249    favsTabContainer->clearModel();
     250    searchTabContainer->clearModel();
     251    searchTabContainer->searchAgainClicked();
     252    nowTabContainer->clearModel();
     253
     254    conferenceHeader->hide();
     255    setWindowTitle(saved_title);
     256}
     257
    240258void MainWindow::conferenceChanged(int aIndex)
    241259{
    242     Conference::getById(Conference::activeConference()).update("active",0);
    243     Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
     260    if (aIndex < 0) {
     261        // no conferences left? reset all views
     262        unsetConference();
     263        return;
     264    }
     265
     266    try {
     267        Conference::getById(Conference::activeConference()).update("active",0);
     268        Conference::getById(selectConference->itemData(aIndex).toInt()).update("active",1);
     269    } catch (OrmException& e) {
     270        // cannon set an active conference
     271        unsetConference();
     272        return;
     273    }
    244274
    245275    initTabs();
  • src/gui/mainwindow.h

    rd97bcab r04acaf9  
    4343    void fillAndShowConferenceHeader();
    4444    void initTabs();
     45    void unsetConference();
     46
     47    QString saved_title;
    4548};
    4649
  • src/gui/tabcontainer.cpp

    rd97bcab r04acaf9  
    5656void TabContainer::updateTreeView(const QDate &aDate)
    5757{
     58    int active_id = Conference::activeConference();
    5859    dayNavigator->show();
    59     loadEvents( aDate, Conference::activeConference() );
    60     treeView->reset();
     60    if (active_id > 0) {
     61        loadEvents(aDate, active_id);
     62    } else {
     63        static_cast<EventModel*>(treeView->model())->clearModel();
     64    }
    6165}
    6266
     
    133137}
    134138
     139void TabContainer::clearModel()
     140{
     141    static_cast<EventModel*>(treeView->model())->clearModel();
     142}
     143
  • src/gui/tabcontainer.h

    rd97bcab r04acaf9  
    3636    virtual ~TabContainer() {}
    3737
     38    void clearModel();
    3839protected:
    3940    virtual void loadEvents( const QDate &aDate, const int aConferenceId )
  • src/mvc/eventmodel.cpp

    rd97bcab r04acaf9  
    2525
    2626EventModel::EventModel()
    27 {
    28     mEvents.clear();
    29 }
     27{ }
    3028
    3129void EventModel::createTimeGroups()
     
    6361
    6462    mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
     63
     64    reset();
    6565}
    6666
     
    200200void EventModel::clearModel()
    201201{
    202     for(int i = 0;i < mGroups.count();i++){
    203         QModelIndex idx = index(i, 0);
    204         Group group = mGroups[i];
    205         beginRemoveRows(idx, 0, group.mChildCount - 1);
    206         /*bool ok =*/ removeRows(0, group.mChildCount, idx);
    207         endRemoveRows();
    208         //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
    209     }
     202    qDebug() << __PRETTY_FUNCTION__ << this << mEvents.count();
     203    mGroups.clear();
    210204    mEvents.clear();
     205    mParents.clear();
     206
     207    reset();
    211208}
    212209
  • src/mvc/eventmodel.h

    rd97bcab r04acaf9  
    4242    void loadEventsByRoom(const QDate &aDate, int aConferenceId);
    4343    void loadConflictEvents(int aEventId, int aConferenceId); // loads events in conflict
     44    void clearModel();
    4445
    4546private:
     
    6364    void createTrackGroups();
    6465    void createTrackGroupsNew();
    65     void clearModel();
    6666    void createRoomGroups();
    6767
Note: See TracChangeset for help on using the changeset viewer.