Ignore:
Timestamp:
01/16/10 16:31:15 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
c790268
Parents:
8860ff4
Message:

work on favourite

  • created 'favourite' column in EVENT table
  • modified 'ormrecord' for setting record's elements
  • favourities view not implemented
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/treeview.cpp

    r8860ff4 r680a4da  
    33#include "treeview.h"
    44#include "delegate.h"
     5#include "event.h"
    56
    67#include <QDebug>
     
    3132    switch(delegate->whichControlClicked(aIndex,aPoint))
    3233    {
    33         case Delegate::FavouriteControl:
     34        case Delegate::FavouriteControlOn:
     35        case Delegate::FavouriteControlOff:
    3436            {
    3537                // handle Favourite Control clicked
    36                 qDebug() << "FAVOURITE CLICKED: " << qVariantValue<QString>(aIndex.data());
     38                Event event = Event::getById(aIndex.data().toInt(),1);
     39                if(event.isFavourite())
     40                {
     41                    static_cast<Event*>(aIndex.internalPointer())->setFavourite(false); // list of events
     42                    event.setFavourite(false); // update DB
     43                }
     44                else
     45                {
     46                    static_cast<Event*>(aIndex.internalPointer())->setFavourite(true); // list of events
     47                    event.setFavourite(true);
     48                }
     49                qDebug() << " FAVOURITE [" << qVariantValue<QString>(aIndex.data()) << "] -> " << event.isFavourite();
     50                event.update("favourite");
     51                // TODO: since the Favourite icon has changed, update TreeView accordingly
     52                // not really working solution is the following
     53                // maybe the call to MainWindow->update() fix the problem ???
     54                QTreeView::update();
     55                update();
    3756            }
    3857            break;
    39         case Delegate::AlarmControl:
     58        case Delegate::AlarmControlOn:
     59        case Delegate::AlarmControlOff:
    4060            {
    4161                // handle Alarm Control clicked
Note: See TracChangeset for help on using the changeset viewer.