Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:11.4
kdebase4-wallpapers
bnc661844-akonadi-launched-by-calendarwidget.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bnc661844-akonadi-launched-by-calendarwidget.diff of Package kdebase4-wallpapers
Subject: prevent calendarapplet from launching Akonadi by default Patch-upstream: yes From: wstephenson@suse.de Index: kdebase-workspace-4.6.0/libs/plasmaclock/calendar.cpp =================================================================== --- kdebase-workspace-4.6.0.orig/libs/plasmaclock/calendar.cpp +++ kdebase-workspace-4.6.0/libs/plasmaclock/calendar.cpp @@ -243,16 +243,6 @@ const QDate& Calendar::date() const return calendarTable()->date(); } -void Calendar::setDataEngine(Plasma::DataEngine *dataEngine) -{ - calendarTable()->setDataEngine(dataEngine); -} - -const Plasma::DataEngine *Calendar::dataEngine() const -{ - return calendarTable()->dataEngine(); -} - void Calendar::setDisplayHolidays(bool showHolidays) { calendarTable()->setDisplayHolidays(showHolidays); Index: kdebase-workspace-4.6.0/libs/plasmaclock/calendar.h =================================================================== --- kdebase-workspace-4.6.0.orig/libs/plasmaclock/calendar.h +++ kdebase-workspace-4.6.0/libs/plasmaclock/calendar.h @@ -57,9 +57,6 @@ public: void setDate(const QDate &date); const QDate& date() const; - void setDataEngine(Plasma::DataEngine *dataEngine); - const Plasma::DataEngine *dataEngine() const; - void setDisplayHolidays(bool showHolidays); bool displayHolidays(); Index: kdebase-workspace-4.6.0/libs/plasmaclock/calendartable.cpp =================================================================== --- kdebase-workspace-4.6.0.orig/libs/plasmaclock/calendartable.cpp +++ kdebase-workspace-4.6.0/libs/plasmaclock/calendartable.cpp @@ -24,6 +24,7 @@ //Qt #include <QtCore/QDate> #include <QtCore/QListIterator> +#include <QtCore/QTimer> #include <QtGui/QPainter> #include <QtGui/QWidget> #include <QtGui/QGraphicsSceneWheelEvent> @@ -40,6 +41,7 @@ #include <Plasma/Svg> #include <Plasma/Theme> #include <Plasma/DataEngine> +#include <Plasma/DataEngineManager> #ifdef HAVE_KDEPIMLIBS #include "ui_calendarHolidaysConfig.h" @@ -76,32 +78,44 @@ public: class CalendarTablePrivate { public: + enum Populations { NoPendingPopulation = 0, PopulateHolidays = 1, PopulateEvents = 2 }; CalendarTablePrivate(CalendarTable *calTable, const QDate &initialDate = QDate::currentDate()) : q(calTable), calendarType("locale"), calendar(KGlobal::locale()->calendar()), - displayEvents(true), - displayHolidays(true), - dataEngine(0), + displayEvents(false), + displayHolidays(false), + calendarDataEngine(0), automaticUpdates(true), - opacity(0.5) + opacity(0.5), + pendingPopulations(NoPendingPopulation), + delayedPopulationTimer(new QTimer()) { svg = new Svg(); svg->setImagePath("widgets/calendar"); svg->setContainsMultipleImages(true); + delayedPopulationTimer->setInterval(0); + delayedPopulationTimer->setSingleShot(true); + QObject::connect(delayedPopulationTimer, SIGNAL(timeout()), q, SLOT(populateCalendar())); + setDate(initialDate); } ~CalendarTablePrivate() { // Delete the old calendar first if it's not the global calendar - if ( calendar != KGlobal::locale()->calendar() ) { + if (calendar != KGlobal::locale()->calendar()) { delete calendar; } + if (calendarDataEngine) { + Plasma::DataEngineManager::self()->unloadEngine("calendar"); + } + delete svg; + delete delayedPopulationTimer; } void setCalendar(const KCalendarSystem *newCalendar) @@ -122,8 +136,8 @@ class CalendarTablePrivate // Force date update to refresh cached date componants then update display setDate(selectedDate); updateHoveredPainting(QPointF()); - q->populateHolidays(); - q->populateEvents(); + populateHolidays(); + populateEvents(); q->update(); } @@ -289,43 +303,42 @@ class CalendarTablePrivate QString defaultHolidaysRegion() { - if (!dataEngine) { - return QString(); - } - - return dataEngine->query("holidaysDefaultRegion").value("holidaysDefaultRegion").toString(); + //FIXME: get rid of the query; turn it into a proper async request + return calendarEngine()->query("holidaysDefaultRegion").value("holidaysDefaultRegion").toString(); } bool isValidHolidaysRegion(const QString &holidayRegion) { - if (holidaysRegions.contains(holidayRegion)) { - return true; - } else { - QString queryString = "holidaysIsValidRegion" + QString(':') + holidayRegion; - return (dataEngine && dataEngine->query(queryString).value(queryString).toBool()); - } + //FIXME: get rid of the query; turn it into a proper async request + QString queryString = "holidaysIsValidRegion" + QString(':') + holidayRegion; + return calendarEngine()->query(queryString).value(queryString).toBool(); } - void addHolidaysRegion(const QString &holidayRegion, bool daysOff) + bool addHolidaysRegion(const QString &holidayRegion, bool daysOff) { - if (!holidaysRegions.contains(holidayRegion) && dataEngine) { - Plasma::DataEngine::Data regions; + kDebug() << "**********8ADDING" << holidayRegion << + holidaysRegions.contains(holidayRegion) << isValidHolidaysRegion(holidayRegion); + if (!holidaysRegions.contains(holidayRegion) && isValidHolidaysRegion(holidayRegion)) { QString queryString = "holidaysRegion" + QString(':') + holidayRegion; - regions = dataEngine->query(queryString); - Plasma::DataEngine::DataIterator i(regions); - while (i.hasNext()) { - i.next(); - Plasma::DataEngine::Data region = i.value().toHash(); + Plasma::DataEngine::Data regions = calendarEngine()->query(queryString); + Plasma::DataEngine::DataIterator it(regions); + while (it.hasNext()) { + it.next(); + Plasma::DataEngine::Data region = it.value().toHash(); region.insert("UseForDaysOff", daysOff); - holidaysRegions.insert(i.key(), region); + holidaysRegions.insert(it.key(), region); } + + return true; } + + return false; } bool holidayIsDayOff(Plasma::DataEngine::Data holidayData) { - return ( holidayData.value("ObservanceType").toString() == "PublicHoliday" && - holidaysRegions.value(holidayData.value("RegionCode").toString()).value("UseForDaysOff").toBool() ); + return (holidayData.value("ObservanceType").toString() == "PublicHoliday" && + holidaysRegions.value(holidayData.value("RegionCode").toString()).value("UseForDaysOff").toBool()); } @@ -343,6 +356,12 @@ class CalendarTablePrivate } } + Plasma::DataEngine *calendarEngine(); + void checkIfCalendarEngineNeeded(); + void populateHolidays(); + void populateEvents(); + void populateCalendar(); + CalendarTable *q; QString calendarType; const KCalendarSystem *calendar; @@ -360,7 +379,7 @@ class CalendarTablePrivate bool displayEvents; bool displayHolidays; - Plasma::DataEngine *dataEngine; + Plasma::DataEngine *calendarDataEngine; // List of Holiday Regions to display // Hash key: QString = Holiday Region Code, Data = details of Holiday Region QHash<QString, Plasma::DataEngine::Data> holidaysRegions; @@ -403,6 +422,9 @@ class CalendarTablePrivate int headerSpace; int weekBarSpace; int glowRadius; + + int pendingPopulations; + QTimer *delayedPopulationTimer; }; CalendarTable::CalendarTable(const QDate &date, QGraphicsWidget *parent) @@ -482,9 +504,8 @@ void CalendarTable::setDate(const QDate update(); //FIXME: we shouldn't need this update here, but something in Qt is broken (but with plasmoidviewer everything work) if (oldYear != d->selectedYear || oldMonth != d->selectedMonth) { - populateHolidays(); - populateEvents(); - update(); + d->populateHolidays(); + d->populateEvents(); } else { // only update the old and the new areas int row, column; @@ -506,48 +527,34 @@ const QDate& CalendarTable::date() const return d->selectedDate; } -void CalendarTable::setDataEngine(Plasma::DataEngine *dataEngine) -{ - if (d->dataEngine != dataEngine) { - d->dataEngine = dataEngine; - populateHolidays(); - populateEvents(); - } -} - -const Plasma::DataEngine *CalendarTable::dataEngine() const -{ - return d->dataEngine; -} - void CalendarTable::setDisplayHolidays(bool showHolidays) { if (showHolidays) { - if (!d->dataEngine) { - clearHolidays(); - return; - } - if (d->holidaysRegions.isEmpty()) { - addHolidaysRegion(d->defaultHolidaysRegion(), true); + d->addHolidaysRegion(d->defaultHolidaysRegion(), true); } - foreach ( const QString &holidayRegion, holidaysRegions() ) { - if (!d->isValidHolidaysRegion(holidayRegion)) { - return; + QMutableHashIterator<QString, Plasma::DataEngine::Data> it(d->holidaysRegions); + while (it.hasNext()) { + it.next(); + if (!d->isValidHolidaysRegion(it.key())) { + it.remove(); } } + } else { + clearHolidays(); + d->checkIfCalendarEngineNeeded(); } if (d->displayHolidays != showHolidays) { d->displayHolidays = showHolidays; - populateHolidays(); + d->populateHolidays(); } } bool CalendarTable::displayHolidays() { - return d->displayHolidays && !holidaysRegions().isEmpty(); + return d->displayHolidays && !d->holidaysRegions.isEmpty(); } bool CalendarTable::displayEvents() @@ -563,36 +570,35 @@ void CalendarTable::setDisplayEvents(boo d->displayEvents = display; if (display) { - populateEvents(); + d->populateEvents(); } else { - if (d->dataEngine) { - d->dataEngine->disconnectSource(d->eventsQuery, this); + if (d->calendarDataEngine) { + d->calendarDataEngine->disconnectSource(d->eventsQuery, this); } d->events.clear(); d->todos.clear(); d->journals.clear(); d->pimEvents.clear(); + d->checkIfCalendarEngineNeeded(); } } void CalendarTable::clearHolidaysRegions() { - clearHolidays(); d->holidaysRegions.clear(); - populateHolidays(); + clearHolidays(); } void CalendarTable::addHolidaysRegion(const QString ®ion, bool daysOff) { - if (d->isValidHolidaysRegion(region)) { - d->addHolidaysRegion(region, daysOff); - populateHolidays(); + if (d->displayHolidays && d->addHolidaysRegion(region, daysOff)) { + d->populateHolidays(); } } QStringList CalendarTable::holidaysRegions() const { - return QStringList(d->holidaysRegions.keys()); + return d->holidaysRegions.keys(); } QStringList CalendarTable::holidaysRegionsDaysOff() const @@ -612,6 +618,7 @@ void CalendarTable::clearHolidays() { d->holidayEvents.clear(); d->holidays.clear(); + update(); } void CalendarTable::addHoliday(Plasma::DataEngine::Data holidayData) @@ -741,42 +748,84 @@ const QDate& CalendarTable::currentDate( return d->currentDate; } -void CalendarTable::populateHolidays() +Plasma::DataEngine *CalendarTablePrivate::calendarEngine() { - clearHolidays(); - - if (!displayHolidays() || !d->dataEngine || holidaysRegions().isEmpty()) { - return; + if (!calendarDataEngine) { + calendarDataEngine = Plasma::DataEngineManager::self()->loadEngine("calendar"); } - // Just fetch the days displayed in the grid - QString queryString = "holidays" + QString(':') + holidaysRegions().join(QString(',')) - + QString(':') + d->viewStartDate.toString(Qt::ISODate) - + QString(':') + d->viewEndDate.toString(Qt::ISODate); - QList<QVariant> holidays = d->dataEngine->query(queryString).value(queryString).toList(); + return calendarDataEngine; +} - QMutableListIterator<QVariant> i(holidays); - while (i.hasNext()) { - addHoliday(i.next().toHash()); +void CalendarTablePrivate::checkIfCalendarEngineNeeded() +{ + if (calendarDataEngine && !displayHolidays && !displayEvents) { + calendarDataEngine = Plasma::DataEngineManager::self()->loadEngine("calendar"); } } -void CalendarTable::populateEvents() +void CalendarTablePrivate::populateHolidays() { - d->events.clear(); - d->todos.clear(); - d->journals.clear(); - d->pimEvents.clear(); + kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; + pendingPopulations |= PopulateHolidays; + delayedPopulationTimer->start(); +} - if (!d->displayEvents || !d->dataEngine) { - return; +void CalendarTablePrivate::populateCalendar() +{ + kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << pendingPopulations; + if (pendingPopulations & PopulateHolidays) { + holidayEvents.clear(); + holidays.clear(); + + if (q->displayHolidays()) { + // Just fetch the days displayed in the grid + //FIXME: queries are bad, use an async method + QString queryString = "holidays" + QString(':') + + q->holidaysRegions().join(QString(',')) + + QString(':') + viewStartDate.toString(Qt::ISODate) + + QString(':') + viewEndDate.toString(Qt::ISODate); + QList<QVariant> holidays = calendarEngine()->query(queryString).value(queryString).toList(); + + QMutableListIterator<QVariant> i(holidays); + while (i.hasNext()) { + q->addHoliday(i.next().toHash()); + } + } + + q->update(); + kDebug() << "repainting due to holiday population"; } - // Just fetch the days displayed in the grid - d->dataEngine->disconnectSource(d->eventsQuery, this); - d->eventsQuery = "events" + QString(':') + d->viewStartDate.toString(Qt::ISODate) - + QString(':') + d->viewEndDate.toString(Qt::ISODate); - d->dataEngine->connectSource(d->eventsQuery, this); + if (pendingPopulations & PopulateEvents) { + events.clear(); + todos.clear(); + journals.clear(); + pimEvents.clear(); + + if (calendarDataEngine && !eventsQuery.isEmpty()) { + calendarDataEngine->disconnectSource(eventsQuery, q); + } + + if (displayEvents) { + // Just fetch the days displayed in the grid + eventsQuery = "events" + QString(':') + viewStartDate.toString(Qt::ISODate) + + QString(':') + viewEndDate.toString(Qt::ISODate); + calendarEngine()->connectSource(eventsQuery, q); + } else { + eventsQuery.clear(); + } + + q->update(); + } + + pendingPopulations = NoPendingPopulation; +} + +void CalendarTablePrivate::populateEvents() +{ + pendingPopulations |= PopulateHolidays; + delayedPopulationTimer->start(); } void CalendarTable::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data) @@ -815,14 +864,22 @@ void CalendarTable::dataUpdated(const QS void CalendarTable::applyConfiguration(KConfigGroup cg) { setCalendar(cg.readEntry("calendarType", "locale")); - QStringList regions = cg.readEntry("holidaysRegions", QStringList(d->defaultHolidaysRegion())); - QStringList daysOff = cg.readEntry("holidaysRegionsDaysOff", QStringList(d->defaultHolidaysRegion())); + const bool holidays = cg.readEntry("displayHolidays", true); clearHolidaysRegions(); - foreach(const QString & region, regions) { - addHolidaysRegion(region, daysOff.contains(region)); + if (holidays) { + QStringList regions = cg.readEntry("holidaysRegions", QStringList(d->defaultHolidaysRegion())); + QStringList daysOff = cg.readEntry("holidaysRegionsDaysOff", QStringList(d->defaultHolidaysRegion())); + clearHolidaysRegions(); + foreach (const QString ®ion, regions) { + d->addHolidaysRegion(region, daysOff.contains(region)); + } + + kDebug() << "applied" << regions << "and now we populate the holidays!!!!!!!!!"; + d->populateHolidays(); } - setDisplayHolidays(cg.readEntry("displayHolidays", true)); - setDisplayEvents(cg.readEntry("displayEvents", true)); + setDisplayHolidays(holidays); + + setDisplayEvents(cg.readEntry("displayEvents", false)); } void CalendarTable::writeConfiguration(KConfigGroup cg) @@ -1031,7 +1088,7 @@ void CalendarTable::paint(QPainter *p, c QList<CalendarCellBorder> borders; QList<CalendarCellBorder> hovers; - if (d->automaticUpdates){ + if (d->automaticUpdates) { d->currentDate = QDate::currentDate(); } Index: kdebase-workspace-4.6.0/libs/plasmaclock/calendartable.h =================================================================== --- kdebase-workspace-4.6.0.orig/libs/plasmaclock/calendartable.h +++ kdebase-workspace-4.6.0/libs/plasmaclock/calendartable.h @@ -64,9 +64,6 @@ public: void setDate(const QDate &date); const QDate& date() const; - void setDataEngine(Plasma::DataEngine *dataEngine); - const Plasma::DataEngine *dataEngine() const; - void setDisplayEvents(bool display); bool displayEvents(); @@ -121,11 +118,10 @@ protected: virtual void paintBorder(QPainter *p, int cell, int week, int weekDay, CellTypes type, const QDate &cellDate); private: - void populateHolidays(); - void populateEvents(); - friend class CalendarTablePrivate; CalendarTablePrivate* const d; + + Q_PRIVATE_SLOT(d, void populateCalendar()) }; } Index: kdebase-workspace-4.6.0/libs/plasmaclock/clockapplet.cpp =================================================================== --- kdebase-workspace-4.6.0.orig/libs/plasmaclock/clockapplet.cpp +++ kdebase-workspace-4.6.0/libs/plasmaclock/clockapplet.cpp @@ -584,7 +584,6 @@ void ClockApplet::init() d->calendarWidget = new Plasma::Calendar(); d->calendarWidget->setAutomaticUpdateEnabled(false); d->calendarWidget->setMinimumSize(QSize(230, 220)); - d->calendarWidget->setDataEngine(dataEngine("calendar")); d->createCalendarExtender(); extender(); Index: kdebase-workspace-4.6.0/plasma/generic/applets/calendar/calendar.cpp =================================================================== --- kdebase-workspace-4.6.0.orig/plasma/generic/applets/calendar/calendar.cpp +++ kdebase-workspace-4.6.0/plasma/generic/applets/calendar/calendar.cpp @@ -50,9 +50,13 @@ void CalendarApplet::init() setPopupIcon("view-pim-calendar"); m_calendarWidget = new Plasma::Calendar(this); m_calendarWidget->setPreferredSize(220, 250); - m_calendarWidget->setDataEngine(dataEngine("calendar")); - m_calendarWidget->applyConfiguration(config()); updateDate(); + configChanged(); +} + +void CalendarApplet::configChanged() +{ + m_calendarWidget->applyConfiguration(config()); } QGraphicsWidget *CalendarApplet::graphicsWidget() Index: kdebase-workspace-4.6.0/plasma/generic/applets/calendar/calendar.h =================================================================== --- kdebase-workspace-4.6.0.orig/plasma/generic/applets/calendar/calendar.h +++ kdebase-workspace-4.6.0/plasma/generic/applets/calendar/calendar.h @@ -46,6 +46,9 @@ class CalendarApplet : public Plasma::Po */ QGraphicsWidget *graphicsWidget(); + public slots: + void configChanged(); + protected: void createConfigurationInterface(KConfigDialog *parent);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor