Changeset c53a3f4


Ignore:
Timestamp:
01/19/10 18:34:18 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
395d6d3
Parents:
02c1e09
Message:

single-click is used to open event dialog

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    r02c1e09 rc53a3f4  
    1717#include "daynavigatorwidget.h"
    1818#include "mapwindow.h"
     19
     20const int confId = 1;
    1921
    2022MainWindow::MainWindow(QWidget *parent)
     
    6567    actTreeView->setItemDelegate(new Delegate(actTreeView));
    6668
    67     // event double clicked
    68     connect(dayTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
    69     connect(favTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
    70     connect(actTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
     69    // event clicked
     70    connect(dayTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     71    connect(favTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
     72    connect(actTreeView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemClicked(const QModelIndex &)));
    7173    // request for map to be displayed
    7274    connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     
    7880    if(Conference::getAll().count()) // no conference(s) in the DB
    7981    {
    80         int confId = 1;
    8182        static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
    8283        favTreeView->reset();
     
    9091    else
    9192    {
    92         int confId = 1;
    9393        QDate aStartDate = Conference::getById(confId).start();
    9494        QDate aEndDate = Conference::getById(confId).end();
     
    130130    if(Conference::getAll().count())
    131131    {
    132         int confId = 1;
    133132        // 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
    134133        QDate aStartDate = Conference::getById(confId).start();
     
    155154void MainWindow::updateDayView(const QDate &aDate)
    156155{
    157     int confId = 1;
    158156    static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,confId);
    159157    dayTreeView->reset();
     
    163161void MainWindow::updateTab(const int aIndex)
    164162{
    165     int confId = 1;
    166163    switch(aIndex)
    167164    {
     
    192189        }
    193190    };
    194 
    195 
    196191}
    197192
    198193void MainWindow::updateActivitiesDayView(const QDate &aDate)
    199194{
    200     int confId = 1;
    201195    static_cast<EventModel*>(actTreeView->model())->loadEventsByActivities(aDate,confId);
    202196    actTreeView->reset();
     
    206200void MainWindow::updateFavouritesDayView(const QDate &aDate)
    207201{
    208     int confId = 1;
    209202    static_cast<EventModel*>(favTreeView->model())->loadFavEvents(aDate,confId);
    210203    favTreeView->reset();
     
    212205}
    213206
    214 void MainWindow::itemDoubleClicked(const QModelIndex &aIndex)
     207void MainWindow::itemClicked(const QModelIndex &aIndex)
    215208{
    216209    // have to handle only events, not time-groups
  • src/gui/mainwindow.h

    r02c1e09 rc53a3f4  
    2323    void updateActivitiesDayView(const QDate &aDate);
    2424    void updateFavouritesDayView(const QDate &aDate);
    25     void itemDoubleClicked(const QModelIndex &aIndex);
     25    void itemClicked(const QModelIndex &aIndex);
    2626    void displayMap(const QModelIndex &aIndex);
    2727private:
  • src/mvc/treeview.cpp

    r02c1e09 rc53a3f4  
    2222    QPoint point = aEvent->pos();
    2323
    24     testForControlClicked(index,point);
    25 
    26     // pass the event to the Base class, so item clicks/events are handled correctly
    27     QTreeView::mouseReleaseEvent(aEvent);
     24    // test whether we have handled the mouse event
     25    if(!testForControlClicked(index,point))
     26    {
     27        // pass the event to the Base class, so item clicks/events are handled correctly
     28        QTreeView::mouseReleaseEvent(aEvent);
     29    }
    2830}
    2931
    30 void TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint)
     32// returns bool if some Control was clicked
     33bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint)
    3134{
     35    bool handled = false;
     36
    3237    if(!aIndex.isValid())
    33         return;
     38        return handled;
    3439
    3540    QRect rect = visualRect(aIndex); // visual QRect of selected/clicked item in the list
     
    5661                // since the Favourite icon has changed, update TreeView accordingly
    5762                static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);
     63                handled = true;
    5864            }
    5965            break;
     
    8995                // since the Alarm icon has changed, update TreeView accordingly
    9096                static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);
    91 
     97                handled = true;
    9298            }
    9399            break;
     
    97103                qDebug() << "MAP CLICKED: " << qVariantValue<QString>(aIndex.data());
    98104                emit(requestForMap(aIndex));
     105                handled = true;
    99106            }
    100107        break;
     
    103110            {
    104111                // item was clicked, but not a control
     112                handled = false;
    105113            }
    106114    };
     115
     116    return handled;
    107117}
    108118
  • src/mvc/treeview.h

    r02c1e09 rc53a3f4  
    1212private:
    1313    void mouseReleaseEvent(QMouseEvent *aEvent);
    14     void testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint);
     14    bool testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint);
    1515signals:
    1616    void requestForMap(const QModelIndex &aIndex);
Note: See TracChangeset for help on using the changeset viewer.