Ignore:
Timestamp:
01/27/10 16:06:21 (12 years ago)
Author:
timkoma <timkoma@…>
Branches:
master, qt5
Children:
0bb39f5
Parents:
33b5c34
Message:

refactoring of the TABS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gui/tabcontainer.cpp

    r33b5c34 r07ae23a  
    55#include <QTimer>
    66
    7 #include <sqlengine.h>
    8 #include <appsettings.h>
    9 
    10 #include <conference.h>
    11 
    127#include <treeview.h>
    13 #include <eventmodel.h>
    148#include <delegate.h>
    159
     
    1913TabContainer::TabContainer(QWidget *aParent)
    2014    : QWidget(aParent)
    21     , mType(EContainerTypeNone)
    2215{
    2316    setupUi(this);
    24 
    25     searchAgainButton->hide();
    26     searchHead->hide();
    2717
    2818    treeView->setHeaderHidden(true);
     
    4030    connect(treeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    4131
    42     connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
    43     connect(searchAgainButton, SIGNAL(clicked()), SLOT(searchAgainClicked()));
    44 
    4532    if(!Conference::getAll().count()) // no conference(s) in the DB
    4633    {
     
    5542}
    5643
    57 void TabContainer::setType(TabContainer::Type aType)
    58 {
    59     mType = aType;
    60 
    61     if(aType == EContainerTypeNow)
    62     {
    63         QTimer *timer = new QTimer( this );
    64         connect( timer, SIGNAL(timeout()), SLOT(timerUpdateTreeView()) );
    65         timer->start( 30000); // 30 seconds timer
    66     }
    67     if(aType == EContainerTypeSearch)
    68     {
    69         searchHead->show();
    70     }
    71 }
    72 
    7344void TabContainer::updateTreeView(const QDate &aDate)
    7445{
    75     switch(mType)
    76     {
    77         case EContainerTypeDay:
    78             {
    79                 static_cast<EventModel*>(treeView->model())->loadEvents(aDate,AppSettings::confId());
    80             }
    81             break;
    82         case EContainerTypeFavs:
    83             {
    84                 static_cast<EventModel*>(treeView->model())->loadFavEvents(aDate,AppSettings::confId());
    85             }
    86             break;
    87         case EContainerTypeTracks:
    88             {
    89                 static_cast<EventModel*>(treeView->model())->loadEventsByTrack(aDate, AppSettings::confId());
    90             }
    91             break;
    92         case EContainerTypeRooms:
    93             {
    94                 static_cast<EventModel*>(treeView->model())->loadEventsByRoom(aDate, AppSettings::confId());
    95             }
    96             break;
    97         case EContainerTypeNow:
    98             {
    99                 static_cast<EventModel*>(treeView->model())->loadNowEvents(AppSettings::confId());
    100                 treeView->setAllExpanded(true);
    101             }
    102             break;
    103         case EContainerTypeSearch:
    104             {
    105                 treeView->reset();
    106                 int eventsCount = static_cast<EventModel*>(treeView->model())->loadSearchResultEvents(aDate,AppSettings::confId());
    107                 if( eventsCount ||
    108                         dayNavigator->getCurrentDate() != Conference::getById(AppSettings::confId()).start() ){
    109                     searchAgainButton->show();
    110                     dayNavigator->show();
    111                     treeView->show();
    112                     searchHead->hide();
    113                 }
    114                 else{
    115                     treeView->hide();
    116                     searchAgainButton->hide();
    117                     dayNavigator->hide();
    118                     searchHead->show();
    119                 }
    120             }
    121             break;
    122         case EContainerTypeNone:
    123         default:
    124             {
    125                 qDebug() << "Container type not specified";
    126             }
    127     }
     46    dayNavigator->show();
     47    loadEvents( aDate, AppSettings::confId() );
    12848    treeView->reset();
    129     dayNavigator->show();
    13049}
    13150
     
    17594void TabContainer::updateTreeViewModel(int aEventId)
    17695{
    177     switch(mType)
    178     {
    179         case EContainerTypeFavs:
    180             {
    181                 // requires special handling
    182                 // we need to reload favourites, because some favourite could be deleted
    183                 //static_cast<EventModel*>(favTreeView->model())->updateModel(aEventId);
    184                 QDate aStartDate = Conference::getById(AppSettings::confId()).start();
    185                 QDate aEndDate = Conference::getById(AppSettings::confId()).end();
    186                 dayNavigator->setDates(aStartDate, aEndDate);
    187                 updateTreeView( Conference::getById(AppSettings::confId()).start() );
    188             }
    189             break;
    190         case EContainerTypeDay:
    191         case EContainerTypeNone:
    192         default:
    193             {
    194                 static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
    195             }
    196     }
     96    static_cast<EventModel*>(treeView->model())->updateModel(aEventId);
    19797}
    19898
     
    202102}
    203103
    204 void TabContainer::timerUpdateTreeView()
    205 {
    206     if(mType == EContainerTypeNow)
    207     {
    208         updateTreeView(QDate());
    209     }
    210 }
    211104
    212 void TabContainer::searchClicked()
    213 {
    214     if(mType == EContainerTypeSearch)
    215     {
    216         QHash<QString,QString> columns;
    217105
    218         if( searchTitle->isChecked() )
    219             columns.insertMulti("EVENT", "title");
    220         if( searchAbstract->isChecked() )
    221             columns.insertMulti("EVENT", "abstract");
    222         if( searchTag->isChecked() )
    223             columns.insertMulti("EVENT", "tag");
    224         if( searchSpeaker->isChecked() )
    225             columns["PERSON"] = "name";
    226         if( searchRoom->isChecked() )
    227             columns["ROOM"] = "name";
    228 
    229         QString keyword = searchEdit->text().replace( QString("%"), QString("\\%") );
    230         qDebug() << "\nKeyword to search: " << keyword;
    231         SqlEngine::searchEvent( AppSettings::confId(), columns, keyword );
    232 
    233         QDate startDate = Conference::getById(AppSettings::confId()).start();
    234         QDate endDate = Conference::getById(AppSettings::confId()).end();
    235         dayNavigator->setDates(startDate, endDate);
    236         updateTreeView( Conference::getById(AppSettings::confId()).start() );
    237     }
    238 }
    239 
    240 void TabContainer::searchAgainClicked()
    241 {
    242     if(mType == EContainerTypeSearch)
    243     {
    244         searchHead->show();
    245         searchAgainButton->hide();
    246         dayNavigator->hide();
    247         treeView->hide();
    248     }
    249 }
    250 
Note: See TracChangeset for help on using the changeset viewer.