Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Remove friends
Browse files Browse the repository at this point in the history
  • Loading branch information
Petri M. Gerdt committed Mar 28, 2014
1 parent 69ccf52 commit 38f7ab9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/calendaragendamodel.cpp
Expand Up @@ -128,7 +128,7 @@ void NemoCalendarAgendaModel::doRefresh(mKCal::ExtendedCalendar::ExpandedInciden
{
// Filter out excluded notebooks
for (int ii = 0; ii < newEvents.count(); ++ii) {
if (!NemoCalendarEventCache::instance()->mNotebooks.contains(NemoCalendarDb::calendar()->notebook(newEvents.at(ii).second))) {
if (!NemoCalendarEventCache::instance()->notebooks().contains(NemoCalendarDb::calendar()->notebook(newEvents.at(ii).second))) {
newEvents.remove(ii);
--ii;
}
Expand Down
5 changes: 2 additions & 3 deletions src/calendaragendamodel.h
Expand Up @@ -67,6 +67,8 @@ class NemoCalendarAgendaModel : public QAbstractListModel, public QQmlParserStat

int count() const;

void doRefresh(mKCal::ExtendedCalendar::ExpandedIncidenceList, bool reset = false);

int rowCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const;

Expand All @@ -84,9 +86,6 @@ private slots:
void refresh();

private:
friend class NemoCalendarEventCache;
void doRefresh(mKCal::ExtendedCalendar::ExpandedIncidenceList, bool reset = false);

QDate mStartDate;
QDate mEndDate;
QList<NemoCalendarEventOccurrence *> mEvents;
Expand Down
2 changes: 1 addition & 1 deletion src/calendarapi.cpp
Expand Up @@ -80,7 +80,7 @@ QStringList NemoCalendarApi::excludedNotebooks() const
QStringList rv;

for (int ii = 0; ii < notebooks.count(); ++ii) {
if (!NemoCalendarEventCache::instance()->mNotebooks.contains(notebooks.at(ii)->uid()))
if (!NemoCalendarEventCache::instance()->notebooks().contains(notebooks.at(ii)->uid()))
rv.append(notebooks.at(ii)->uid());
}

Expand Down
10 changes: 5 additions & 5 deletions src/calendarevent.cpp
Expand Up @@ -44,18 +44,18 @@
NemoCalendarEvent::NemoCalendarEvent(QObject *parent)
: QObject(parent), mNewEvent(true), mEvent(KCalCore::Event::Ptr(new KCalCore::Event))
{
NemoCalendarEventCache::instance()->mEvents.insert(this);
NemoCalendarEventCache::instance()->addEvent(this);
}

NemoCalendarEvent::NemoCalendarEvent(const KCalCore::Event::Ptr &event, QObject *parent)
: QObject(parent), mNewEvent(false), mEvent(event)
{
NemoCalendarEventCache::instance()->mEvents.insert(this);
NemoCalendarEventCache::instance()->addEvent(this);
}

NemoCalendarEvent::~NemoCalendarEvent()
{
NemoCalendarEventCache::instance()->mEvents.remove(this);
NemoCalendarEventCache::instance()->removeEvent(this);
}

QString NemoCalendarEvent::displayLabel() const
Expand Down Expand Up @@ -550,12 +550,12 @@ NemoCalendarEventOccurrence::NemoCalendarEventOccurrence(const mKCal::ExtendedCa
QObject *parent)
: QObject(parent), mOccurrence(o), mEvent(0)
{
NemoCalendarEventCache::instance()->mEventOccurrences.insert(this);
NemoCalendarEventCache::instance()->addEventOccurrence(this);
}

NemoCalendarEventOccurrence::~NemoCalendarEventOccurrence()
{
NemoCalendarEventCache::instance()->mEventOccurrences.remove(this);
NemoCalendarEventCache::instance()->removeEventOccurrence(this);
}

QDateTime NemoCalendarEventOccurrence::startTime() const
Expand Down
2 changes: 0 additions & 2 deletions src/calendarevent.h
Expand Up @@ -156,8 +156,6 @@ class NemoCalendarEvent : public QObject
void locationChanged();

private:
friend class NemoCalendarEventCache;

bool mNewEvent:1;
KCalCore::Event::Ptr mEvent;
};
Expand Down
25 changes: 25 additions & 0 deletions src/calendareventcache.cpp
Expand Up @@ -153,6 +153,31 @@ void NemoCalendarEventCache::storageFinished(mKCal::ExtendedStorage *storage, bo
Q_UNUSED(info)
}

void NemoCalendarEventCache::addEvent(NemoCalendarEvent *event)
{
mEvents.insert(event);
}

void NemoCalendarEventCache::removeEvent(NemoCalendarEvent *event)
{
mEvents.remove(event);
}

void NemoCalendarEventCache::addEventOccurrence(NemoCalendarEventOccurrence *eventOccurrence)
{
mEventOccurrences.insert(eventOccurrence);
}

void NemoCalendarEventCache::removeEventOccurrence(NemoCalendarEventOccurrence *eventOccurrence)
{
mEventOccurrences.remove(eventOccurrence);
}

QSet<QString> NemoCalendarEventCache::notebooks() const
{
return mNotebooks;
}

QString NemoCalendarEventCache::notebookColor(const QString &notebook) const
{
return mNotebookColors.value(notebook, "black");
Expand Down
18 changes: 11 additions & 7 deletions src/calendareventcache.h
Expand Up @@ -59,25 +59,29 @@ class NemoCalendarEventCache : public QObject, public mKCal::ExtendedStorageObse
void storageProgress(mKCal::ExtendedStorage *storage, const QString &info);
void storageFinished(mKCal::ExtendedStorage *storage, bool error, const QString &info);

void addEvent(NemoCalendarEvent* event);
void removeEvent(NemoCalendarEvent* event);

void addEventOccurrence(NemoCalendarEventOccurrence* eventOccurrence);
void removeEventOccurrence(NemoCalendarEventOccurrence* eventOccurrence);

QSet<QString> notebooks() const;

QString notebookColor(const QString &) const;
void setNotebookColor(const QString &, const QString &);

static QList<NemoCalendarEvent *> events(const KCalCore::Event::Ptr &event);

void scheduleAgendaRefresh(NemoCalendarAgendaModel *);
void cancelAgendaRefresh(NemoCalendarAgendaModel *);

protected:
virtual bool event(QEvent *);

signals:
void modelReset();

private:
friend class NemoCalendarApi;
friend class NemoCalendarEvent;
friend class NemoCalendarAgendaModel;
friend class NemoCalendarEventOccurrence;

void scheduleAgendaRefresh(NemoCalendarAgendaModel *);
void cancelAgendaRefresh(NemoCalendarAgendaModel *);
void doAgendaRefresh();

QStringList mDefaultNotebookColors;
Expand Down

0 comments on commit 38f7ab9

Please sign in to comment.