~ubuntu-branches/ubuntu/quantal/kdepim/quantal

« back to all changes in this revision

Viewing changes to kalarm/eventlistmodel.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 193.
  • Revision ID: package-import@ubuntu.com-20111215141751-bmhdpiwl23wd9w26
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "resources/alarmresource.h"
24
24
#include "resources/alarmresources.h"
25
25
#include "alarmcalendar.h"
26
 
#include "alarmtext.h"
27
26
#include "preferences.h"
28
27
#include "synchtimer.h"
29
28
#include "eventlistmodel.moc"
30
29
 
 
30
#include <kalarmcal/alarmtext.h>
 
31
 
31
32
#include <klocale.h>
32
33
#include <kiconloader.h>
33
34
#include <kdebug.h>
35
36
#include <QApplication>
36
37
#include <QPixmap>
37
38
 
38
 
 
39
39
/*=============================================================================
40
40
= Class: EventListModel
41
41
= Contains all active/archived alarms, or all alarm templates, unsorted.
56
56
{
57
57
    if (!mAlarmInstance)
58
58
    {
59
 
        mAlarmInstance = new EventListModel(KAlarm::CalEvent::ACTIVE | KAlarm::CalEvent::ARCHIVED);
60
 
        Preferences::connect(SIGNAL(archivedColourChanged(const QColor&)), mAlarmInstance, SLOT(slotUpdateArchivedColour(const QColor&)));
61
 
        Preferences::connect(SIGNAL(disabledColourChanged(const QColor&)), mAlarmInstance, SLOT(slotUpdateDisabledColour(const QColor&)));
62
 
        Preferences::connect(SIGNAL(holidaysChanged(const KHolidays::HolidayRegion&)), mAlarmInstance, SLOT(slotUpdateHolidays()));
63
 
        Preferences::connect(SIGNAL(workTimeChanged(const QTime&, const QTime&, const QBitArray&)), mAlarmInstance, SLOT(slotUpdateWorkingHours()));
 
59
        mAlarmInstance = new EventListModel(CalEvent::ACTIVE | CalEvent::ARCHIVED);
 
60
        Preferences::connect(SIGNAL(archivedColourChanged(QColor)), mAlarmInstance, SLOT(slotUpdateArchivedColour(QColor)));
 
61
        Preferences::connect(SIGNAL(disabledColourChanged(QColor)), mAlarmInstance, SLOT(slotUpdateDisabledColour(QColor)));
 
62
        Preferences::connect(SIGNAL(holidaysChanged(KHolidays::HolidayRegion)), mAlarmInstance, SLOT(slotUpdateHolidays()));
 
63
        Preferences::connect(SIGNAL(workTimeChanged(QTime,QTime,QBitArray)), mAlarmInstance, SLOT(slotUpdateWorkingHours()));
64
64
    }
65
65
    return mAlarmInstance;
66
66
}
68
68
EventListModel* EventListModel::templates()
69
69
{
70
70
    if (!mTemplateInstance)
71
 
        mTemplateInstance = new EventListModel(KAlarm::CalEvent::TEMPLATE);
 
71
        mTemplateInstance = new EventListModel(CalEvent::TEMPLATE);
72
72
    return mTemplateInstance;
73
73
}
74
74
 
80
80
        mTemplateInstance = 0;
81
81
}
82
82
 
83
 
EventListModel::EventListModel(KAlarm::CalEvent::Types status, QObject* parent)
 
83
EventListModel::EventListModel(CalEvent::Types status, QObject* parent)
84
84
    : QAbstractTableModel(parent),
85
85
      mStatus(status)
86
86
{
102
102
    }
103
103
    MinuteTimer::connect(this, SLOT(slotUpdateTimeTo()));
104
104
    AlarmResources* resources = AlarmResources::instance();
105
 
    connect(resources, SIGNAL(resourceStatusChanged(AlarmResource*, AlarmResources::Change)),
106
 
                       SLOT(slotResourceStatusChanged(AlarmResource*, AlarmResources::Change)));
107
 
    connect(resources, SIGNAL(resourceLoaded(AlarmResource*, bool)),
108
 
                       SLOT(slotResourceLoaded(AlarmResource*, bool)));
 
105
    connect(resources, SIGNAL(resourceStatusChanged(AlarmResource*,AlarmResources::Change)),
 
106
                       SLOT(slotResourceStatusChanged(AlarmResource*,AlarmResources::Change)));
 
107
    connect(resources, SIGNAL(resourceLoaded(AlarmResource*,bool)),
 
108
                       SLOT(slotResourceLoaded(AlarmResource*,bool)));
109
109
}
110
110
 
111
111
int EventListModel::rowCount(const QModelIndex& parent) const
201
201
            switch (role)
202
202
            {
203
203
                case Qt::BackgroundRole:
204
 
                    switch (event->actions())
 
204
                    switch (event->actionTypes())
205
205
                    {
206
206
                        case KAEvent::ACT_DISPLAY_COMMAND:
207
207
                        case KAEvent::ACT_DISPLAY:
217
217
                case Qt::ForegroundRole:
218
218
                    if (event->commandError() != KAEvent::CMD_NO_ERROR)
219
219
                    {
220
 
                        if (event->actions() == KAEvent::ACT_COMMAND)
 
220
                        if (event->actionTypes() == KAEvent::ACT_COMMAND)
221
221
                            return Qt::white;
222
222
                        QColor colour = Qt::red;
223
223
                        int r, g, b;
233
233
                    break;
234
234
                case SortRole:
235
235
                {
236
 
                    unsigned i = (event->actions() == KAEvent::ACT_DISPLAY)
 
236
                    unsigned i = (event->actionTypes() == KAEvent::ACT_DISPLAY)
237
237
                               ? event->bgColour().rgb() : 0;
238
238
                    return QString("%1").arg(i, 6, 10, QLatin1Char('0'));
239
239
                }
260
260
#endif
261
261
                    return QString();
262
262
                case ValueRole:
263
 
                    return static_cast<int>(event->action());
 
263
                    return static_cast<int>(event->actionSubType());
264
264
                case SortRole:
265
 
                    return QString("%1").arg(event->action(), 2, 10, QLatin1Char('0'));
 
265
                    return QString("%1").arg(event->actionSubType(), 2, 10, QLatin1Char('0'));
266
266
            }
267
267
            break;
268
268
        case TextColumn:
405
405
    int firstRow = -1;
406
406
    for (int row = 0, end = mEvents.count();  row < end;  ++row)
407
407
    {
408
 
        if (mEvents[row]->category() == KAlarm::CalEvent::ARCHIVED)
 
408
        if (mEvents[row]->category() == CalEvent::ARCHIVED)
409
409
        {
410
410
            // For efficiency, emit a single signal for each group
411
411
            // of consecutive archived alarms, rather than a separate
616
616
        for (int i = list.count();  --i >= 0;  )
617
617
        {
618
618
            if (mEvents.indexOf(list[i]) >= 0)
619
 
                list.removeAt(i);    // avoid creating duplicate entries
 
619
                list.remove(i);    // avoid creating duplicate entries
620
620
        }
621
621
        if (!list.isEmpty())
622
622
        {
656
656
        {
657
657
            beginRemoveRows(QModelIndex(), row + 1, lastRow);
658
658
            while (lastRow > row)
659
 
                mEvents.removeAt(lastRow--);
 
659
                mEvents.remove(lastRow--);
660
660
            endRemoveRows();
661
661
            lastRow = -1;
662
662
        }
665
665
    {
666
666
        beginRemoveRows(QModelIndex(), 0, lastRow);
667
667
        while (lastRow >= 0)
668
 
            mEvents.removeAt(lastRow--);
 
668
            mEvents.remove(lastRow--);
669
669
        endRemoveRows();
670
670
    }
671
671
    if (mHaveEvents  &&  mEvents.isEmpty())
759
759
    if (row < 0)
760
760
        return;
761
761
    beginRemoveRows(QModelIndex(), row, row);
762
 
    mEvents.removeAt(row);
 
762
    mEvents.remove(row);
763
763
    endRemoveRows();
764
764
    if (mHaveEvents  &&  mEvents.isEmpty())
765
765
        updateHaveEvents(false);
939
939
*/
940
940
QPixmap* EventListModel::eventIcon(const KAEvent* event) const
941
941
{
942
 
    switch (event->actions())
 
942
    switch (event->actionTypes())
943
943
    {
944
944
        case KAEvent::ACT_EMAIL:
945
945
            return mEmailIcon;
948
948
        case KAEvent::ACT_COMMAND:
949
949
            return mCommandIcon;
950
950
        case KAEvent::ACT_DISPLAY:
951
 
            if (event->action() == KAEvent::FILE)
 
951
            if (event->actionSubType() == KAEvent::FILE)
952
952
                return mFileIcon;
953
953
            // fall through to ACT_DISPLAY_COMMAND
954
954
        case KAEvent::ACT_DISPLAY_COMMAND: