mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
libs: remove pim support leftovers
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1105573bb1
commit
a467c75b4b
4 changed files with 12 additions and 431 deletions
|
@ -284,21 +284,6 @@ const QDate& Calendar::date() const
|
||||||
return calendarTable()->date();
|
return calendarTable()->date();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calendar::clearHolidaysRegions()
|
|
||||||
{
|
|
||||||
calendarTable()->clearHolidaysRegions();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Calendar::addHolidaysRegion(const QString ®ion, bool daysOff)
|
|
||||||
{
|
|
||||||
calendarTable()->addHolidaysRegion(region, daysOff);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Calendar::holidaysRegions() const
|
|
||||||
{
|
|
||||||
return calendarTable()->holidaysRegions();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Calendar::setAutomaticUpdateEnabled(bool automatic)
|
void Calendar::setAutomaticUpdateEnabled(bool automatic)
|
||||||
{
|
{
|
||||||
calendarTable()->setAutomaticUpdateEnabled(automatic);
|
calendarTable()->setAutomaticUpdateEnabled(automatic);
|
||||||
|
@ -335,12 +320,6 @@ void Calendar::configAccepted(KConfigGroup cg)
|
||||||
applyConfiguration(cg);
|
applyConfiguration(cg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calendar::resizeEvent(QGraphicsSceneResizeEvent * event)
|
|
||||||
{
|
|
||||||
// just forward the event. Not removed due to BC.
|
|
||||||
QGraphicsWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarPrivate::updateSize()
|
void CalendarPrivate::updateSize()
|
||||||
{
|
{
|
||||||
QSize minSize = QSize(200, 200);
|
QSize minSize = QSize(200, 200);
|
||||||
|
|
|
@ -56,10 +56,6 @@ public:
|
||||||
void setDate(const QDate &date);
|
void setDate(const QDate &date);
|
||||||
const QDate& date() const;
|
const QDate& date() const;
|
||||||
|
|
||||||
void clearHolidaysRegions();
|
|
||||||
void addHolidaysRegion(const QString ®ionCode, bool daysOff);
|
|
||||||
QStringList holidaysRegions() const;
|
|
||||||
|
|
||||||
bool isDisplayingDateDetails() const;
|
bool isDisplayingDateDetails() const;
|
||||||
|
|
||||||
void setAutomaticUpdateEnabled(bool automatic);
|
void setAutomaticUpdateEnabled(bool automatic);
|
||||||
|
@ -82,7 +78,6 @@ protected:
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
void focusInEvent(QFocusEvent * event);
|
void focusInEvent(QFocusEvent * event);
|
||||||
void focusOutEvent(QFocusEvent * event);
|
void focusOutEvent(QFocusEvent * event);
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent * event); // not removed due to BC
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void prevMonth();
|
void prevMonth();
|
||||||
|
|
|
@ -73,32 +73,19 @@ public:
|
||||||
class CalendarTablePrivate
|
class CalendarTablePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Populations { NoPendingPopulation = 0, PopulateHolidays = 1, PopulateEvents = 2 };
|
|
||||||
|
|
||||||
CalendarTablePrivate(CalendarTable *calTable, const QDate &initialDate = QDate::currentDate())
|
CalendarTablePrivate(CalendarTable *calTable, const QDate &initialDate = QDate::currentDate())
|
||||||
: q(calTable),
|
: q(calTable),
|
||||||
calendarType(-1),
|
calendarType(-1),
|
||||||
calendar(0),
|
calendar(0),
|
||||||
displayEvents(false),
|
|
||||||
displayHolidays(false),
|
|
||||||
calendarDataEngine(0),
|
|
||||||
automaticUpdates(true),
|
automaticUpdates(true),
|
||||||
opacity(0.5),
|
opacity(0.5),
|
||||||
hoverWeekRow(-1),
|
hoverWeekRow(-1),
|
||||||
hoverWeekdayColumn(-1),
|
hoverWeekdayColumn(-1)
|
||||||
pendingPopulations(NoPendingPopulation),
|
|
||||||
delayedPopulationTimer(new QTimer())
|
|
||||||
{
|
{
|
||||||
KGlobal::locale()->insertCatalog("libkholidays");
|
|
||||||
|
|
||||||
svg = new Svg();
|
svg = new Svg();
|
||||||
svg->setImagePath("widgets/calendar");
|
svg->setImagePath("widgets/calendar");
|
||||||
svg->setContainsMultipleImages(true);
|
svg->setContainsMultipleImages(true);
|
||||||
|
|
||||||
delayedPopulationTimer->setInterval(0);
|
|
||||||
delayedPopulationTimer->setSingleShot(true);
|
|
||||||
QObject::connect(delayedPopulationTimer, SIGNAL(timeout()), q, SLOT(populateCalendar()));
|
|
||||||
|
|
||||||
setDate(initialDate);
|
setDate(initialDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +96,7 @@ class CalendarTablePrivate
|
||||||
delete calendar;
|
delete calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calendarDataEngine) {
|
|
||||||
Plasma::DataEngineManager::self()->unloadEngine("calendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
delete svg;
|
delete svg;
|
||||||
delete delayedPopulationTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCalendar(const KCalendarSystem *newCalendar)
|
void setCalendar(const KCalendarSystem *newCalendar)
|
||||||
|
@ -137,8 +119,6 @@ class CalendarTablePrivate
|
||||||
// Force date update to refresh cached date componants then update display
|
// Force date update to refresh cached date componants then update display
|
||||||
setDate(selectedDate);
|
setDate(selectedDate);
|
||||||
updateHoveredPainting(QPointF());
|
updateHoveredPainting(QPointF());
|
||||||
populateHolidays();
|
|
||||||
populateEvents();
|
|
||||||
q->update();
|
q->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,65 +293,6 @@ class CalendarTablePrivate
|
||||||
return weekday;
|
return weekday;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString defaultHolidaysRegion()
|
|
||||||
{
|
|
||||||
//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)
|
|
||||||
{
|
|
||||||
//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();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool addHolidaysRegion(const QString &holidayRegion, bool daysOff)
|
|
||||||
{
|
|
||||||
//kDebug() << holidayRegion << holidaysRegions.contains(holidayRegion) << isValidHolidaysRegion(holidayRegion);
|
|
||||||
if (!holidaysRegions.contains(holidayRegion) && isValidHolidaysRegion(holidayRegion)) {
|
|
||||||
QString queryString = "holidaysRegion" + QString(':') + holidayRegion;
|
|
||||||
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(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());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void insertPimOccurence(const QString &type, const QDate &date, Plasma::DataEngine::Data occurrence)
|
|
||||||
{
|
|
||||||
if (date >= viewStartDate && date <= viewEndDate) {
|
|
||||||
int julian = date.toJulianDay();
|
|
||||||
if (type == "Event" && !events.contains(julian, occurrence)) {
|
|
||||||
events.insert(julian, occurrence);
|
|
||||||
} else if (type == "Todo" && !todos.contains(julian, occurrence)) {
|
|
||||||
todos.insert(julian, occurrence);
|
|
||||||
} else if (type == "Journal" && !journals.contains(julian, occurrence)) {
|
|
||||||
journals.insert(julian, occurrence);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::DataEngine *calendarEngine();
|
|
||||||
void checkIfCalendarEngineNeeded();
|
|
||||||
void populateHolidays();
|
|
||||||
void populateEvents();
|
|
||||||
void populateCalendar();
|
|
||||||
void settingsChanged(int category);
|
void settingsChanged(int category);
|
||||||
|
|
||||||
CalendarTable *q;
|
CalendarTable *q;
|
||||||
|
@ -389,28 +310,6 @@ class CalendarTablePrivate
|
||||||
QDate viewStartDate;
|
QDate viewStartDate;
|
||||||
QDate viewEndDate;
|
QDate viewEndDate;
|
||||||
|
|
||||||
bool displayEvents;
|
|
||||||
bool displayHolidays;
|
|
||||||
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;
|
|
||||||
// Index to Holidays that occur on a given date.
|
|
||||||
// Hash key: int = Julian Day number of holiday observance, int = key of holiday event
|
|
||||||
QMultiHash<int, int> holidays;
|
|
||||||
// Holiday details. A holiday may be observed on multiple dates.
|
|
||||||
// Hash key: int = key of holiday event, Data = details of holiday
|
|
||||||
QHash<int, Plasma::DataEngine::Data> holidayEvents;
|
|
||||||
// Index to Events/Todos/Journals that occur on a given date.
|
|
||||||
// Hash key: int = Julian Day number of event/todo occurrence, Data = occurence details including start date, end date and Akonadi incidence UID
|
|
||||||
QMultiHash<int, Plasma::DataEngine::Data> events;
|
|
||||||
QMultiHash<int, Plasma::DataEngine::Data> todos;
|
|
||||||
QMultiHash<int, Plasma::DataEngine::Data> journals;
|
|
||||||
// Event/Todo/Journal details. An event may recur on multiple dates.
|
|
||||||
// Hash key: QString = Akonadi UID of event/todo/journal, Data = details of event/todo/journal
|
|
||||||
QHash<QString, Plasma::DataEngine::Data> pimEvents;
|
|
||||||
QString eventsQuery;
|
|
||||||
|
|
||||||
bool automaticUpdates;
|
bool automaticUpdates;
|
||||||
|
|
||||||
QPointF lastSeenMousePos;
|
QPointF lastSeenMousePos;
|
||||||
|
@ -434,9 +333,6 @@ class CalendarTablePrivate
|
||||||
QFont weekDayFont;
|
QFont weekDayFont;
|
||||||
QFont dateFontBold;
|
QFont dateFontBold;
|
||||||
QFont dateFont;
|
QFont dateFont;
|
||||||
|
|
||||||
int pendingPopulations;
|
|
||||||
QTimer *delayedPopulationTimer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CalendarTable::CalendarTable(const QDate &date, QGraphicsWidget *parent)
|
CalendarTable::CalendarTable(const QDate &date, QGraphicsWidget *parent)
|
||||||
|
@ -519,10 +415,7 @@ void CalendarTable::setDate(const QDate &newDate)
|
||||||
d->updateHoveredPainting(d->lastSeenMousePos);
|
d->updateHoveredPainting(d->lastSeenMousePos);
|
||||||
update(); //FIXME: we shouldn't need this update here, but something in Qt is broken (but with plasmoidviewer everything work)
|
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) {
|
if (oldYear == d->selectedYear && oldMonth == d->selectedMonth) {
|
||||||
d->populateHolidays();
|
|
||||||
d->populateEvents();
|
|
||||||
} else {
|
|
||||||
// only update the old and the new areas
|
// only update the old and the new areas
|
||||||
int row, column;
|
int row, column;
|
||||||
d->rowColumnFromDate(oldDate, row, column);
|
d->rowColumnFromDate(oldDate, row, column);
|
||||||
|
@ -543,132 +436,6 @@ const QDate& CalendarTable::date() const
|
||||||
return d->selectedDate;
|
return d->selectedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarTable::setDisplayHolidays(bool showHolidays)
|
|
||||||
{
|
|
||||||
if (showHolidays) {
|
|
||||||
if (d->holidaysRegions.isEmpty()) {
|
|
||||||
d->addHolidaysRegion(d->defaultHolidaysRegion(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
d->populateHolidays();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CalendarTable::displayHolidays()
|
|
||||||
{
|
|
||||||
return d->displayHolidays && !d->holidaysRegions.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CalendarTable::displayEvents()
|
|
||||||
{
|
|
||||||
return d->displayEvents;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTable::setDisplayEvents(bool display)
|
|
||||||
{
|
|
||||||
if (d->displayEvents == display) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->displayEvents = display;
|
|
||||||
if (display) {
|
|
||||||
d->populateEvents();
|
|
||||||
} else {
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
d->holidaysRegions.clear();
|
|
||||||
clearHolidays();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTable::addHolidaysRegion(const QString ®ion, bool daysOff)
|
|
||||||
{
|
|
||||||
if (d->displayHolidays && d->addHolidaysRegion(region, daysOff)) {
|
|
||||||
d->populateHolidays();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList CalendarTable::holidaysRegions() const
|
|
||||||
{
|
|
||||||
return d->holidaysRegions.keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList CalendarTable::holidaysRegionsDaysOff() const
|
|
||||||
{
|
|
||||||
QStringList regions;
|
|
||||||
QHashIterator<QString, Plasma::DataEngine::Data> it(d->holidaysRegions);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
if (it.value().value("UseForDaysOff").toBool()) {
|
|
||||||
regions.append(it.key());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return regions;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTable::clearHolidays()
|
|
||||||
{
|
|
||||||
d->holidayEvents.clear();
|
|
||||||
d->holidays.clear();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTable::addHoliday(Plasma::DataEngine::Data holidayData)
|
|
||||||
{
|
|
||||||
QDate holidayStartDate = QDate::fromString(holidayData.value("ObservanceStartDate").toString(), Qt::ISODate);
|
|
||||||
int holidayDuration = holidayData.value("ObservanceDuration").toInt();
|
|
||||||
int uid = d->holidayEvents.count();
|
|
||||||
d->holidayEvents.insert(uid, holidayData);
|
|
||||||
for (int i = 0; i < holidayDuration; ++i) {
|
|
||||||
d->holidays.insertMulti(holidayStartDate.addDays(i).toJulianDay(), uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CalendarTable::buildOccurrenceDescription(const Plasma::DataEngine::Data &occurrence) const
|
|
||||||
{
|
|
||||||
const QString uid = occurrence.value("OccurrenceUid").toString();
|
|
||||||
const KDateTime occStartDate = occurrence.value("OccurrenceStartDate").value<KDateTime>();
|
|
||||||
const KDateTime occEndDate = occurrence.value("OccurrenceEndDate").value<KDateTime>();
|
|
||||||
const Plasma::DataEngine::Data details = d->pimEvents.value(uid);
|
|
||||||
|
|
||||||
if (details.value("AllDay").toBool()) {
|
|
||||||
return i18nc("All-day calendar event summary", "<br>%1", details.value("Summary").toString());
|
|
||||||
} else if (!occEndDate.isValid() || occStartDate == occEndDate) {
|
|
||||||
return i18nc("Time and summary for a calendarevent", "%1<br>%2",
|
|
||||||
KGlobal::locale()->formatTime(occStartDate.time()),
|
|
||||||
details.value("Summary").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return i18nc("Start and end time and summary for a calendar event", "%1 - %2<br>%3",
|
|
||||||
KGlobal::locale()->formatTime(occStartDate.time()),
|
|
||||||
KGlobal::locale()->formatTime(occEndDate.time()),
|
|
||||||
details.value("Summary").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTable::setAutomaticUpdateEnabled(bool enabled)
|
void CalendarTable::setAutomaticUpdateEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
d->automaticUpdates = enabled;
|
d->automaticUpdates = enabled;
|
||||||
|
@ -699,87 +466,6 @@ QDate CalendarTable::endDate() const
|
||||||
return d->viewEndDate;
|
return d->viewEndDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::DataEngine *CalendarTablePrivate::calendarEngine()
|
|
||||||
{
|
|
||||||
if (!calendarDataEngine) {
|
|
||||||
calendarDataEngine = Plasma::DataEngineManager::self()->loadEngine("calendar");
|
|
||||||
}
|
|
||||||
|
|
||||||
return calendarDataEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTablePrivate::checkIfCalendarEngineNeeded()
|
|
||||||
{
|
|
||||||
if (calendarDataEngine && !displayHolidays && !displayEvents) {
|
|
||||||
Plasma::DataEngineManager::self()->unloadEngine("calendar");
|
|
||||||
calendarDataEngine = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTablePrivate::populateHolidays()
|
|
||||||
{
|
|
||||||
pendingPopulations |= PopulateHolidays;
|
|
||||||
delayedPopulationTimer->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTablePrivate::populateCalendar()
|
|
||||||
{
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
//kDebug() << "connecting to .. " << eventsQuery;
|
|
||||||
calendarEngine()->connectSource(eventsQuery, q);
|
|
||||||
} else {
|
|
||||||
eventsQuery.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
q->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
pendingPopulations = NoPendingPopulation;
|
|
||||||
emit q->eventsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTablePrivate::populateEvents()
|
|
||||||
{
|
|
||||||
pendingPopulations |= PopulateEvents;
|
|
||||||
delayedPopulationTimer->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalendarTablePrivate::settingsChanged(int category)
|
void CalendarTablePrivate::settingsChanged(int category)
|
||||||
{
|
{
|
||||||
if (category != KGlobalSettings::SETTINGS_LOCALE) {
|
if (category != KGlobalSettings::SETTINGS_LOCALE) {
|
||||||
|
@ -793,35 +479,7 @@ void CalendarTablePrivate::settingsChanged(int category)
|
||||||
void CalendarTable::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
|
void CalendarTable::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(source)
|
Q_UNUSED(source)
|
||||||
d->events.clear();
|
Q_UNUSED(data)
|
||||||
d->todos.clear();
|
|
||||||
d->journals.clear();
|
|
||||||
d->pimEvents.clear();
|
|
||||||
|
|
||||||
foreach (const QVariant &v, data) {
|
|
||||||
Plasma::DataEngine::Data pimData = v.toHash();
|
|
||||||
QString type = pimData.value("Type").toString();
|
|
||||||
QString uid = pimData.value("UID").toString();
|
|
||||||
|
|
||||||
d->pimEvents.insert(uid, pimData);
|
|
||||||
|
|
||||||
QList<QVariant> occurrenceList = pimData.value("Occurrences").toList();
|
|
||||||
foreach (const QVariant &occurrence, occurrenceList) {
|
|
||||||
QDate occStartDate = occurrence.toHash().value("OccurrenceStartDate").value<KDateTime>().date();
|
|
||||||
if (pimData.value("EventMultiDay").toBool() == true) {
|
|
||||||
QDate occEndDate = occurrence.toHash().value("OccurrenceEndDate").value<KDateTime>().date();
|
|
||||||
QDate multiDate = occStartDate;
|
|
||||||
while (multiDate <= occEndDate) {
|
|
||||||
d->insertPimOccurence(type, multiDate, occurrence.toHash());
|
|
||||||
multiDate = multiDate.addDays(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
d->insertPimOccurence(type, occStartDate, occurrence.toHash());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit eventsChanged();
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,30 +520,11 @@ void CalendarTable::applyConfiguration(KConfigGroup cg)
|
||||||
}
|
}
|
||||||
|
|
||||||
setCalendar(cg.readEntry("calendarType", -1));
|
setCalendar(cg.readEntry("calendarType", -1));
|
||||||
const bool holidays = cg.readEntry("displayHolidays", true);
|
|
||||||
clearHolidaysRegions();
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
d->populateHolidays();
|
|
||||||
}
|
|
||||||
|
|
||||||
setDisplayHolidays(holidays);
|
|
||||||
setDisplayEvents(cg.readEntry("displayEvents", true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarTable::writeConfiguration(KConfigGroup cg)
|
void CalendarTable::writeConfiguration(KConfigGroup cg)
|
||||||
{
|
{
|
||||||
cg.writeEntry("calendarType", d->calendarType);
|
cg.writeEntry("calendarType", d->calendarType);
|
||||||
cg.writeEntry("holidaysRegions", holidaysRegions());
|
|
||||||
cg.writeEntry("holidaysRegionsDaysOff", holidaysRegionsDaysOff());
|
|
||||||
cg.writeEntry("displayHolidays", d->displayHolidays);
|
|
||||||
cg.writeEntry("displayEvents", d->displayEvents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalendarTable::createConfigurationInterface(KConfigDialog *parent)
|
void CalendarTable::createConfigurationInterface(KConfigDialog *parent)
|
||||||
|
@ -1043,7 +682,7 @@ void CalendarTable::paintCell(QPainter *p, int cell, int weekRow, int weekdayCol
|
||||||
}
|
}
|
||||||
|
|
||||||
p->setPen(numberColor);
|
p->setPen(numberColor);
|
||||||
p->setFont(type & Event ? d->dateFontBold : d->dateFont);
|
p->setFont(d->dateFont);
|
||||||
if (!(type & InvalidDate)) {
|
if (!(type & InvalidDate)) {
|
||||||
p->drawText(cellArea, Qt::AlignCenter, calendar()->formatDate(cellDate, KLocale::Day, KLocale::ShortNumber), &cellArea); //draw number
|
p->drawText(cellArea, Qt::AlignCenter, calendar()->formatDate(cellDate, KLocale::Day, KLocale::ShortNumber), &cellArea); //draw number
|
||||||
}
|
}
|
||||||
|
@ -1065,10 +704,6 @@ void CalendarTable::paintBorder(QPainter *p, int cell, int weekRow, int weekdayC
|
||||||
elementId = "today";
|
elementId = "today";
|
||||||
} else if (type & Selected) {
|
} else if (type & Selected) {
|
||||||
elementId = "selected";
|
elementId = "selected";
|
||||||
} else if (type & PublicHoliday) {
|
|
||||||
elementId = "red";
|
|
||||||
} else if (type & Holiday) {
|
|
||||||
elementId = "green";
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1131,18 +766,6 @@ void CalendarTable::paint(QPainter *p, const QStyleOptionGraphicsItem *option, Q
|
||||||
type |= CalendarTable::Selected;
|
type |= CalendarTable::Selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int holidayUid, d->holidays.values(julian)) {
|
|
||||||
if (d->holidayIsDayOff(d->holidayEvents.value(holidayUid))) {
|
|
||||||
type |= CalendarTable::PublicHoliday;
|
|
||||||
} else {
|
|
||||||
type |= CalendarTable::Holiday;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->events.contains(julian) || d->todos.contains(julian)) {
|
|
||||||
type |= CalendarTable::Event;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type != CalendarTable::NoType && type != CalendarTable::NotInCurrentMonth) {
|
if (type != CalendarTable::NoType && type != CalendarTable::NotInCurrentMonth) {
|
||||||
borders.append(CalendarCellBorder(cellDay, weekRow, weekdayColumn, type, cellDate));
|
borders.append(CalendarCellBorder(cellDay, weekRow, weekdayColumn, type, cellDate));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,15 +42,14 @@ class PLASMACLOCK_EXPORT CalendarTable : public QGraphicsWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum CellType { NoType = 0,
|
enum CellType {
|
||||||
Today = 1,
|
NoType = 0,
|
||||||
Selected = 2,
|
Today = 1,
|
||||||
Hovered = 4,
|
Selected = 2,
|
||||||
Holiday = 8,
|
Hovered = 4,
|
||||||
NotInCurrentMonth = 16,
|
NotInCurrentMonth = 8,
|
||||||
InvalidDate = 32,
|
InvalidDate = 16
|
||||||
Event = 64,
|
};
|
||||||
PublicHoliday = 128};
|
|
||||||
Q_DECLARE_FLAGS(CellTypes, CellType)
|
Q_DECLARE_FLAGS(CellTypes, CellType)
|
||||||
|
|
||||||
explicit CalendarTable(QGraphicsWidget *parent = 0);
|
explicit CalendarTable(QGraphicsWidget *parent = 0);
|
||||||
|
@ -64,17 +63,6 @@ public:
|
||||||
void setDate(const QDate &date);
|
void setDate(const QDate &date);
|
||||||
const QDate& date() const;
|
const QDate& date() const;
|
||||||
|
|
||||||
void setDisplayEvents(bool display);
|
|
||||||
bool displayEvents();
|
|
||||||
|
|
||||||
void setDisplayHolidays(bool showHolidays);
|
|
||||||
bool displayHolidays();
|
|
||||||
|
|
||||||
void clearHolidaysRegions();
|
|
||||||
void addHolidaysRegion(const QString ®ionCode, bool daysOff);
|
|
||||||
QStringList holidaysRegions() const;
|
|
||||||
QStringList holidaysRegionsDaysOff() const;
|
|
||||||
|
|
||||||
void clearHolidays();
|
void clearHolidays();
|
||||||
void addHoliday(Plasma::DataEngine::Data holidayData);
|
void addHoliday(Plasma::DataEngine::Data holidayData);
|
||||||
|
|
||||||
|
@ -98,7 +86,6 @@ Q_SIGNALS:
|
||||||
void dateSelected(const QDate &date);
|
void dateSelected(const QDate &date);
|
||||||
void dateHovered(const QDate &date);
|
void dateHovered(const QDate &date);
|
||||||
void tableClicked();
|
void tableClicked();
|
||||||
void eventsChanged();
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data);
|
void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data);
|
||||||
|
@ -119,12 +106,9 @@ protected:
|
||||||
virtual void paintBorder(QPainter *p, int cell, int week, int weekDay, CellTypes type, const QDate &cellDate);
|
virtual void paintBorder(QPainter *p, int cell, int week, int weekDay, CellTypes type, const QDate &cellDate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString buildOccurrenceDescription(const Plasma::DataEngine::Data &occurrence) const;
|
|
||||||
|
|
||||||
friend class CalendarTablePrivate;
|
friend class CalendarTablePrivate;
|
||||||
CalendarTablePrivate* const d;
|
CalendarTablePrivate* const d;
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void populateCalendar())
|
|
||||||
Q_PRIVATE_SLOT(d, void settingsChanged(int category))
|
Q_PRIVATE_SLOT(d, void settingsChanged(int category))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue