Changeset 3f3e22d


Ignore:
Timestamp:
01/21/10 16:39:43 (12 years ago)
Author:
fortefr <fortefr@…>
Branches:
master, qt5
Children:
76cde75
Parents:
a957cfa
Message:

Warning handling

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/gui/mainwindow.cpp

    ra957cfa r3f3e22d  
    1313
    1414#include <QDialog>
     15#include <QMessageBox>
    1516#include "ui_about.h"
    1617#include "eventdialog.h"
     
    1819#include "importscheduledialog.h"
    1920#include "mapwindow.h"
     21
    2022
    2123const int confId = 1;
     
    8688    connect(trackTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
    8789    connect(searchTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
     90    // request for warning to be displayed
     91    connect(dayTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     92    connect(favTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     93    connect(trackTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
     94    connect(searchTreeView, SIGNAL(requestForWarning(const QModelIndex &)), SLOT(displayWarning(const QModelIndex &)));
    8895    // event search button clicked
    8996    connect(searchButton, SIGNAL(clicked()), SLOT(searchClicked()));
     
    274281}
    275282
     283void MainWindow::displayWarning(const QModelIndex &aIndex)
     284{
     285    QMessageBox::warning(
     286    this,
     287    tr("Time Conflict Warning"),
     288    tr("This event happens at the same time than another one of your favourites.") );
     289}
  • src/gui/mainwindow.h

    ra957cfa r3f3e22d  
    2626    void itemClicked(const QModelIndex &aIndex);
    2727    void displayMap(const QModelIndex &aIndex);
     28    void displayWarning(const QModelIndex &aIndex);
    2829    void searchClicked();
    2930private:
  • src/mvc/delegate.cpp

    ra957cfa r3f3e22d  
    136136        //if(static_cast<Event*>(index.internalPointer())->hasTimeConflict())
    137137        if(bkgrColor == Qt::yellow)
     138        {
    138139            painter->drawImage(mControls[WarningControlOn]->drawPoint(option.rect),*mControls[WarningControlOn]->image());
     140            mControls[WarningControlOn]->hasConflict=true;
     141        }
    139142        else
     143        {
    140144            painter->drawImage(mControls[WarningControlOff]->drawPoint(option.rect),*mControls[WarningControlOff]->image());
     145            mControls[WarningControlOn]->hasConflict=false;
     146        }
    141147
    142148        // draw texts
     
    310316    {
    311317        ControlId id = i.next();
    312         if(mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
     318        if((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
     319            && (id != WarningControlOn) && (id != WarningControlOff))
     320        {
    313321            return id;
     322        }
     323        else
     324        {
     325            if ((mControls[id]->drawRect(static_cast<QTreeView*>(parent())->visualRect(aIndex)).contains(aPoint))
     326            && (mControls[id]->hasConflict))
     327            {
     328            return id;
     329            }
     330        }
    314331    }
    315332
     
    369386    control = new Control(WarningControlOn,QString(":icons/exclamation-iconOn.png"));
    370387    p = mControls[MapControl]->drawPoint();
     388    control->hasConflict = false;
    371389    p.setX(p.x()-control->image()->width()-SPACER);
    372390    control->setDrawPoint(p);
     
    375393    control = new Control(WarningControlOff,QString(":icons/exclamation-iconOff.png"));
    376394    p = mControls[MapControl]->drawPoint();
     395    control->hasConflict = false;
    377396    p.setX(p.x()-control->image()->width()-SPACER);
    378397    control->setDrawPoint(p);
  • src/mvc/delegate.h

    ra957cfa r3f3e22d  
    4545                    return QRect(drawPoint(aRect), drawPoint(aRect)+QPoint(mImage->size().width(),mImage->size().height()));
    4646                }
     47                bool hasConflict;
    4748            private:
    4849                ControlId mId;
  • src/mvc/treeview.cpp

    ra957cfa r3f3e22d  
    107107            }
    108108        break;
     109        case Delegate::WarningControlOff:
    109110        case Delegate::WarningControlOn:
    110         case Delegate::WarningControlOff:
    111111        {
     112
     113            qDebug() << "WARNING CLICKED: " << qVariantValue<QString>(aIndex.data());
    112114            // TODO: implement
     115            emit(requestForWarning(aIndex));
    113116            handled = true;
    114117        }
  • src/mvc/treeview.h

    ra957cfa r3f3e22d  
    1717signals:
    1818    void requestForMap(const QModelIndex &aIndex);
     19    void requestForWarning(const QModelIndex &aIndex);
    1920};
    2021
Note: See TracChangeset for help on using the changeset viewer.