Move unittestenv to correct location
[kdepim.git] / kalarm / birthdaymodel.h
blobf6dd3bbf58f7b8352ac1dea609003a13c3a1f991
1 /*
2 * birthdaymodel.h - model class for birthdays from address book
3 * Program: kalarm
4 * Copyright © 2009 by Tobias Koenig <tokoe@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef BIRTHDAYMODEL_H
22 #define BIRTHDAYMODEL_H
24 #include <Akonadi/Contact/ContactsTreeModel>
26 #include <QSortFilterProxyModel>
28 namespace Akonadi
30 class ChangeRecorder;
33 /**
34 * @short Provides the global model for all contacts
36 * This model provides the EntityTreeModel for all contacts.
37 * The model is accessable via the static instance() method.
39 class BirthdayModel : public Akonadi::ContactsTreeModel
41 Q_OBJECT
42 public:
43 enum { // data columns
44 NameColumn, DateColumn,
45 ColumnCount
48 /**
49 * Destroys the global contact model.
51 ~BirthdayModel();
53 /**
54 * Returns the global contact model instance.
56 static BirthdayModel* instance();
58 QVariant entityData(const Akonadi::Item&, int column, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
59 QVariant entityData(const Akonadi::Collection& collection, int column, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
60 { return Akonadi::ContactsTreeModel::entityData(collection, column, role); }
62 private:
63 explicit BirthdayModel(Akonadi::ChangeRecorder* recorder);
65 static BirthdayModel* mInstance;
69 class BirthdaySortModel : public QSortFilterProxyModel
71 Q_OBJECT
72 public:
73 explicit BirthdaySortModel(QObject* parent = Q_NULLPTR);
75 void setPrefixSuffix(const QString& prefix, const QString& suffix);
77 protected:
78 bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const Q_DECL_OVERRIDE;
80 private:
81 QStringList mContactsWithAlarm;
82 QString mPrefix;
83 QString mSuffix;
86 #endif
88 // vim: et sw=4: