[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/frameworks] kalarm: Remove non-Akonadi files
From: David Jarvie <djarvie () kde ! org>
Date: 2014-04-30 23:46:58
Message-ID: E1WfeDK-0006Wp-Hf () scm ! kde ! org
[Download RAW message or body]
Git commit fe52177e25a95507ea6a44c1eb0f481c4934ad30 by David Jarvie.
Committed on 30/04/2014 at 23:47.
Pushed by djarvie into branch 'frameworks'.
Remove non-Akonadi files
M +25 -79 kalarm/CMakeLists.txt
D +0 -64 kalarm/alarmlistfiltermodel.cpp
D +0 -52 kalarm/alarmlistfiltermodel.h
D +0 -74 kalarm/calendarcompat.cpp
D +0 -41 kalarm/calendarcompat.h
D +0 -969 kalarm/eventlistmodel.cpp
D +0 -147 kalarm/eventlistmodel.h
D +0 -143 kalarm/resourceconfigdialog.cpp
D +0 -60 kalarm/resourceconfigdialog.h
D +0 -542 kalarm/resourcemodelview.cpp
D +0 -116 kalarm/resourcemodelview.h
D +0 -79 kalarm/resources/CMakeLists.txt
D +0 -444 kalarm/resources/alarmresource.cpp
D +0 -261 kalarm/resources/alarmresource.h
D +0 -828 kalarm/resources/alarmresources.cpp
D +0 -475 kalarm/resources/alarmresources.h
D +0 -60 kalarm/resources/kalarm_manager.desktop
D +0 -43 kalarm/resources/kalarm_resources_export.h
D +0 -104 kalarm/resources/local.desktop
D +0 -104 kalarm/resources/localdir.desktop
D +0 -104 kalarm/resources/remote.desktop
D +0 -272 kalarm/resources/resourcelocal.cpp
D +0 -90 kalarm/resources/resourcelocal.h
D +0 -40 kalarm/resources/resourcelocal_plugin.cpp
D +0 -494 kalarm/resources/resourcelocaldir.cpp
D +0 -104 kalarm/resources/resourcelocaldir.h
D +0 -40 kalarm/resources/resourcelocaldir_plugin.cpp
D +0 -78 kalarm/resources/resourcelocaldirwidget.cpp
D +0 -51 kalarm/resources/resourcelocaldirwidget.h
D +0 -83 kalarm/resources/resourcelocalwidget.cpp
D +0 -51 kalarm/resources/resourcelocalwidget.h
D +0 -368 kalarm/resources/resourceremote.cpp
D +0 -111 kalarm/resources/resourceremote.h
D +0 -41 kalarm/resources/resourceremote_plugin.cpp
D +0 -101 kalarm/resources/resourceremotewidget.cpp
D +0 -59 kalarm/resources/resourceremotewidget.h
D +0 -58 kalarm/resources/resourcewidget.cpp
D +0 -49 kalarm/resources/resourcewidget.h
D +0 -120 kalarm/templatelistfiltermodel.cpp
D +0 -59 kalarm/templatelistfiltermodel.h
http://commits.kde.org/kdepim/fe52177e25a95507ea6a44c1eb0f481c4934ad30
diff --git a/kalarm/CMakeLists.txt b/kalarm/CMakeLists.txt
index 9967a56..a7d193f 100644
--- a/kalarm/CMakeLists.txt
+++ b/kalarm/CMakeLists.txt
@@ -8,9 +8,6 @@ add_definitions( -DQT_NO_CAST_TO_ASCII )
set(CMAKE_AUTOMOC_RELAXED_MODE ON)
-option(KALARM_USE_AKONADI "Build to use Akonadi" ON)
-
-
add_definitions(-DUSE_AKONADI)
if (NOT CMAKE_VERSION VERSION_LESS 2.8.12 AND (CMAKE_VERSION VERSION_LESS \
2.8.12.1
OR CMAKE_VERSION VERSION_LESS 2.8.13 # Temporary measure because \
build.kde.org uses a datestamped CMake version @@ -21,7 +18,6 @@ \
option(KALARM_USE_AKONADI "Build to use Akonadi" ON) kde_enable_exceptions()
-if(KALARM_USE_AKONADI)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/
@@ -30,21 +26,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/libkdepim/
${Boost_INCLUDE_DIR}
)
-else()
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/
- ${CMAKE_CURRENT_SOURCE_DIR}/lib
- ${CMAKE_CURRENT_SOURCE_DIR}/resources
- ${CMAKE_SOURCE_DIR}
- ${CMAKE_SOURCE_DIR}/libkdepim/
- ${Boost_INCLUDE_DIR}
-)
-endif()
-if(NOT KALARM_USE_AKONADI)
- add_subdirectory(resources)
-endif()
add_subdirectory(appicons)
add_subdirectory(pixmaps)
add_subdirectory(autostart)
@@ -126,7 +108,6 @@ set(kalarm_bin_SRCS ${libkalarm_SRCS}
templatemenuaction.cpp
wakedlg.cpp
)
-if(KALARM_USE_AKONADI)
set(kalarm_bin_SRCS ${kalarm_bin_SRCS}
akonadimodel.cpp
akonadiresourcecreator.cpp
@@ -136,16 +117,6 @@ set(kalarm_bin_SRCS ${kalarm_bin_SRCS}
calendarmigrator.cpp
eventid.cpp
)
-else()
-set(kalarm_bin_SRCS ${kalarm_bin_SRCS}
- calendarcompat.cpp
- eventlistmodel.cpp
- alarmlistfiltermodel.cpp
- resourceconfigdialog.cpp
- resourcemodelview.cpp
- templatelistfiltermodel.cpp
- )
-endif()
qt5_wrap_ui(kalarm_bin_SRCS
wakedlg.ui
@@ -157,70 +128,45 @@ if (KMAIL_SUPPORTED)
endif ()
#REACTIVATE qt4_add_dbus_interfaces(kalarm_bin_SRCS \
${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
-if(KALARM_USE_AKONADI)
- kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/kalarmresource.kcfg \
org.kde.Akonadi.KAlarm.Settings)
- qt4_add_dbus_interface(kalarm_bin_SRCS \
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.KAlarm.Settings.xml kalarmsettings \
KAlarmSettings) +kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/kalarmresource.kcfg \
org.kde.Akonadi.KAlarm.Settings) +qt4_add_dbus_interface(kalarm_bin_SRCS \
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.KAlarm.Settings.xml kalarmsettings \
KAlarmSettings)
- kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/kalarmdirresource.kcfg \
org.kde.Akonadi.KAlarmDir.Settings)
- qt4_add_dbus_interface(kalarm_bin_SRCS \
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.KAlarmDir.Settings.xml kalarmdirsettings \
KAlarmDirSettings) +kcfg_generate_dbus_interface(${CMAKE_CURRENT_SOURCE_DIR}/kalarmdirresource.kcfg \
org.kde.Akonadi.KAlarmDir.Settings) +qt4_add_dbus_interface(kalarm_bin_SRCS \
${CMAKE_CURRENT_BINARY_DIR}/org.kde.Akonadi.KAlarmDir.Settings.xml kalarmdirsettings \
KAlarmDirSettings)
- qt4_add_dbus_interfaces(kalarm_bin_SRCS \
${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml)
-# qt5_add_dbus_adaptor(kalarm_bin_SRCS \
${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml agentbase.h \
Akonadi::AgentBase controladaptor Akonadi__ControlAdaptor)
-endif()
+qt4_add_dbus_interfaces(kalarm_bin_SRCS \
${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml) \
+#qt5_add_dbus_adaptor(kalarm_bin_SRCS \
${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml agentbase.h \
Akonadi::AgentBase controladaptor Akonadi__ControlAdaptor)
kconfig_add_kcfg_files(kalarm_bin_SRCS GENERATE_MOC kalarmconfig.kcfgc)
#if (UNIX)
kde4_add_app_icon(kalarm_bin_SRCS \
"${CMAKE_CURRENT_SOURCE_DIR}/appicons/ox*-app-kalarm.png") add_executable(kalarm_bin \
${kalarm_bin_SRCS})
-if(KALARM_USE_AKONADI)
- add_dependencies(kalarm_bin kalarm_resource_xml kalarmdir_resource_xml)
-endif()
+add_dependencies(kalarm_bin kalarm_resource_xml kalarmdir_resource_xml)
if (KMAIL_SUPPORTED)
add_dependencies(kalarm_bin kmail_xml)
endif ()
set_target_properties(kalarm_bin PROPERTIES OUTPUT_NAME kalarm)
-if(KALARM_USE_AKONADI)
- target_link_libraries(kalarm_bin
- KF5::AlarmCalendar
- KF5::CalendarCore
- KF5::CalendarUtils
- KF5::Abc
- KF5::Mime
- KF5::PimIdentities
- KF5::MailTransport
- KF5::AkonadiCore
- KF5::AkonadiMime
- KF5::AkonadiContact
- KF5::Holidays
- KF5::PimUtils
- kdepim
- KF5::KCMUtils
- ${KDE4_PHONON_LIBS}
- ${X11_X11_LIB}
- )
-else()
- target_link_libraries(kalarm_bin
- kalarm_resources
- KF5::AlarmCalendar
- ${KDEPIMLIBS_KCAL_LIBS}
- KF5::Abc
- KF5::Mime
- KF5::PimIdentities
- KF5::MailTransport
- KF5::AkonadiCore
- KF5::AkonadiMime
- KF5::AkonadiContact
- KF5::Holidays
- KF5::PimUtils
- kdepim
- KF5::KCMUtils
- ${KDE4_PHONON_LIBS}
- ${X11_X11_LIB}
- )
-endif()
+target_link_libraries(kalarm_bin
+KF5::AlarmCalendar
+KF5::CalendarCore
+KF5::CalendarUtils
+KF5::Abc
+KF5::Mime
+KF5::PimIdentities
+KF5::MailTransport
+KF5::AkonadiCore
+KF5::AkonadiMime
+KF5::AkonadiContact
+KF5::Holidays
+KF5::PimUtils
+kdepim
+KF5::KCMUtils
+${KDE4_PHONON_LIBS}
+${X11_X11_LIB}
+)
install(TARGETS kalarm_bin ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/kalarm/alarmlistfiltermodel.cpp b/kalarm/alarmlistfiltermodel.cpp
deleted file mode 100644
index 6c346d5..0000000
--- a/kalarm/alarmlistfiltermodel.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * alarmlistfiltermodel.cpp - proxy model class for lists of alarms
- * Program: kalarm
- * Copyright © 2007-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h" //krazy:exclude=includes (kalarm.h must be first)
-#include "alarmlistfiltermodel.h"
-
-#include "eventlistmodel.h"
-
-#include <kdebug.h>
-
-using namespace KAlarmCal;
-
-// AlarmListFilterModel provides sorting and filtering for the alarm list model.
-
-
-AlarmListFilterModel::AlarmListFilterModel(EventListModel* baseModel, QObject* \
parent)
- : EventListFilterModel(baseModel, parent),
- mStatusFilter(CalEvent::EMPTY)
-{}
-
-void AlarmListFilterModel::setStatusFilter(CalEvent::Types type)
-{
- if (type != mStatusFilter)
- {
- mStatusFilter = type;
- invalidateFilter();
- }
-}
-
-bool AlarmListFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex&) const
-{
- return sourceModel()->data(sourceModel()->index(sourceRow, 0), \
EventListModel::StatusRole).toInt() & mStatusFilter;
-}
-
-bool AlarmListFilterModel::filterAcceptsColumn(int sourceCol, const QModelIndex&) \
const
-{
- return (sourceCol != EventListModel::TemplateNameColumn);
-}
-
-QModelIndex AlarmListFilterModel::mapFromSource(const QModelIndex& sourceIndex) \
const
-{
- if (sourceIndex.column() == EventListModel::TemplateNameColumn)
- return QModelIndex();
- return EventListFilterModel::mapFromSource(sourceIndex);
-}
-
-// vim: et sw=4:
diff --git a/kalarm/alarmlistfiltermodel.h b/kalarm/alarmlistfiltermodel.h
deleted file mode 100644
index d85feef..0000000
--- a/kalarm/alarmlistfiltermodel.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * alarmlistfiltermodel.h - proxy model class for lists of alarms
- * Program: kalarm
- * Copyright © 2007-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef ALARMLISTFILTERMODEL_H
-#define ALARMLISTFILTERMODEL_H
-
-#include "kalarm.h"
-
-#include "eventlistmodel.h"
-
-#include <KAlarmCal/kacalendar.h>
-
-
-class AlarmListFilterModel : public EventListFilterModel
-{
- Q_OBJECT
- public:
- enum { ColumnCount = 6 };
-
- explicit AlarmListFilterModel(EventListModel* baseModel, QObject* parent = \
0);
- void setStatusFilter(CalEvent::Types);
- CalEvent::Types statusFilter() const { return mStatusFilter; }
- virtual QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
-
- protected:
- virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& \
sourceParent) const;
- virtual bool filterAcceptsColumn(int sourceCol, const QModelIndex& \
sourceParent) const;
-
- private:
- CalEvent::Types mStatusFilter;
-};
-
-#endif // ALARMLISTFILTERMODEL_H
-
-// vim: et sw=4:
diff --git a/kalarm/calendarcompat.cpp b/kalarm/calendarcompat.cpp
deleted file mode 100644
index 89215ef..0000000
--- a/kalarm/calendarcompat.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * calendarcompat.cpp - compatibility for old calendar file formats
- * Program: kalarm
- * Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "calendarcompat.h"
-#include "functions.h"
-#include "mainwindow.h"
-#include "messagebox.h"
-
-#include <kcal/calendarlocal.h>
-
-#include <kdebug.h>
-
-namespace CalendarCompat
-{
-
-/******************************************************************************
-* Find the version of KAlarm which wrote the calendar file, and do any
-* necessary conversions to the current format. If it is a resource calendar,
-* the user is prompted whether to save the conversions. For a local calendar
-* file, any conversions will only be saved if changes are made later.
-* If the calendar only contains the wrong alarm types, 'wrongType' is set true.
-* Reply = true if the calendar file is now in the current format.
-*/
-KACalendar::Compat fix(KCal::CalendarLocal& calendar, const QString& localFile, \
AlarmResource* resource,
- AlarmResource::FixFunc conv, bool* wrongType)
-{
- if (wrongType)
- *wrongType = false;
- QString versionString;
- int version = KACalendar::updateVersion(calendar, localFile, versionString);
- if (version == KACalendar::IncompatibleFormat)
- return KACalendar::Incompatible; // calendar was created by another \
program, or an unknown version of KAlarm
- if (!resource)
- return KACalendar::Current; // update non-shared calendars regardless
-
- // Check whether the alarm types in the calendar correspond with the resource's \
alarm type
- if (wrongType)
- *wrongType = !resource->checkAlarmTypes(calendar);
-
- if (version == KACalendar::CurrentFormat)
- return KACalendar::Current; // calendar is in current KAlarm format
- if (resource->ResourceCached::readOnly() || conv == AlarmResource::NO_CONVERT)
- return KACalendar::Convertible;
- // Update the calendar file now if the user wants it to be read-write
- if (conv == AlarmResource::PROMPT || conv == AlarmResource::PROMPT_PART)
- {
- QString msg = KAlarm::conversionPrompt(resource->resourceName(), \
versionString, (conv == AlarmResource::PROMPT));
- if (KAMessageBox::warningYesNo(MainWindow::mainMainWindow(), msg) != \
KMessageBox::Yes)
- return KACalendar::Convertible;
- }
- KACalendar::setKAlarmVersion(calendar);
- return KACalendar::Converted;
-}
-
-} // namespace CalendarCompat
-
-// vim: et sw=4:
diff --git a/kalarm/calendarcompat.h b/kalarm/calendarcompat.h
deleted file mode 100644
index cc7b240..0000000
--- a/kalarm/calendarcompat.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * calendarcompat.h - compatibility for old calendar file formats
- * Program: kalarm
- * Copyright © 2005-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef CALENDARCOMPAT_H
-#define CALENDARCOMPAT_H
-
-#ifndef USE_AKONADI
-
-#include "alarmresource.h"
-#include <KAlarmCal/kacalendar.h>
-namespace KCal { class CalendarLocal; }
-
-
-namespace CalendarCompat
-{
- KACalendar::Compat fix(KCal::CalendarLocal&, const QString& localFile,
- AlarmResource* = 0, AlarmResource::FixFunc = \
AlarmResource::PROMPT, bool* wrongType = 0);
-}
-
-#endif
-
-#endif // CALENDARCOMPAT_H
-
-// vim: et sw=4:
diff --git a/kalarm/eventlistmodel.cpp b/kalarm/eventlistmodel.cpp
deleted file mode 100644
index e99a8bf..0000000
--- a/kalarm/eventlistmodel.cpp
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * eventlistmodel.cpp - model class for lists of alarms or templates
- * Program: kalarm
- * Copyright © 2007-2012 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resources/alarmresource.h"
-#include "resources/alarmresources.h"
-#include "alarmcalendar.h"
-#include "alarmtime.h"
-#include "preferences.h"
-#include "synchtimer.h"
-#include "eventlistmodel.moc"
-
-#include <KAlarmCal/alarmtext.h>
-
-#include <klocale.h>
-#include <kiconloader.h>
-#include <kdebug.h>
-
-#include <QPixmap>
-
-/*=============================================================================
-= Class: EventListModel
-= Contains all active/archived alarms, or all alarm templates, unsorted.
-=============================================================================*/
-
-EventListModel* EventListModel::mAlarmInstance = 0;
-EventListModel* EventListModel::mTemplateInstance = 0;
-QPixmap* EventListModel::mTextIcon = 0;
-QPixmap* EventListModel::mFileIcon = 0;
-QPixmap* EventListModel::mCommandIcon = 0;
-QPixmap* EventListModel::mEmailIcon = 0;
-QPixmap* EventListModel::mAudioIcon = 0;
-QSize EventListModel::mIconSize;
-int EventListModel::mTimeHourPos = -2;
-
-
-EventListModel* EventListModel::alarms()
-{
- if (!mAlarmInstance)
- {
- mAlarmInstance = new EventListModel(CalEvent::ACTIVE | CalEvent::ARCHIVED);
- Preferences::connect(SIGNAL(archivedColourChanged(QColor)), mAlarmInstance, \
SLOT(slotUpdateArchivedColour(QColor)));
- Preferences::connect(SIGNAL(disabledColourChanged(QColor)), mAlarmInstance, \
SLOT(slotUpdateDisabledColour(QColor)));
- Preferences::connect(SIGNAL(holidaysChanged(KHolidays::HolidayRegion)), \
mAlarmInstance, SLOT(slotUpdateHolidays()));
- Preferences::connect(SIGNAL(workTimeChanged(QTime,QTime,QBitArray)), \
mAlarmInstance, SLOT(slotUpdateWorkingHours()));
- }
- return mAlarmInstance;
-}
-
-EventListModel* EventListModel::templates()
-{
- if (!mTemplateInstance)
- mTemplateInstance = new EventListModel(CalEvent::TEMPLATE);
- return mTemplateInstance;
-}
-
-EventListModel::~EventListModel()
-{
- if (this == mAlarmInstance)
- mAlarmInstance = 0;
- else if (this == mTemplateInstance)
- mTemplateInstance = 0;
-}
-
-EventListModel::EventListModel(CalEvent::Types status, QObject* parent)
- : QAbstractTableModel(parent),
- mStatus(status)
-{
- // Load the current list of alarms.
- // The list will be updated whenever a signal is received notifying changes.
- // We need to store the list so that when deletions occur, the deleted alarm's
- // position in the list can be determined.
- mEvents = AlarmCalendar::resources()->events(mStatus);
- mHaveEvents = !mEvents.isEmpty();
-//for(int x=0; x<mEvents.count(); \
++x)kDebug(0)<<"Resource"<<(void*)mEvents[x]->resource()<<"Event"<<(void*)mEvents[x];
- if (!mTextIcon)
- {
- mTextIcon = new QPixmap(SmallIcon("dialog-information"));
- mFileIcon = new QPixmap(SmallIcon("document-open"));
- mCommandIcon = new QPixmap(SmallIcon("system-run"));
- mEmailIcon = new QPixmap(SmallIcon("mail-message-unread"));
- mAudioIcon = new QPixmap(SmallIcon("audio-x-generic"));
- mIconSize = \
mTextIcon->size().expandedTo(mFileIcon->size()).expandedTo(mCommandIcon->size()).expandedTo(mEmailIcon->size()).expandedTo(mAudioIcon->size());
- }
- MinuteTimer::connect(this, SLOT(slotUpdateTimeTo()));
- AlarmResources* resources = AlarmResources::instance();
- connect(resources, \
SIGNAL(resourceStatusChanged(AlarmResource*,AlarmResources::Change)),
- \
SLOT(slotResourceStatusChanged(AlarmResource*,AlarmResources::Change)));
- connect(resources, SIGNAL(resourceLoaded(AlarmResource*,bool)),
- SLOT(slotResourceLoaded(AlarmResource*,bool)));
-}
-
-int EventListModel::rowCount(const QModelIndex& parent) const
-{
- if (parent.isValid())
- return 0;
- return mEvents.count();
-}
-
-int EventListModel::columnCount(const QModelIndex& parent) const
-{
- if (parent.isValid())
- return 0;
- return ColumnCount;
-}
-
-QModelIndex EventListModel::index(int row, int column, const QModelIndex& parent) \
const
-{
- if (parent.isValid() || row >= mEvents.count())
- return QModelIndex();
- return createIndex(row, column, mEvents[row]);
-}
-
-QVariant EventListModel::data(const QModelIndex& index, int role) const
-{
- int column = index.column();
- if (role == Qt::WhatsThisRole)
- return whatsThisText(column);
- KAEvent* event = static_cast<KAEvent*>(index.internalPointer());
- if (!event)
- return QVariant();
- bool resourceColour = false;
- switch (column)
- {
- case TimeColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- resourceColour = true;
- break;
- case Qt::DisplayRole:
- {
- DateTime due = event->expired() ? event->startDateTime() : \
event->nextTrigger(KAEvent::DISPLAY_TRIGGER);
- return AlarmTime::alarmTimeText(due);
- }
- case SortRole:
- {
- DateTime due = event->expired() ? event->startDateTime() : \
event->nextTrigger(KAEvent::DISPLAY_TRIGGER);
- return due.isValid() ? \
due.effectiveKDateTime().toUtc().dateTime()
- : QDateTime(QDate(9999,12,31), \
QTime(0,0,0));
- }
- default:
- break;
- }
- break;
- case TimeToColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- resourceColour = true;
- break;
- case Qt::DisplayRole:
- if (event->expired())
- return QString();
- return \
AlarmTime::timeToAlarmText(event->nextTrigger(KAEvent::DISPLAY_TRIGGER));
- case SortRole:
- {
- if (event->expired())
- return -1;
- KDateTime now = KDateTime::currentUtcDateTime();
- DateTime due = event->nextTrigger(KAEvent::DISPLAY_TRIGGER);
- if (due.isDateOnly())
- return now.date().daysTo(due.date()) * 1440;
- return (now.secsTo(due.effectiveKDateTime()) + 59) / 60;
- }
- }
- break;
- case RepeatColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- resourceColour = true;
- break;
- case Qt::DisplayRole:
- return repeatText(event);
- case Qt::TextAlignmentRole:
- return Qt::AlignHCenter;
- case SortRole:
- return repeatOrder(event);
- }
- break;
- case ColourColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- switch (event->actionTypes())
- {
- case KAEvent::ACT_DISPLAY_COMMAND:
- case KAEvent::ACT_DISPLAY:
- return event->bgColour();
- case KAEvent::ACT_COMMAND:
- if (event->commandError() != KAEvent::CMD_NO_ERROR)
- return Qt::red;
- break;
- default:
- break;
- }
- break;
- case Qt::ForegroundRole:
- if (event->commandError() != KAEvent::CMD_NO_ERROR)
- {
- if (event->actionTypes() == KAEvent::ACT_COMMAND)
- return Qt::white;
- QColor colour = Qt::red;
- int r, g, b;
- event->bgColour().getRgb(&r, &g, &b);
- if (r > 128 && g <= 128 && b <= 128)
- colour = Qt::white;
- return colour;
- }
- break;
- case Qt::DisplayRole:
- if (event->commandError() != KAEvent::CMD_NO_ERROR)
- return QString::fromLatin1("!");
- break;
- case SortRole:
- {
- unsigned i = (event->actionTypes() == KAEvent::ACT_DISPLAY)
- ? event->bgColour().rgb() : 0;
- return QString("%1").arg(i, 6, 10, QLatin1Char('0'));
- }
- default:
- break;
- }
- break;
- case TypeColumn:
- switch (role)
- {
- case Qt::DecorationRole:
- {
- QVariant v;
- v.setValue(*eventIcon(event));
- return v;
- }
- case Qt::TextAlignmentRole:
- return Qt::AlignHCenter;
- case Qt::SizeHintRole:
- return mIconSize;
- case Qt::AccessibleTextRole:
-#ifdef __GNUC__
-#warning Implement this
-#endif
- return QString();
- case ValueRole:
- return static_cast<int>(event->actionSubType());
- case SortRole:
- return QString("%1").arg(event->actionSubType(), 2, 10, \
QLatin1Char('0'));
- }
- break;
- case TextColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- resourceColour = true;
- break;
- case Qt::DisplayRole:
- case SortRole:
- return AlarmText::summary(*event, 1);
- case Qt::ToolTipRole:
- return AlarmText::summary(*event, 10);
- default:
- break;
- }
- break;
- case TemplateNameColumn:
- switch (role)
- {
- case Qt::BackgroundRole:
- resourceColour = true;
- break;
- case Qt::DisplayRole:
- return event->templateName();
- case SortRole:
- return event->templateName().toUpper();
- }
- break;
- default:
- break;
- }
-
- switch (role)
- {
- case Qt::ForegroundRole:
- if (!event->enabled())
- return Preferences::disabledColour();
- if (event->expired())
- return Preferences::archivedColour();
- break; // use the default for normal active alarms
- case Qt::ToolTipRole:
- // Show the last command execution error message
- switch (event->commandError())
- {
- case KAEvent::CMD_ERROR:
- return i18nc("@info:tooltip", "Command execution failed");
- case KAEvent::CMD_ERROR_PRE:
- return i18nc("@info:tooltip", "Pre-alarm action execution \
failed");
- case KAEvent::CMD_ERROR_POST:
- return i18nc("@info:tooltip", "Post-alarm action execution \
failed");
- case KAEvent::CMD_ERROR_PRE_POST:
- return i18nc("@info:tooltip", "Pre- and post-alarm action \
execution failed");
- default:
- case KAEvent::CMD_NO_ERROR:
- break;
- }
- break;
- case StatusRole:
- return event->category();
- case EnabledRole:
- return event->enabled();
- default:
- break;
- }
-
- if (resourceColour)
- {
- AlarmResource* resource = \
AlarmResources::instance()->resourceForIncidence(event->id());
- if (resource && resource->colour().isValid())
- return resource->colour();
- }
- return QVariant();
-}
-
-bool EventListModel::setData(const QModelIndex& ix, const QVariant&, int role)
-{
- if (ix.isValid() && role == Qt::EditRole)
- {
- int row = ix.row();
- emit dataChanged(index(row, 0), index(row, ColumnCount - 1));
- return true;
- }
- return false;
-}
-
-QVariant EventListModel::headerData(int section, Qt::Orientation orientation, int \
role) const
-{
- if (orientation == Qt::Horizontal)
- {
- if (role == Qt::DisplayRole)
- {
- switch (section)
- {
- case TimeColumn:
- return i18nc("@title:column", "Time");
- case TimeToColumn:
- return i18nc("@title:column", "Time To");
- case RepeatColumn:
- return i18nc("@title:column", "Repeat");
- case ColourColumn:
- return QString();
- case TypeColumn:
- return QString();
- case TextColumn:
- return i18nc("@title:column", "Message, File or Command");
- case TemplateNameColumn:
- return i18nc("@title:column Template name", "Name");
- }
- }
- else if (role == Qt::WhatsThisRole)
- return whatsThisText(section);
- }
- return QVariant();
-}
-
-Qt::ItemFlags EventListModel::flags(const QModelIndex& index) const
-{
- if (!index.isValid())
- return Qt::ItemIsEnabled;
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | \
Qt::ItemIsDragEnabled;
-}
-
-/******************************************************************************
-* Signal every minute that the time-to-alarm values have changed.
-*/
-void EventListModel::slotUpdateTimeTo()
-{
- int n = mEvents.count();
- if (n > 0)
- emit dataChanged(index(0, TimeToColumn), index(n - 1, TimeToColumn));
-}
-
-/******************************************************************************
-* Called when the colour used to display archived alarms has changed.
-*/
-void EventListModel::slotUpdateArchivedColour(const QColor&)
-{
- kDebug();
- int firstRow = -1;
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->category() == CalEvent::ARCHIVED)
- {
- // For efficiency, emit a single signal for each group
- // of consecutive archived alarms, rather than a separate
- // signal for each alarm.
- if (firstRow < 0)
- firstRow = row;
- }
- else if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, 0), index(row - 1, ColumnCount - 1));
- firstRow = -1;
- }
- }
- if (firstRow >= 0)
- emit dataChanged(index(firstRow, 0), index(mEvents.count() - 1, ColumnCount \
- 1));
-}
-
-/******************************************************************************
-* Called when the colour used to display disabled alarms has changed.
-*/
-void EventListModel::slotUpdateDisabledColour(const QColor&)
-{
- kDebug();
- int firstRow = -1;
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (!mEvents[row]->enabled())
- {
- // For efficiency, emit a single signal for each group
- // of consecutive disabled alarms, rather than a separate
- // signal for each alarm.
- if (firstRow < 0)
- firstRow = row;
- }
- else if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, 0), index(row - 1, ColumnCount - 1));
- firstRow = -1;
- }
- }
- if (firstRow >= 0)
- emit dataChanged(index(firstRow, 0), index(mEvents.count() - 1, ColumnCount \
- 1));
-}
-
-/******************************************************************************
-* Called when the definition of holidays has changed.
-* Update the next trigger time for all alarms which are set to recur only on
-* non-holidays.
-*/
-void EventListModel::slotUpdateHolidays()
-{
- kDebug();
- int firstRow = -1;
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->holidaysExcluded())
- {
- // For efficiency, emit a single signal for each group
- // of consecutive alarms to update, rather than a separate
- // signal for each alarm.
- if (firstRow < 0)
- firstRow = row;
- }
- else if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, TimeColumn), index(row - 1, \
TimeColumn));
- emit dataChanged(index(firstRow, TimeToColumn), index(row - 1, \
TimeToColumn));
- firstRow = -1;
- }
- }
- if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, TimeColumn), index(mEvents.count() - 1, \
TimeColumn));
- emit dataChanged(index(firstRow, TimeToColumn), index(mEvents.count() - 1, \
TimeToColumn));
- }
-}
-
-/******************************************************************************
-* Called when the definition of working hours has changed.
-* Update the next trigger time for all alarms which are set to recur only
-* during working hours.
-*/
-void EventListModel::slotUpdateWorkingHours()
-{
- kDebug();
- int firstRow = -1;
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->workTimeOnly())
- {
- // For efficiency, emit a single signal for each group
- // of consecutive alarms to update, rather than a separate
- // signal for each alarm.
- if (firstRow < 0)
- firstRow = row;
- }
- else if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, TimeColumn), index(row - 1, \
TimeColumn));
- emit dataChanged(index(firstRow, TimeToColumn), index(row - 1, \
TimeToColumn));
- firstRow = -1;
- }
- }
- if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, TimeColumn), index(mEvents.count() - 1, \
TimeColumn));
- emit dataChanged(index(firstRow, TimeToColumn), index(mEvents.count() - 1, \
TimeToColumn));
- }
-}
-
-/******************************************************************************
-* Called when the command error status of an alarm has changed.
-* Update the visual command error indication.
-*/
-void EventListModel::updateCommandError(const QString& eventId)
-{
- int row = findEvent(eventId);
- if (row >= 0)
- {
- QModelIndex ix = index(row, ColourColumn);
- emit dataChanged(ix, ix);
- }
-}
-
-/******************************************************************************
-* Called when loading of a resource is complete.
-*/
-void EventListModel::slotResourceLoaded(AlarmResource* resource, bool active)
-{
- if (active)
- slotResourceStatusChanged(resource, AlarmResources::Added);
-}
-
-/******************************************************************************
-* Static method called when a resource status has changed.
-*/
-void EventListModel::resourceStatusChanged(AlarmResource* resource, \
AlarmResources::Change change)
-{
- if (mAlarmInstance)
- mAlarmInstance->slotResourceStatusChanged(resource, change);
- if (mTemplateInstance)
- mTemplateInstance->slotResourceStatusChanged(resource, change);
-}
-
-/******************************************************************************
-* Called when a resource status has changed.
-*/
-void EventListModel::slotResourceStatusChanged(AlarmResource* resource, \
AlarmResources::Change change)
-{
- bool added = false;
- switch (change)
- {
- case AlarmResources::Added:
- kDebug() << resource->resourceName() << "Added";
- added = true;
- break;
- case AlarmResources::Deleted:
- kDebug() << resource->resourceName() << "Deleted";
- removeResource(resource);
- return;
- case AlarmResources::Invalidated:
- kDebug() << resource->resourceName() << "Invalidated";
- removeResource(resource);
- return;
- case AlarmResources::Location:
- kDebug() << resource->resourceName() << "Location";
- removeResource(resource);
- added = true;
- break;
- case AlarmResources::Enabled:
- if (resource->isActive())
- added = true;
- else
- removeResource(resource);
- break;
- case AlarmResources::Colour:
- {
- kDebug() << "Colour";
- int firstRow = -1;
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->resource() == resource)
- {
- // For efficiency, emit a single signal for each group
- // of consecutive alarms for the resource, rather than a \
separate
- // signal for each alarm.
- if (firstRow < 0)
- firstRow = row;
- }
- else if (firstRow >= 0)
- {
- emit dataChanged(index(firstRow, 0), index(row - 1, ColumnCount \
- 1));
- firstRow = -1;
- }
- }
- if (firstRow >= 0)
- emit dataChanged(index(firstRow, 0), index(mEvents.count() - 1, \
ColumnCount - 1));
- return;
- }
- case AlarmResources::ReadOnly:
- case AlarmResources::WrongType:
- return;
- }
-
- if (added)
- {
- KAEvent::List list = AlarmCalendar::resources()->events(resource, mStatus);
- for (int i = list.count(); --i >= 0; )
- {
- if (mEvents.indexOf(list[i]) >= 0)
- list.remove(i); // avoid creating duplicate entries
- }
- if (!list.isEmpty())
- {
- int row = mEvents.count();
- beginInsertRows(QModelIndex(), row, row + list.count() - 1);
- mEvents += list;
- endInsertRows();
- if (!mHaveEvents)
- updateHaveEvents(true);
- }
- }
-}
-
-/******************************************************************************
-* Remove a resource's events from the list.
-* This has to be called before the resource is actually deleted or reloaded. If
-* not, timer based updates can occur between the resource being deleted and
-* slotResourceStatusChanged(Deleted) being triggered, leading to crashes when
-* data from the resource's events is fetched.
-*/
-void EventListModel::removeResource(AlarmResource* resource)
-{
- kDebug();
- int lastRow = -1;
- for (int row = mEvents.count(); --row >= 0; )
- {
- AlarmResource* r = mEvents[row]->resource();
- if (!r || r == resource)
- {
- // For efficiency, delete each group of consecutive
- // alarms for the resource, rather than deleting each
- // alarm separately.
- if (lastRow < 0)
- lastRow = row;
- }
- else if (lastRow >= 0)
- {
- beginRemoveRows(QModelIndex(), row + 1, lastRow);
- while (lastRow > row)
- mEvents.remove(lastRow--);
- endRemoveRows();
- lastRow = -1;
- }
- }
- if (lastRow >= 0)
- {
- beginRemoveRows(QModelIndex(), 0, lastRow);
- while (lastRow >= 0)
- mEvents.remove(lastRow--);
- endRemoveRows();
- }
- if (mHaveEvents && mEvents.isEmpty())
- updateHaveEvents(false);
-}
-
-/******************************************************************************
-* Reload the event list.
-*/
-void EventListModel::reload()
-{
- // This would be better done by a reset(), but the signals are private to \
QAbstractItemModel
- if (!mEvents.isEmpty())
- {
- beginRemoveRows(QModelIndex(), 0, mEvents.count() - 1);
- mEvents.clear();
- endRemoveRows();
- }
- KAEvent::List list = AlarmCalendar::resources()->events(mStatus);
- if (!list.isEmpty())
- {
- beginInsertRows(QModelIndex(), 0, list.count() - 1);
- mEvents = list;
- endInsertRows();
- }
- if (mHaveEvents == mEvents.isEmpty())
- updateHaveEvents(!mHaveEvents);
-}
-
-/******************************************************************************
-* Return the index to a specified event.
-*/
-QModelIndex EventListModel::eventIndex(const QString& eventId) const
-{
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->id() == eventId)
- return createIndex(row, 0, mEvents[row]);
- }
- return QModelIndex();
-}
-
-/******************************************************************************
-* Return the index to a specified event.
-*/
-QModelIndex EventListModel::eventIndex(const KAEvent* event) const
-{
- int row = mEvents.indexOf(const_cast<KAEvent*>(event));
- if (row < 0)
- return QModelIndex();
- return createIndex(row, 0, mEvents[row]);
-}
-
-/******************************************************************************
-* Add an event to the list.
-*/
-void EventListModel::addEvent(KAEvent* event)
-{
- if (!(event->category() & mStatus) || mEvents.contains(event))
- return;
- int row = mEvents.count();
- beginInsertRows(QModelIndex(), row, row);
- mEvents += event;
- endInsertRows();
- if (!mHaveEvents)
- updateHaveEvents(true);
-}
-
-/******************************************************************************
-* Add an event to the list.
-*/
-void EventListModel::addEvents(const KAEvent::List& events)
-{
- KAEvent::List evs;
- for (int i = 0, count = events.count(); i < count; ++i)
- if (events[i]->category() & mStatus)
- evs += events[i];
- int row = mEvents.count();
- beginInsertRows(QModelIndex(), row, row + evs.count() - 1);
- mEvents += evs;
- endInsertRows();
- if (!mHaveEvents)
- updateHaveEvents(true);
-}
-
-/******************************************************************************
-* Remove an event from the list.
-*/
-void EventListModel::removeEvent(int row)
-{
- if (row < 0)
- return;
- beginRemoveRows(QModelIndex(), row, row);
- mEvents.remove(row);
- endRemoveRows();
- if (mHaveEvents && mEvents.isEmpty())
- updateHaveEvents(false);
-}
-
-/******************************************************************************
-* Notify that an event in the list has been updated.
-*/
-bool EventListModel::updateEvent(int row)
-{
- if (row < 0)
- return false;
- emit dataChanged(index(row, 0), index(row, ColumnCount - 1));
- return true;
-}
-
-bool EventListModel::updateEvent(const QString& oldId, KAEvent* newEvent)
-{
- int row = findEvent(oldId);
- if (row < 0)
- return false;
- mEvents[row] = newEvent;
- emit dataChanged(index(row, 0), index(row, ColumnCount - 1));
- return true;
-}
-
-/******************************************************************************
-* Find the row of an event in the list, given its unique ID.
-*/
-int EventListModel::findEvent(const QString& eventId) const
-{
- for (int row = 0, end = mEvents.count(); row < end; ++row)
- {
- if (mEvents[row]->id() == eventId)
- return row;
- }
- return -1;
-}
-
-/******************************************************************************
-* Return the event for a given row.
-*/
-KAEvent* EventListModel::event(int row) const
-{
- if (row < 0 || row >= mEvents.count())
- return 0;
- return mEvents[row];
-}
-
-/******************************************************************************
-* Return the event referred to by an index.
-*/
-KAEvent* EventListModel::event(const QModelIndex& index)
-{
- if (!index.isValid())
- return 0;
- return static_cast<KAEvent*>(index.internalPointer());
-}
-
-/******************************************************************************
-* Return the repetition text.
-*/
-QString EventListModel::repeatText(const KAEvent* event) const
-{
- QString repeatText = event->recurrenceText(true);
- if (repeatText.isEmpty())
- repeatText = event->repetitionText(true);
- return repeatText;
-}
-
-/******************************************************************************
-* Return a string for sorting the repetition column.
-*/
-QString EventListModel::repeatOrder(const KAEvent* event) const
-{
- int repeatOrder = 0;
- int repeatInterval = 0;
- if (event->repeatAtLogin())
- repeatOrder = 1;
- else
- {
- repeatInterval = event->recurInterval();
- switch (event->recurType())
- {
- case KARecurrence::MINUTELY:
- repeatOrder = 2;
- break;
- case KARecurrence::DAILY:
- repeatOrder = 3;
- break;
- case KARecurrence::WEEKLY:
- repeatOrder = 4;
- break;
- case KARecurrence::MONTHLY_DAY:
- case KARecurrence::MONTHLY_POS:
- repeatOrder = 5;
- break;
- case KARecurrence::ANNUAL_DATE:
- case KARecurrence::ANNUAL_POS:
- repeatOrder = 6;
- break;
- case KARecurrence::NO_RECUR:
- default:
- break;
- }
- }
- return QString("%1%2").arg(static_cast<char>('0' + \
repeatOrder)).arg(repeatInterval, 8, 10, QLatin1Char('0'));
-}
-
-/******************************************************************************
-* Return the icon associated with the event's action.
-*/
-QPixmap* EventListModel::eventIcon(const KAEvent* event) const
-{
- switch (event->actionTypes())
- {
- case KAEvent::ACT_EMAIL:
- return mEmailIcon;
- case KAEvent::ACT_AUDIO:
- return mAudioIcon;
- case KAEvent::ACT_COMMAND:
- return mCommandIcon;
- case KAEvent::ACT_DISPLAY:
- if (event->actionSubType() == KAEvent::FILE)
- return mFileIcon;
- // fall through to ACT_DISPLAY_COMMAND
- case KAEvent::ACT_DISPLAY_COMMAND:
- default:
- return mTextIcon;
- }
-}
-
-/******************************************************************************
-* Returns the QWhatsThis text for a specified column.
-*/
-QString EventListModel::whatsThisText(int column) const
-{
- switch (column)
- {
- case TimeColumn:
- return i18nc("@info:whatsthis", "Next scheduled date and time of the \
alarm");
- case TimeToColumn:
- return i18nc("@info:whatsthis", "How long until the next scheduled \
trigger of the alarm");
- case RepeatColumn:
- return i18nc("@info:whatsthis", "How often the alarm recurs");
- case ColourColumn:
- return i18nc("@info:whatsthis", "Background color of alarm message");
- case TypeColumn:
- return i18nc("@info:whatsthis", "Alarm type (message, file, command or \
email)");
- case TextColumn:
- return i18nc("@info:whatsthis", "Alarm message text, URL of text file to \
display, command to execute, or email subject line");
- case TemplateNameColumn:
- return i18nc("@info:whatsthis", "Name of the alarm template");
- default:
- return QString();
- }
-}
-
-
-/*=============================================================================
-= Class: EventListFilterModel
-= Base class for all filters on EventListModel.
-=============================================================================*/
-
-EventListFilterModel::EventListFilterModel(EventListModel* baseModel, QObject* \
parent)
- : QSortFilterProxyModel(parent)
-{
- setSourceModel(baseModel);
- setSortRole(EventListModel::SortRole);
- setDynamicSortFilter(true);
-}
-
-/******************************************************************************
-* Return the event referred to by an index.
-*/
-KAEvent* EventListFilterModel::event(const QModelIndex& index) const
-{
- return static_cast<EventListModel*>(sourceModel())->event(mapToSource(index));
-}
-
-KAEvent* EventListFilterModel::event(int row) const
-{
- return static_cast<EventListModel*>(sourceModel())->event(mapToSource(index(row, \
0)));
-}
-
-/******************************************************************************
-* Return the index to a specified event.
-*/
-QModelIndex EventListFilterModel::eventIndex(const QString& eventId) const
-{
- return mapFromSource(static_cast<EventListModel*>(sourceModel())->eventIndex(eventId));
-}
-
-/******************************************************************************
-* Return the index to a specified event.
-*/
-QModelIndex EventListFilterModel::eventIndex(const KAEvent* event) const
-{
- return mapFromSource(static_cast<EventListModel*>(sourceModel())->eventIndex(event));
-}
-
-void EventListFilterModel::slotDataChanged(const QModelIndex& topLeft, const \
QModelIndex& bottomRight)
-{
- emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
-}
-
-// vim: et sw=4:
diff --git a/kalarm/eventlistmodel.h b/kalarm/eventlistmodel.h
deleted file mode 100644
index d8f1682..0000000
--- a/kalarm/eventlistmodel.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * eventlistmodel.h - model class for lists of alarms or templates
- * Program: kalarm
- * Copyright © 2007-2012 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef EVENTLISTMODEL_H
-#define EVENTLISTMODEL_H
-
-#include "kalarm.h"
-
-#include "alarmresources.h"
-
-#include <KAlarmCal/kacalendar.h>
-#include <KAlarmCal/kaevent.h>
-
-#include <QAbstractTableModel>
-#include <QSortFilterProxyModel>
-#include <QSize>
-
-class QPixmap;
-namespace KCal { class Event; }
-
-using namespace KAlarmCal;
-
-
-class EventListModel : public QAbstractTableModel
-{
- Q_OBJECT
- public:
- enum { // data columns
- TimeColumn, TimeToColumn, RepeatColumn, ColourColumn, TypeColumn, \
TextColumn,
- TemplateNameColumn,
- ColumnCount
- };
- enum { // additional roles
- StatusRole = Qt::UserRole, // return ACTIVE/ARCHIVED
- ValueRole, // return numeric value
- SortRole, // return the value to use for sorting
- EnabledRole // return true for enabled alarm, false for \
disabled
- };
-
- static EventListModel* alarms();
- static EventListModel* templates();
- ~EventListModel();
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) \
const;
- virtual int columnCount(const QModelIndex& parent = QModelIndex()) \
const;
- virtual QModelIndex index(int row, int column = 0, const QModelIndex& \
parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) \
const;
- virtual bool setData(const QModelIndex&, const QVariant& value, int \
role = Qt::EditRole);
- virtual QVariant headerData(int section, Qt::Orientation, int role = \
Qt::DisplayRole) const;
- virtual Qt::ItemFlags flags(const QModelIndex&) const;
- static int iconWidth() { return mIconSize.width(); }
- QModelIndex eventIndex(const KAEvent*) const;
- QModelIndex eventIndex(const QString& eventId) const;
- void addEvent(KAEvent*);
- void addEvents(const KAEvent::List&);
- bool updateEvent(KAEvent* event) { return \
updateEvent(mEvents.indexOf(event)); }
- bool updateEvent(const QString& eventId) { return \
updateEvent(findEvent(eventId)); }
- bool updateEvent(const QString& oldId, KAEvent* newEvent);
- void removeEvent(const KAEvent* event) { \
removeEvent(mEvents.indexOf(const_cast<KAEvent*>(event))); }
- void removeEvent(const QString& eventId) { \
removeEvent(findEvent(eventId)); }
- void removeResource(AlarmResource*);
- KAEvent* event(int row) const;
- static KAEvent* event(const QModelIndex&);
- void updateCommandError(const QString& eventId);
- bool haveEvents() const { return \
mHaveEvents; }
- static void resourceStatusChanged(AlarmResource*, \
AlarmResources::Change);
-
- public slots:
- void reload();
-
- signals:
- void haveEventsStatus(bool have);
-
- private slots:
- void slotUpdateTimeTo();
- void slotUpdateArchivedColour(const QColor&);
- void slotUpdateDisabledColour(const QColor&);
- void slotUpdateHolidays();
- void slotUpdateWorkingHours();
- void slotResourceLoaded(AlarmResource*, bool active);
- void slotResourceStatusChanged(AlarmResource*, AlarmResources::Change);
-
- private:
- explicit EventListModel(CalEvent::Types, QObject* parent = 0);
- bool updateEvent(int row);
- void removeEvent(int row);
- int findEvent(const QString& eventId) const;
- void updateHaveEvents(bool have) { mHaveEvents = have; emit \
haveEventsStatus(have); }
- QString repeatText(const KAEvent*) const;
- QString repeatOrder(const KAEvent*) const;
- QPixmap* eventIcon(const KAEvent*) const;
- QString whatsThisText(int column) const;
-
- static EventListModel* mAlarmInstance; // the instance containing all \
alarms
- static EventListModel* mTemplateInstance; // the instance containing all \
templates
- static QPixmap* mTextIcon;
- static QPixmap* mFileIcon;
- static QPixmap* mCommandIcon;
- static QPixmap* mEmailIcon;
- static QPixmap* mAudioIcon;
- static QSize mIconSize; // maximum size of any icon
- static int mTimeHourPos; // position of hour within time string, or \
-1 if leading zeroes included
-
- KAEvent::List mEvents;
- CalEvent::Types mStatus; // types of events contained in this model
- bool mHaveEvents;// there are events in this model
-
- using QObject::event; // prevent "hidden" warning
-};
-
-
-class EventListFilterModel : public QSortFilterProxyModel
-{
- Q_OBJECT
- public:
- explicit EventListFilterModel(EventListModel* baseModel, QObject* parent = \
0);
- KAEvent* event(int row) const;
- KAEvent* event(const QModelIndex&) const;
- QModelIndex eventIndex(const KAEvent*) const;
- QModelIndex eventIndex(const QString& eventId) const;
-
- private slots:
- void slotDataChanged(const QModelIndex&, const QModelIndex&);
-
- private:
- using QObject::event; // prevent "hidden" warning
-};
-
-#endif // EVENTLISTMODEL_H
-
-// vim: et sw=4:
diff --git a/kalarm/resourceconfigdialog.cpp b/kalarm/resourceconfigdialog.cpp
deleted file mode 100644
index 4c2c87a..0000000
--- a/kalarm/resourceconfigdialog.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * resourceconfigdialog.cpp - KAlarm resource configuration dialog
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on configdialog.cpp in kdelibs/kresources,
- * Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
- * Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
- * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "alarmresource.h"
-#include "resourceconfigdialog.moc"
-#include "messagebox.h"
-
-#include <kresources/factory.h>
-
-#include <klocale.h>
-#include <klineedit.h>
-
-#include <QGroupBox>
-#include <QLabel>
-#include <QCheckBox>
-#include <QVBoxLayout>
-#include <QGridLayout>
-
-using namespace KRES;
-
-ResourceConfigDialog::ResourceConfigDialog(QWidget* parent, AlarmResource* resource)
- : KDialog(parent), mResource(resource)
-{
- Factory* factory = Factory::self(QLatin1String("alarms"));
-
- QFrame* main = new QFrame(this);
- setMainWidget(main);
- setCaption(i18nc("@title:window", "Calendar Configuration"));
- setButtons(Ok | Cancel);
- setDefaultButton(Ok);
- setModal(true);
-
- QVBoxLayout* mainLayout = new QVBoxLayout(main);
- mainLayout->setSpacing(spacingHint());
-
- QGroupBox* generalGroupBox = new QGroupBox(main);
- QGridLayout* gbLayout = new QGridLayout;
- gbLayout->setSpacing(spacingHint());
- generalGroupBox->setLayout(gbLayout);
-
- generalGroupBox->setTitle(i18nc("@title:group", "General Settings"));
-
- gbLayout->addWidget(new QLabel(i18nc("@label:textbox Calendar name", "Name:"), \
generalGroupBox), 0, 0);
-
- mName = new KLineEdit();
- gbLayout->addWidget(mName, 0, 1);
-
- mReadOnly = new QCheckBox(i18nc("@option:check", "Read-only"), generalGroupBox);
- gbLayout->addWidget(mReadOnly, 1, 0, 1, 2);
-
- mName->setText(mResource->resourceName());
- mReadOnly->setChecked(mResource->readOnly());
-
- mainLayout->addWidget(generalGroupBox);
-
- QGroupBox* resourceGroupBox = new QGroupBox(main);
- QGridLayout* resourceLayout = new QGridLayout;
- resourceLayout->setSpacing(spacingHint());
- resourceGroupBox->setLayout(resourceLayout);
-
- resourceGroupBox->setTitle(i18nc("@title:group", "<resource>%1</resource> \
Calendar Settings",
- factory->typeName(resource->type())));
- mainLayout->addWidget(resourceGroupBox);
-
- mainLayout->addStretch();
-
- mConfigWidget = factory->configWidget(resource->type(), resourceGroupBox);
- if (mConfigWidget)
- {
- resourceLayout->addWidget(mConfigWidget);
- mConfigWidget->setInEditMode(false);
- mConfigWidget->loadSettings(mResource);
- mConfigWidget->show();
- connect(mConfigWidget, SIGNAL(setReadOnly(bool)), SLOT(setReadOnly(bool)));
- }
-
- connect(mName, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)));
-
- slotNameChanged(mName->text());
- setMinimumSize(sizeHint());
-}
-
-void ResourceConfigDialog::setInEditMode(bool value)
-{
- if (mConfigWidget)
- mConfigWidget->setInEditMode(value);
-}
-
-void ResourceConfigDialog::slotNameChanged(const QString& text)
-{
- enableButtonOk(!text.isEmpty());
-}
-
-void ResourceConfigDialog::setReadOnly(bool value)
-{
- mReadOnly->setChecked(value);
-}
-
-void ResourceConfigDialog::accept()
-{
- if (mName->text().isEmpty())
- {
- KAMessageBox::sorry(this, i18nc("@info", "Please enter a calendar name."));
- return;
- }
-
- mResource->startReconfig();
- mResource->setResourceName(mName->text());
- mResource->setReadOnly(mReadOnly->isChecked());
-
- if (mConfigWidget)
- {
- // First save generic information
- // Also save setting of specific resource type
- mConfigWidget->saveSettings(mResource);
- }
- mResource->applyReconfig();
-
- KDialog::accept();
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resourceconfigdialog.h b/kalarm/resourceconfigdialog.h
deleted file mode 100644
index 42b641f..0000000
--- a/kalarm/resourceconfigdialog.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * resourceconfigdialog.h - KAlarm resource configuration dialog
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- * Based on configdialog.cpp in kdelibs/kresources,
- * Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
- * Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCECONFIGDIALOG_H
-#define RESOURCECONFIGDIALOG_H
-
-#include <kdialog.h>
-
-class KLineEdit;
-class QCheckBox;
-
-namespace KRES {
- class ConfigWidget;
-}
-class AlarmResource;
-
-class ResourceConfigDialog : public KDialog
-{
- Q_OBJECT
- public:
- // Resource=0: create new resource
- ResourceConfigDialog(QWidget* parent, AlarmResource* resource);
-
- void setInEditMode(bool value);
-
- protected Q_SLOTS:
- void accept();
- void setReadOnly(bool value);
- void slotNameChanged(const QString& text);
-
- private:
- KRES::ConfigWidget* mConfigWidget;
- AlarmResource* mResource;
- KLineEdit* mName;
- QCheckBox* mReadOnly;
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resourcemodelview.cpp b/kalarm/resourcemodelview.cpp
deleted file mode 100644
index 847e743..0000000
--- a/kalarm/resourcemodelview.cpp
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * resourcemodelview.cpp - model/view classes for alarm resource lists
- * Program: kalarm
- * Copyright © 2007-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "messagebox.h"
-#include "preferences.h"
-#include "resourcemodelview.moc"
-
-#include <klocale.h>
-#include <kcolorutils.h>
-#include <kdebug.h>
-
-#include <QApplication>
-#include <QToolTip>
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <QHelpEvent>
-
-
-ResourceModel* ResourceModel::mInstance = 0;
-
-
-ResourceModel* ResourceModel::instance(QObject* parent)
-{
- if (!mInstance)
- mInstance = new ResourceModel(parent);
- return mInstance;
-}
-
-ResourceModel::ResourceModel(QObject* parent)
- : QAbstractListModel(parent)
-{
- refresh();
- AlarmResources* resources = AlarmResources::instance();
- connect(resources, SIGNAL(signalResourceModified(AlarmResource*)), \
SLOT(updateResource(AlarmResource*)));
- connect(resources, SIGNAL(standardResourceChange(CalEvent::Type)), \
SLOT(slotStandardChanged(CalEvent::Type)));
- connect(resources, \
SIGNAL(resourceStatusChanged(AlarmResource*,AlarmResources::Change)), \
SLOT(slotStatusChanged(AlarmResource*,AlarmResources::Change)));
- connect(resources, SIGNAL(resourceLoaded(AlarmResource*,bool)), \
SLOT(slotLoaded(AlarmResource*,bool)));
-}
-
-int ResourceModel::rowCount(const QModelIndex& parent) const
-{
- if (parent.isValid())
- return 0;
- return mResources.count();
-}
-
-QModelIndex ResourceModel::index(int row, int column, const QModelIndex& parent) \
const
-{
- if (parent.isValid() || row >= mResources.count())
- return QModelIndex();
- return createIndex(row, column, mResources[row]);
-}
-
-QVariant ResourceModel::data(const QModelIndex& index, int role) const
-{
- if (!index.isValid())
- return QVariant();
- AlarmResource* resource = static_cast<AlarmResource*>(index.internalPointer());
- if (!resource)
- return QVariant();
- switch (role)
- {
- case Qt::DisplayRole:
- return resource->resourceName();
- case Qt::CheckStateRole:
- return resource->isEnabled() ? Qt::Checked : Qt::Unchecked;
- case Qt::ForegroundRole:
- {
- QColor colour;
- switch (resource->alarmType())
- {
- case CalEvent::ACTIVE: colour = \
KColorScheme(QPalette::Active).foreground(KColorScheme::NormalText).color(); \
break;
- case CalEvent::ARCHIVED: colour = Preferences::archivedColour(); \
break;
- case CalEvent::TEMPLATE: colour = \
KColorScheme(QPalette::Active).foreground(KColorScheme::LinkText).color(); \
break;
- default: break;
- }
- if (colour.isValid())
- return resource->readOnly() ? KColorUtils::lighten(colour, 0.25) : \
colour;
- break;
- }
- case Qt::BackgroundRole:
- if (resource->colour().isValid())
- return resource->colour();
- break;
- case Qt::FontRole:
- {
- if (!resource->isEnabled() || !resource->standardResource())
- break;
- QFont font = mFont;
- font.setBold(true);
- return font;
- }
- case Qt::ToolTipRole:
- {
- QString name = '@' + resource->resourceName(); // insert markers for \
stripping out name
- QString type = '@' + resource->displayType();
- bool inactive = !resource->isActive();
- QString disabled = resource->isWrongAlarmType() ? i18nc("@info/plain", \
"Disabled (wrong alarm type)") : i18nc("@info/plain", "Disabled");
- QString readonly = i18nc("@info/plain", "Read-only");
- if (inactive && resource->readOnly())
- return i18nc("@info:tooltip",
- "%1"
- "<nl/>%2: <filename>%3</filename>"
- "<nl/>%4, %5",
- name, type, resource->displayLocation(), disabled, \
readonly);
- if (inactive || resource->readOnly())
- return i18nc("@info:tooltip",
- "%1"
- "<nl/>%2: <filename>%3</filename>"
- "<nl/>%4",
- name, type, resource->displayLocation(),
- (inactive ? disabled : readonly));
- return i18nc("@info:tooltip",
- "%1"
- "<nl/>%2: <filename>%3</filename>",
- name, type, resource->displayLocation());
- }
- default:
- break;
- }
- return QVariant();
-}
-
-/******************************************************************************
-* Set the font to use for all items, or the checked state of one item.
-* The font must always be set at initialisation.
-*/
-bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, int \
role)
-{
- mErrorPrompt.clear();
- if (role == Qt::FontRole)
- {
- // Set the font used in all views.
- // This enables data(index, Qt::FontRole) to return bold when appropriate.
- mFont = value.value<QFont>();
- return true;
- }
- if (role != Qt::CheckStateRole || !index.isValid())
- return false;
- AlarmResource* resource = static_cast<AlarmResource*>(index.internalPointer());
- if (!resource)
- return false;
- Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
- bool active = (state == Qt::Checked);
- bool saveChange = false;
- AlarmResources* resources = AlarmResources::instance();
- if (active)
- {
- // Enable the resource
- resource->setActive(true); // enable it now so that load() will work
- saveChange = resources->load(resource);
- resource->setActive(false); // reset so that setEnabled() will work
- }
- else
- {
- // Disable the resource
- saveChange = resource->saveAndClose(); // close resource after it is saved
- }
- if (saveChange)
- resource->setEnabled(active);
- emit dataChanged(index, index);
- return true;
-}
-
-Qt::ItemFlags ResourceModel::flags(const QModelIndex&) const
-{
- return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
-}
-
-/******************************************************************************
-* Return the resource referred to by an index.
-*/
-AlarmResource* ResourceModel::resource(const QModelIndex& index) const
-{
- if (!index.isValid())
- return 0;
- return static_cast<AlarmResource*>(index.internalPointer());
-}
-
-/******************************************************************************
-* Emit a signal that a resource has changed.
-*/
-void ResourceModel::notifyChange(const QModelIndex& index)
-{
- if (index.isValid())
- emit dataChanged(index, index);
-}
-
-/******************************************************************************
-* Reload the resources list.
-*/
-void ResourceModel::refresh()
-{
- // This would be better done by a reset(), but the signals are private to \
QAbstractItemModel
- if (!mResources.isEmpty())
- {
- beginRemoveRows(QModelIndex(), 0, mResources.count() - 1);
- mResources.clear();
- endRemoveRows();
- }
- QList<AlarmResource*> newResources;
- AlarmResourceManager* manager = AlarmResources::instance()->resourceManager();
- for (AlarmResourceManager::Iterator it = manager->begin(); it != \
manager->end(); ++it)
- newResources += *it;
- if (!newResources.isEmpty())
- {
- beginInsertRows(QModelIndex(), 0, newResources.count() - 1);
- mResources = newResources;
- endInsertRows();
- }
-}
-
-/******************************************************************************
-* Add the specified resource to the list.
-*/
-void ResourceModel::addResource(AlarmResource* resource)
-{
- int row = mResources.count();
- beginInsertRows(QModelIndex(), row, row);
- mResources += resource;
- endInsertRows();
-}
-
-/******************************************************************************
-* Delete the specified resource from the list.
-*/
-void ResourceModel::removeResource(AlarmResource* resource)
-{
- int row = mResources.indexOf(resource);
- if (row >= 0)
- {
- beginRemoveRows(QModelIndex(), row, row);
- mResources.removeAt(row);
- endRemoveRows();
- }
-}
-
-/******************************************************************************
-* Called when the resource has been updated , to update the
-* active status displayed for the resource item.
-*/
-void ResourceModel::updateResource(AlarmResource* resource)
-{
- int row = mResources.indexOf(resource);
- if (row >= 0)
- {
- QModelIndex ix = index(row, 0, QModelIndex());
- emit dataChanged(ix, ix);
- }
-}
-
-/******************************************************************************
-* Called when a different resource has been set as the standard resource.
-*/
-void ResourceModel::slotStandardChanged(CalEvent::Type type)
-{
- for (int row = 0, end = mResources.count(); row < end; ++row)
- {
- if (mResources[row]->alarmType() == type)
- {
- QModelIndex ix = index(row, 0, QModelIndex());
- emit dataChanged(ix, ix);
- }
- }
-}
-
-/******************************************************************************
-* Called when a resource has completed loading.
-* Check in case its status has changed.
-*/
-void ResourceModel::slotLoaded(AlarmResource* resource, bool active)
-{
- if (active)
- updateResource(resource);
-}
-
-/******************************************************************************
-* Called when a resource status has changed, to update the list.
-*/
-void ResourceModel::slotStatusChanged(AlarmResource* resource, \
AlarmResources::Change change)
-{
- switch (change)
- {
- case AlarmResources::Added:
- addResource(resource);
- break;
- case AlarmResources::Enabled:
- case AlarmResources::ReadOnly:
- case AlarmResources::Colour:
- updateResource(resource);
- break;
- default:
- break;
- }
-}
-
-
-/*=============================================================================
-= Class: ResourceFilterModel
-= Proxy model for filtering resource lists.
-=============================================================================*/
-
-ResourceFilterModel::ResourceFilterModel(QAbstractItemModel* baseModel, QObject* \
parent)
- : QSortFilterProxyModel(parent),
- mResourceType(CalEvent::EMPTY)
-{
- setSourceModel(baseModel);
-}
-
-void ResourceFilterModel::setFilter(CalEvent::Type type)
-{
- if (type != mResourceType)
- {
- mResourceType = type;
- invalidateFilter();
- }
-}
-
-bool ResourceFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex&) const
-{
- return static_cast<ResourceModel*>(sourceModel())->resource(sourceModel()->index(sourceRow, \
0))->alarmType() == mResourceType;
-}
-
-/******************************************************************************
-* Return the resource referred to by an index.
-*/
-AlarmResource* ResourceFilterModel::resource(int row) const
-{
- return static_cast<ResourceModel*>(sourceModel())->resource(mapToSource(index(row, \
0)));
-}
-
-AlarmResource* ResourceFilterModel::resource(const QModelIndex& index) const
-{
- return static_cast<ResourceModel*>(sourceModel())->resource(mapToSource(index));
-}
-
-/******************************************************************************
-* Emit a signal that a resource has changed.
-*/
-void ResourceFilterModel::notifyChange(int row)
-{
- static_cast<ResourceModel*>(sourceModel())->notifyChange(mapToSource(index(row, \
0)));
-}
-
-void ResourceFilterModel::notifyChange(const QModelIndex& index)
-{
- static_cast<ResourceModel*>(sourceModel())->notifyChange(mapToSource(index));
-}
-
-
-/*=============================================================================
-= Class: ResourceDelegate
-= Model/view delegate for resource list.
-=============================================================================*/
-
-/******************************************************************************
-* Process a change of state of the checkbox for a resource.
-*/
-bool ResourceDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const \
QStyleOptionViewItem& option, const QModelIndex& index)
-{
- if (!(model->flags(index) & Qt::ItemIsEnabled))
- return false;
- if (event->type() == QEvent::MouseButtonRelease
- || event->type() == QEvent::MouseButtonDblClick)
- {
- const int textMargin = \
QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
- QRect checkRect = QStyle::alignedRect(option.direction, Qt::AlignLeft | \
Qt::AlignVCenter,
- check(option, option.rect, \
Qt::Checked).size(),
- QRect(option.rect.x() + textMargin, \
option.rect.y(), option.rect.width(), option.rect.height()));
- if (!checkRect.contains(static_cast<QMouseEvent*>(event)->pos()))
- return false;
- if (event->type() == QEvent::MouseButtonDblClick)
- return true; // ignore double clicks
- }
- else if (event->type() == QEvent::KeyPress)
- {
- if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space
- && static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)
- return false;
- }
- else
- return false;
-
- QVariant value = index.data(Qt::CheckStateRole);
- if (!value.isValid())
- return false;
- Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == \
Qt::Checked ? Qt::Unchecked : Qt::Checked);
- if (state == Qt::Unchecked)
- {
- // The resource is to be disabled.
- // Check for eligibility.
- AlarmResource* resource = \
static_cast<ResourceFilterModel*>(model)->resource(index);
- if (!resource)
- return false;
- if (resource->standardResource())
- {
- // It's the standard resource for its type.
- if (resource->alarmType() == CalEvent::ACTIVE)
- {
- KAMessageBox::sorry(static_cast<QWidget*>(parent()),
- i18nc("@info", "You cannot disable your default \
active alarm calendar."));
- return false;
-
- }
- if (resource->alarmType() == CalEvent::ARCHIVED && \
Preferences::archivedKeepDays())
- {
- // Only allow the archived alarms standard resource to be disabled \
if
- // we're not saving archived alarms.
- KAMessageBox::sorry(static_cast<QWidget*>(parent()),
- i18nc("@info", "You cannot disable your default \
archived alarm calendar "
- "while expired alarms are configured to be \
kept."));
- return false;
- }
- if (KAMessageBox::warningContinueCancel(static_cast<QWidget*>(parent()),
- i18nc("@info", "Do you really \
want to disable your default calendar?"))
- == KMessageBox::Cancel)
- return false;
- }
- }
- return model->setData(index, state, Qt::CheckStateRole);
-}
-
-
-/*=============================================================================
-= Class: ResourceView
-= View displaying a list of resources.
-=============================================================================*/
-
-void ResourceView::setModel(QAbstractItemModel* model)
-{
- model->setData(QModelIndex(), viewOptions().font, Qt::FontRole);
- QListView::setModel(model);
- setItemDelegate(new ResourceDelegate(this));
-}
-
-/******************************************************************************
-* Return the resource for a given row.
-*/
-AlarmResource* ResourceView::resource(int row) const
-{
- return static_cast<ResourceFilterModel*>(model())->resource(row);
-}
-
-AlarmResource* ResourceView::resource(const QModelIndex& index) const
-{
- return static_cast<ResourceFilterModel*>(model())->resource(index);
-}
-
-/******************************************************************************
-* Emit a signal that a resource has changed.
-*/
-void ResourceView::notifyChange(int row) const
-{
- static_cast<ResourceFilterModel*>(model())->notifyChange(row);
-}
-
-void ResourceView::notifyChange(const QModelIndex& index) const
-{
- static_cast<ResourceFilterModel*>(model())->notifyChange(index);
-}
-
-/******************************************************************************
-* Called when a mouse button is released.
-* Any currently selected resource is deselected.
-*/
-void ResourceView::mouseReleaseEvent(QMouseEvent* e)
-{
- if (!indexAt(e->pos()).isValid())
- clearSelection();
- QListView::mouseReleaseEvent(e);
-}
-
-/******************************************************************************
-* Called when a ToolTip or WhatsThis event occurs.
-*/
-bool ResourceView::viewportEvent(QEvent* e)
-{
- if (e->type() == QEvent::ToolTip && isActiveWindow())
- {
- QHelpEvent* he = static_cast<QHelpEvent*>(e);
- QModelIndex index = indexAt(he->pos());
- QVariant value = model()->data(index, Qt::ToolTipRole);
- if (qVariantCanConvert<QString>(value))
- {
- QString toolTip = value.toString();
- int i = toolTip.indexOf('@');
- if (i > 0)
- {
- int j = toolTip.indexOf(QRegExp("<(nl|br)", Qt::CaseInsensitive), i \
+ 1);
- int k = toolTip.indexOf('@', j);
- QString name = toolTip.mid(i + 1, j - i - 1);
- value = model()->data(index, Qt::FontRole);
- QFontMetrics \
fm(qvariant_cast<QFont>(value).resolve(viewOptions().font));
- int textWidth = fm.boundingRect(name).width() + 1;
- const int margin = \
QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
- QStyleOptionButton opt;
- opt.QStyleOption::operator=(viewOptions());
- opt.rect = rectForIndex(index);
- int checkWidth = \
QApplication::style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, \
&opt).width();
- int left = spacing() + 3*margin + checkWidth + \
viewOptions().decorationSize.width(); // left offset of text
- int right = left + textWidth;
- if (left >= horizontalOffset() + spacing()
- && right <= horizontalOffset() + width() - spacing() - \
2*frameWidth())
- {
- // The whole of the resource name is already displayed,
- // so omit it from the tooltip.
- if (k > 0)
- toolTip.remove(i, k + 1 - i);
- }
- else
- {
- toolTip.remove(k, 1);
- toolTip.remove(i, 1);
- }
- }
- QToolTip::showText(he->globalPos(), toolTip, this);
- return true;
- }
- }
- return QListView::viewportEvent(e);
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resourcemodelview.h b/kalarm/resourcemodelview.h
deleted file mode 100644
index f757313..0000000
--- a/kalarm/resourcemodelview.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * resourcemodelview.h - model/view classes for alarm resource lists
- * Program: kalarm
- * Copyright © 2007,2008,2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCEMODELVIEW_H
-#define RESOURCEMODELVIEW_H
-
-#include "kalarm.h"
-
-#include "resources/alarmresource.h"
-#include "resources/alarmresources.h"
-
-#include <QAbstractListModel>
-#include <QSortFilterProxyModel>
-#include <QItemDelegate>
-#include <QListView>
-#include <QList>
-#include <QFont>
-
-using namespace KAlarmCal;
-
-class ResourceModel : public QAbstractListModel
-{
- Q_OBJECT
- public:
- static ResourceModel* instance(QObject* parent = 0);
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
- virtual QModelIndex index(int row, int column, const QModelIndex& parent) \
const;
- virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
- virtual bool setData(const QModelIndex&, const QVariant& value, int role \
= Qt::EditRole);
- virtual Qt::ItemFlags flags(const QModelIndex&) const;
- AlarmResource* resource(const QModelIndex&) const;
- void removeResource(AlarmResource*);
- void notifyChange(const QModelIndex&);
-
- private slots:
- void refresh();
- void addResource(AlarmResource*);
- void updateResource(AlarmResource*);
- void slotStandardChanged(CalEvent::Type);
- void slotLoaded(AlarmResource*, bool active);
- void slotStatusChanged(AlarmResource*, AlarmResources::Change);
-
- private:
- explicit ResourceModel(QObject* parent = 0);
-
- static ResourceModel* mInstance;
- QList<AlarmResource*> mResources;
- QString mErrorPrompt;
- QFont mFont;
-};
-
-
-class ResourceFilterModel : public QSortFilterProxyModel
-{
- Q_OBJECT
- public:
- ResourceFilterModel(QAbstractItemModel* baseModel, QObject* parent);
- void setFilter(CalEvent::Type);
- AlarmResource* resource(int row) const;
- AlarmResource* resource(const QModelIndex&) const;
- void notifyChange(int row);
- void notifyChange(const QModelIndex&);
-
- protected:
- virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& \
sourceParent) const;
-
- private:
- CalEvent::Type mResourceType;
-};
-
-
-class ResourceView : public QListView
-{
- Q_OBJECT
- public:
- explicit ResourceView(QWidget* parent = 0) : QListView(parent) {}
- virtual void setModel(QAbstractItemModel*);
- AlarmResource* resource(int row) const;
- AlarmResource* resource(const QModelIndex&) const;
- void notifyChange(int row) const;
- void notifyChange(const QModelIndex&) const;
-
- protected:
- virtual void mouseReleaseEvent(QMouseEvent*);
- virtual bool viewportEvent(QEvent*);
-};
-
-
-class ResourceDelegate : public QItemDelegate
-{
- Q_OBJECT
- public:
- explicit ResourceDelegate(ResourceView* parent = 0) : QItemDelegate(parent) \
{}
- virtual bool editorEvent(QEvent*, QAbstractItemModel*, const \
QStyleOptionViewItem&, const QModelIndex&);
-};
-
-#endif // RESOURCEMODELVIEW_H
-
-// vim: et sw=4:
diff --git a/kalarm/resources/CMakeLists.txt b/kalarm/resources/CMakeLists.txt
deleted file mode 100644
index 9b4bd85..0000000
--- a/kalarm/resources/CMakeLists.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-########### next target ###############
-set(kalarm_resources_LIB_SRCS
- alarmresource.cpp
- alarmresources.cpp
- resourcelocal.cpp
- resourcelocalwidget.cpp
- resourcelocaldir.cpp
- resourcelocaldirwidget.cpp
- resourceremote.cpp
- resourceremotewidget.cpp
- resourcewidget.cpp
-)
-
-
-kde4_add_library(kalarm_resources ${LIBRARY_TYPE} ${kalarm_resources_LIB_SRCS})
-
-target_link_libraries(kalarm_resources
- ${KDEPIMLIBS_KALARMCAL_LIBS}
- ${KDEPIMLIBS_KRESOURCES_LIBS}
- ${KDEPIMLIBS_KABC_LIBS}
- ${KDEPIMLIBS_KCAL_LIBS}
- ${KDE4_KIO_LIBS}
- )
-target_link_libraries(kalarm_resources LINK_INTERFACE_LIBRARIES
- ${KDEPIMLIBS_KALARMCAL_LIBS}
- ${KDEPIMLIBS_KRESOURCES_LIBS}
- ${KDEPIMLIBS_KABC_LIBS}
- ${KDEPIMLIBS_KCAL_LIBS}
- ${KDE4_KIO_LIBS}
- )
-
-set_target_properties(kalarm_resources PROPERTIES
- VERSION ${KDEPIM_LIB_VERSION}
- SOVERSION ${KDEPIM_LIB_SOVERSION}
-)
-install(TARGETS kalarm_resources ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY \
NAMELINK_SKIP)
-
-install(FILES kalarm_manager.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kresources)
-
-
-########### next target ###############
-
-set(kalarm_local_PART_SRCS resourcelocal_plugin.cpp)
-
-
-kde4_add_plugin(kalarm_local ${kalarm_local_PART_SRCS})
-
-target_link_libraries(kalarm_local kalarm_resources ${KDEPIMLIBS_KCAL_LIBS} \
${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
-
-install(TARGETS kalarm_local DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES local.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kresources/alarms)
-
-########### next target ###############
-
-set(kalarm_localdir_PART_SRCS resourcelocaldir_plugin.cpp)
-
-
-kde4_add_plugin(kalarm_localdir ${kalarm_localdir_PART_SRCS})
-
-target_link_libraries(kalarm_localdir kalarm_resources ${KDEPIMLIBS_KCAL_LIBS} \
${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
-
-install(TARGETS kalarm_localdir DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES localdir.desktop DESTINATION \
${SERVICES_INSTALL_DIR}/kresources/alarms)
-
-########### next target ###############
-
-set(kalarm_remote_PART_SRCS resourceremote_plugin.cpp)
-
-
-kde4_add_plugin(kalarm_remote ${kalarm_remote_PART_SRCS})
-
-target_link_libraries(kalarm_remote kalarm_resources ${KDEPIMLIBS_KCAL_LIBS} \
${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY})
-
-install(TARGETS kalarm_remote DESTINATION ${PLUGIN_INSTALL_DIR})
-
-install(FILES remote.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kresources/alarms)
-
diff --git a/kalarm/resources/alarmresource.cpp b/kalarm/resources/alarmresource.cpp
deleted file mode 100644
index 898bff5..0000000
--- a/kalarm/resources/alarmresource.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * alarmresource.cpp - base class for a KAlarm alarm calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "alarmresource.moc"
-using namespace KCal;
-#include "alarmresources.h"
-
-#include <KABC/lock.h>
-#include <KABC/locknull.h>
-#include <kcal/calendarlocal.h>
-
-#include <kconfig.h>
-#include <kconfiggroup.h>
-#include <klocale.h>
-#include <kstandarddirs.h>
-
-
-
-void (*AlarmResource::mCalIDFunction)(CalendarLocal&) = 0;
-void (*AlarmResource::mCustomEventFunction)(AlarmResource*, \
CalendarLocal*) = 0;
-KACalendar::Compat (*AlarmResource::mFixFunction)(CalendarLocal&, const QString&, \
AlarmResource*, AlarmResource::FixFunc, bool* wrongType) = 0;
-int AlarmResource::mDebugArea = 0;
-bool AlarmResource::mNoGui = false;
-
-
-AlarmResource::AlarmResource()
- : ResourceCached(),
- mLock(0),
- mType(static_cast<CalEvent::Type>(0)), // invalid
- mStandard(false),
- mCloseAfterSave(false),
- mWrongAlarmType(false),
- mCompatibility(KACalendar::Incompatible),
- mReconfiguring(0),
- mLoaded(false),
- mLoading(false)
-{
- // Prevent individual events being set read-only when loading a read-only \
resource
- setNoReadOnlyOnLoad(true);
- init();
-}
-
-AlarmResource::AlarmResource(const KConfigGroup& group)
- : ResourceCached(group),
- mLock(0),
- mType(static_cast<CalEvent::Type>(0)), // invalid
- mStandard(false),
- mCloseAfterSave(false),
- mWrongAlarmType(false),
- mCompatibility(KACalendar::Incompatible),
- mReconfiguring(0),
- mLoaded(false),
- mLoading(false)
-{
- // Prevent individual events being set read-only when loading a read-only \
resource
- setNoReadOnlyOnLoad(true);
-
- ResourceCached::readConfig(group);
- int type = group.readEntry("AlarmType", static_cast<int>(CalEvent::ACTIVE));
- switch (type)
- {
- case CalEvent::ACTIVE:
- case CalEvent::ARCHIVED:
- case CalEvent::TEMPLATE:
- mType = static_cast<CalEvent::Type>(type);
- mStandard = group.readEntry("Standard", true);
- break;
- default:
- break;
- }
- mColour = group.readEntry("Color", QColor());
- init();
-}
-
-AlarmResource::AlarmResource(CalEvent::Type type)
- : ResourceCached(),
- mLock(0),
- mType(type),
- mStandard(false),
- mCloseAfterSave(false),
- mCompatibility(KACalendar::Incompatible),
- mReconfiguring(0),
- mLoaded(false),
- mLoading(false)
-{
- init();
-}
-
-void AlarmResource::init()
-{
- enableChangeNotification();
- if (mType == CalEvent::ARCHIVED)
- {
- // Prevent unnecessary multiple saves of archived alarm resources.
- // When multiple alarms are deleted as a group, the archive
- // resource would be saved once for each alarm. Ironically, setting
- // the resource to be automatically saved will prevent this, since
- // automatic saving delays for a second after each change before
- // actually saving the resource, thereby ensuring that they are
- // saved as a group.
- setSavePolicy(SaveAlways);
- }
-}
-
-AlarmResource::~AlarmResource()
-{
- delete mLock;
-}
-
-void AlarmResource::writeConfig(KConfigGroup& group)
-{
- group.writeEntry("AlarmType", static_cast<int>(mType));
- if (mColour.isValid())
- group.writeEntry("Color", mColour);
- else
- group.deleteEntry("Color");
- group.writeEntry("Standard", mStandard);
- ResourceCached::writeConfig(group);
- ResourceCalendar::writeConfig(group);
-}
-
-void AlarmResource::startReconfig()
-{
- mOldReadOnly = ResourceCached::readOnly();
- mNewReadOnly = mOldReadOnly;
- mReconfiguring = 1;
-}
-
-void AlarmResource::applyReconfig()
-{
- if (!mReconfiguring)
- return;
- if (mReconfiguring == 1)
- {
- // Called before derived classes do their stuff
- ResourceCached::setReadOnly(mNewReadOnly);
- mReconfiguring = 2;
- }
- else
- {
- // Called when derived classes have done their stuff
- setReadOnly(mNewReadOnly);
- mReconfiguring = 0;
- }
-}
-
-/******************************************************************************
-* If a function is defined to convert alarms to the current format, call it.
-* Set the resource to read-only if it isn't the current format version, or if
-* its format is unknown.
-*/
-void AlarmResource::checkCompatibility(const QString& filename)
-{
- bool wrongType = false;
- bool oldReadOnly = readOnly();
- mCompatibility = KACalendar::Incompatible; // assume the worst
- if (mFixFunction)
- {
- // Check whether the version is compatible (and convert it if desired)
- mCompatibility = (*mFixFunction)(*calendar(), filename, this, PROMPT, \
&wrongType);
- if (wrongType)
- kDebug(KARES_DEBUG) << resourceName() << ": contains wrong alarm \
type(s)";
- if (mCompatibility == KACalendar::Converted)
- {
- // Set mCompatibility first to ensure that readOnly() returns
- // the correct value and that save() therefore works.
- mCompatibility = KACalendar::Current;
- save();
- }
- if (mCompatibility != KACalendar::Current && mCompatibility != \
KACalendar::ByEvent)
- {
- // It's not in the current KAlarm format, so it will be read-only to \
prevent incompatible updates
- kDebug(KARES_DEBUG) << resourceName() << ": opened read-only (not \
current KAlarm format)";
- }
- }
- setWrongAlarmType(wrongType);
- if (readOnly() != oldReadOnly)
- emit readOnlyChanged(this); // the effective read-only status has changed
-}
-
-/******************************************************************************
-* If a function is defined to convert alarms to the current format, call it to
-* convert an individual file within the overall resource.
-*/
-KACalendar::Compat AlarmResource::checkCompatibility(CalendarLocal& calendar, const \
QString& filename, FixFunc conv, bool* wrongType)
-{
- if (wrongType)
- *wrongType = false;
- KACalendar::Compat compat = KACalendar::Incompatible; // assume the worst
- if (mFixFunction)
- {
- // Check whether the version is compatible (and convert it if desired)
- compat = (*mFixFunction)(calendar, filename, this, conv, wrongType);
- if (compat == KACalendar::Converted)
- calendar.save(filename);
- }
- return compat;
-}
-
-KACalendar::Compat AlarmResource::compatibility(const Event* event) const
-{
- if (mCompatibility != KACalendar::ByEvent)
- return mCompatibility;
- CompatibilityMap::ConstIterator it = mCompatibilityMap.find(event);
- if (it == mCompatibilityMap.constEnd())
- return KACalendar::Incompatible; // event not found!?! - assume the worst
- return it.value();
-}
-
-/******************************************************************************
-* Set whether the resource contains only the wrong alarm types.
-* If the wrong types, disable the resource.
-*/
-void AlarmResource::setWrongAlarmType(bool wrongType, bool emitSignal)
-{
- if (wrongType != mWrongAlarmType)
- {
- mWrongAlarmType = wrongType;
- if (emitSignal)
- emit wrongAlarmTypeChanged(this);
- if (mWrongAlarmType)
- setEnabled(false);
- }
-}
-
-/******************************************************************************
-* If a function is defined to update KAlarm event instances, call it.
-*/
-void AlarmResource::updateCustomEvents(bool useCalendar)
-{
- if (mCustomEventFunction && isEnabled())
- (*mCustomEventFunction)(this, useCalendar ? calendar() : 0);
-}
-
-bool AlarmResource::writable(const Event* event) const
-{
- return isActive() && !KCal::ResourceCached::readOnly()
- && compatibility(event) == KACalendar::Current;
-}
-
-bool AlarmResource::readOnly() const
-{
- return KCal::ResourceCached::readOnly()
- || (isActive() && mCompatibility != KACalendar::Current && mCompatibility \
!= KACalendar::ByEvent);
-}
-
-void AlarmResource::setReadOnly(bool ronly)
-{
- if (mReconfiguring == 1)
- {
- mNewReadOnly = ronly;
- return;
- }
- kDebug(KARES_DEBUG) << ronly;
- bool oldRCronly = (mReconfiguring == 2) ? mOldReadOnly : \
ResourceCached::readOnly();
- bool oldronly = (oldRCronly || (mCompatibility != KACalendar::Current && \
mCompatibility != KACalendar::ByEvent));
- if (!ronly && isActive())
- {
- // Trying to change the resource to read-write.
- // Only allow this if it is in, or can be converted to, the current KAlarm \
format.
- switch (mCompatibility)
- {
- case KACalendar::Incompatible:
- emit notWritable(this); // allow an error message to be output
- return;
- case KACalendar::Convertible:
- if (mReconfiguring <= 2)
- {
- if (!isOpen())
- return;
- load(NoSyncCache); // give user the option of converting it
- }
- if (mCompatibility != KACalendar::Current)
- return; // not converted, so keep as read-only
- break;
- case KACalendar::Current:
- case KACalendar::ByEvent:
- case KACalendar::Converted: // shouldn't ever happen
- break;
- }
- }
- if (ronly != oldRCronly)
- ResourceCached::setReadOnly(ronly);
- if ((ronly || (mCompatibility != KACalendar::Current && mCompatibility != \
KACalendar::ByEvent)) != oldronly)
- emit readOnlyChanged(this); // the effective read-only status has changed
-}
-
-void AlarmResource::setEnabled(bool enable)
-{
- if (mWrongAlarmType)
- enable = false;
- if (isActive() != enable)
- {
- setActive(enable);
- enableResource(enable);
- emit enabledChanged(this);
- }
-}
-
-void AlarmResource::setColour(const QColor& colour)
-{
- if (colour != mColour)
- {
- mColour = colour;
- emit colourChanged(this);
- }
-}
-
-bool AlarmResource::saveAndClose(CacheAction action, Incidence* incidence)
-{
- bool result = save(action, incidence);
- if (isSaving())
- mCloseAfterSave = true; // ensure it's closed if saving is asynchronous
- else
- close();
- return result;
-}
-
-void AlarmResource::doClose()
-{
- mCloseAfterSave = false;
- emit invalidate(this);
- KCal::ResourceCached::doClose();
- mLoaded = mLoading = false;
- mCompatibilityMap.clear();
-}
-
-QString AlarmResource::infoText() const
-{
- KRES::Factory* factory = KRES::Factory::self("alarms");
- QString atype;
- switch (mType)
- {
- case CalEvent::ACTIVE: atype = i18nc("@info/plain", "Active alarms"); \
break;
- case CalEvent::ARCHIVED: atype = i18nc("@info/plain", "Archived alarms"); \
break;
- case CalEvent::TEMPLATE: atype = i18nc("@info/plain", "Alarm templates"); \
break;
- default: break;
- }
- QString perms = readOnly() ? i18nc("@info/plain", "Read-only") : \
i18nc("@info/plain", "Read-write");
- QString enabled = isEnabled() ? i18nc("@info/plain", "Enabled") : \
mWrongAlarmType ? i18nc("@info/plain", "Disabled (wrong alarm type)") : \
i18nc("@info/plain", "Disabled");
- QString std = (AlarmResources::instance()->getStandardResource(mType) == this) ? \
i18nc("@info/plain Parameter in 'Default calendar: Yes/No'", "Yes") : \
i18nc("@info/plain Parameter in 'Default calendar: Yes/No'", "No");
- return i18nc("@info",
- "<title>%1</title>"
- "<para>Calendar type: %2<nl/>"
- "Contents: %3<nl/>"
- "%4: <filename>%5</filename><nl/>"
- "Permissions: %6<nl/>"
- "Status: %7<nl/>"
- "Default calendar: %8</para>",
- resourceName(), factory->typeName(type()), atype, displayType(), \
displayLocation(), perms, enabled, std);
-}
-
-void AlarmResource::lock(const QString& path)
-{
- delete mLock;
- if (path.isNull())
- mLock = 0;
- else if (path.isEmpty())
- mLock = new KABC::LockNull(true);
- else
- mLock = new KABC::Lock(path);
-}
-
-/******************************************************************************
-* Check whether the alarm types in a calendar correspond with the resource's
-* alarm type.
-* Reply = true if at least 1 alarm is the right type.
-*/
-bool AlarmResource::checkAlarmTypes(KCal::CalendarLocal& calendar) const
-{
- if (mType != CalEvent::EMPTY)
- {
- bool have = false;
- bool other = false;
- const Event::List events = calendar.rawEvents();
- for (int i = 0, iend = events.count(); i < iend; ++i)
- {
- CalEvent::Type s = CalEvent::status(events[i]);
- if (mType == s)
- have = true;
- else
- other = true;
- if (have && other)
- break;
- }
- if (!have && other)
- return false; // contains only wrong alarm types
- }
- return true;
-}
-
-/*
-void AlarmResource::kaCheckCalendar(CalendarLocal& cal)
-{
- mTypes = CalEvent::EMPTY;
- Event::List events = cal.rawEvents();
- for (int i = 0, iend = events.count(); i < iend; ++i)
- {
- switch (CalEvent::status(events[i]))
- {
- case CalEvent::ACTIVE: mTypes = static_cast<CalEvent::Type>(mTypes | \
CalEvent::ACTIVE); break;
- case CalEvent::ARCHIVED: mTypes = static_cast<CalEvent::Type>(mTypes | \
CalEvent::ARCHIVED); break;
- case CalEvent::TEMPLATE: mTypes = static_cast<CalEvent::Type>(mTypes | \
CalEvent::TEMPLATE); break;
- default: break;
- }
- if (mTypes == CalEvent::ALL)
- break;
- }
-}
-*/
-
-#ifndef NDEBUG
-QByteArray AlarmResource::typeName() const
-{
- switch (mType)
- {
- case CalEvent::ACTIVE: return "Active";
- case CalEvent::ARCHIVED: return "Archived";
- case CalEvent::TEMPLATE: return "Template";
- default: return "Empty";
- }
-}
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/alarmresource.h b/kalarm/resources/alarmresource.h
deleted file mode 100644
index e44462f..0000000
--- a/kalarm/resources/alarmresource.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * alarmresource.h - base class for a KAlarm alarm calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef ALARMRESOURCE_H
-#define ALARMRESOURCE_H
-
-/* @file alarmresource.h - base class for a KAlarm alarm calendar resource */
-
-#include "kalarm_resources_export.h"
-
-#include <KAlarmCal/kacalendar.h>
-
-#include <kcal/resourcecached.h>
-#include <QMap>
-#include <QByteArray>
-
-#include <sys/stat.h>
-
-using KCal::CalendarLocal;
-using namespace KAlarmCal;
-
-
-#define KARES_DEBUG AlarmResource::debugArea()
-
-
-/** Base class for a KAlarm alarm calendar resource. */
-class KALARM_RESOURCES_EXPORT AlarmResource : public KCal::ResourceCached
-{
- Q_OBJECT
- public:
- /** Whether the fix function should convert old format KAlarm calendars. */
- enum FixFunc { PROMPT, PROMPT_PART, CONVERT, NO_CONVERT };
-
- AlarmResource();
- explicit AlarmResource(const KConfigGroup&);
- explicit AlarmResource(CalEvent::Type);
- ~AlarmResource();
- virtual void writeConfig(KConfigGroup&);
- virtual QString infoText() const;
- KABC::Lock* lock() { return mLock; }
-
- /** Return which type of alarms the resource can contain. */
- CalEvent::Type alarmType() const { return mType; }
-
- /** Set the type of alarms which the resource can contain. */
- void setAlarmType(CalEvent::Type type) { mType = type; }
-
- /** Return whether the resource contains only alarms of the wrong type. */
- bool isWrongAlarmType() const { return mWrongAlarmType; }
-
- /** Check whether the alarm types in a calendar correspond with
- * the resource's alarm type.
- * Reply = true if at least 1 alarm is the right type.
- */
- bool checkAlarmTypes(KCal::CalendarLocal&) const;
-
- /** Set whether the application has a GUI. This determines whether error or
- * progress messages are displayed. */
- static void setNoGui(bool noGui) { mNoGui = noGui; }
- static bool hasGui() { return !mNoGui; }
-
- /** Return the location(s) of the resource (URL, file path, etc.) */
- virtual QStringList location() const = 0;
-
- /** Return the type of the resource (URL, file, etc.)
- * for display purposes. */
- virtual QString displayType() const = 0;
-
- /** Return the location of the resource (URL, file path, etc.)
- * for display purposes. */
- virtual QString displayLocation() const = 0;
-
- /** Change the resource's location. The resource will be reloaded if active. \
*/
- virtual bool setLocation(const QString& locn, const QString& locn2 = \
QString()) = 0;
- /** Return whether the resource is the standard resource for its alarm type. \
*/
- bool standardResource() const { return mStandard; }
-
- /** Set or clear the resource as the standard resource for its alarm type. \
*/
- void setStandardResource(bool std) { mStandard = std; }
-
- void setEnabled(bool enable);
- bool isEnabled() const { return !mWrongAlarmType && \
isActive(); }
-
- /** Return whether the resource can be written to now,
- * i.e. it's active, read-write and in the current KAlarm format. */
- bool writable() const { return isEnabled() && \
!readOnly(); }
-
- /** Return whether the event can be written to now, i.e. the resource is
- * active and read-write, and the event is in the current KAlarm format. */
- bool writable(const KCal::Event*) const;
-
- /** Return whether the resource is cached, i.e. whether it is downloaded
- * and stored locally in a cache file. */
- virtual bool cached() const { return false; }
-
- /** Return whether the resource is read-only, either because it's marked as
- * read-only, or because it's active but not in the current KAlarm format. \
*/
- virtual bool readOnly() const;
- virtual void setReadOnly(bool);
-
- /** Return the colour used to display alarms belonging to this resource.
- * @return display colour, or invalid if none specified */
- QColor colour() const { return mColour; }
-
- /** Set the colour used to display alarms belonging to this resource.
- * @param color display colour, or invalid to use the default colour */
- void setColour(const QColor& color);
- /** Start a batch of configuration changes.
- * The changes will be stored up until applyReconfig() is called. */
- virtual void startReconfig();
-
- /** Apply the batch of configuration changes since startReconfig() was \
called. */
- virtual void applyReconfig();
-
- /** Load the resource.
- * If it's a cached resource, load() uses the default action to either \
refresh
- * the cache file first or not.
- * If loading succeeds, the loaded() signal is emitted on completion (but \
is
- * not emitted if false is returned). This allows AlarmResources to process
- * the load.
- * Loading is not performed if the resource is disabled.
- * @return true if loading succeeded at least partially, false if it failed
- * completely
- */
- bool load(CacheAction a) { return KCal::ResourceCached::load(a); }
-
- /** Return whether the resource has fully loaded. */
- bool isLoaded() const { return mLoaded; }
-
- /** Return whether the resource is in the process of loading. */
- bool isLoading() const { return mLoading; }
-
- /** Save the resource and then close it.
- * It will be closed even if saving fails. */
- bool saveAndClose(CacheAction, KCal::Incidence* = 0);
- bool saveAndClose(KCal::Incidence* incidence = 0) { return \
saveAndClose(DefaultCache, incidence); }
-
- /** Set a function to write the application ID into a calendar. */
- static void setCalIDFunction(void (*f)(CalendarLocal&)) { mCalIDFunction \
= f; }
- /** Set a function to create KAlarm event instances.
- * When the function is called, the CalendarLocal parameter is
- * set to null to indicate that the resource is about to be reloaded. */
- static void setCustomEventFunction(void (*f)(AlarmResource*, \
CalendarLocal*)) { mCustomEventFunction = f; }
- /** Set a function to fix the calendar once it has been loaded. */
- static void setFixFunction(KACalendar::Compat (*f)(CalendarLocal&, const \
QString&, AlarmResource*, FixFunc, bool* wrongType))
- { mFixFunction = f; }
- /** Return whether the resource is in a different format from the
- * current KAlarm format, in which case it cannot be written to.
- * Note that readOnly() takes account of both incompatible() and
- * KCal::ResourceCached::readOnly().
- */
- KACalendar::Compat compatibility() const { return mCompatibility; }
- KACalendar::Compat compatibility(const KCal::Event*) const;
-
- virtual void showProgress(bool) {}
-
- static int debugArea() { return mDebugArea; }
- static void setDebugArea(int area) { mDebugArea = area; }
-
-#ifndef NDEBUG
- QByteArray typeName() const;
-#endif
-
- public slots:
- virtual void cancelDownload(bool /*disable*/ = false) {}
-
- signals:
- /** Signal that the resource is about to close or reload.
- * This signal warns that all events are about to be deleted. */
- void invalidate(AlarmResource*);
- /** Signal that loading of the resource has completed, whether
- * successfully or not.
- * This signal is always emitted after a resource is loaded. */
- void loaded(AlarmResource*);
- /** Emitted after attempting to save the resource, whether successfully or \
not.
- * Not emitted if no attempt was made to save it (e.g. if the resource
- * is closed or read-only or there is nothing to save, or if save()
- * returned false).
- */
- void resourceSaved(AlarmResource*);
- /** Emitted during download for remote resources. */
- void downloading(AlarmResource*, unsigned long percent);
- /** Signal that a remote resource download has completed, and the cache file \
has been updated. */
- void cacheDownloaded(AlarmResource*);
- /** Signal that the resource's read-only status has changed. */
- void readOnlyChanged(AlarmResource*);
- /** Signal that the resource's wrong alarm type status has changed. */
- void wrongAlarmTypeChanged(AlarmResource*);
- /** Signal that the resource's active status has changed. */
- void enabledChanged(AlarmResource*);
- /** Signal that the resource's location has changed. */
- void locationChanged(AlarmResource*);
- /** Signal that the resource cannot be set read-write since its format is \
incompatible. */
- void notWritable(AlarmResource*);
- /** Signal that the display colour has changed. */
- void colourChanged(AlarmResource*);
-
- protected:
- virtual void doClose();
- bool closeAfterSave() const { return mCloseAfterSave; }
- void setCompatibility(KACalendar::Compat c) { mCompatibility \
= c; }
- void checkCompatibility(const QString&);
- KACalendar::Compat checkCompatibility(KCal::CalendarLocal&, const QString& \
filename, FixFunc, bool* wrongType = 0);
- void setWrongAlarmType(bool wrongType, bool emitSignal = true);
- void updateCustomEvents(bool useCalendar = true);
- virtual void enableResource(bool enable) = 0;
- void lock(const QString& path);
-
- static void (*mCalIDFunction)(CalendarLocal&);
- static KACalendar::Compat (*mFixFunction)(CalendarLocal&, const QString&, \
AlarmResource*, FixFunc, bool* wrongType);
-
- private:
- void init();
-
- static int mDebugArea; // area for kDebug() output
- static bool mNoGui; // application has no GUI, so don't display \
messages
- static void (*mCustomEventFunction)(AlarmResource*, \
CalendarLocal*);
-
- KABC::Lock* mLock;
- CalEvent::Type mType; // type of alarm held in this resource
- QColor mColour; // background colour for displaying this \
resource
- bool mStandard; // this is the standard resource for this \
mWriteType
- bool mNewReadOnly; // new read-only status (while mReconfiguring \
= 1)
- bool mOldReadOnly; // old read-only status (when startReconfig() \
called)
- bool mCloseAfterSave; // resource is to be closed once save() is \
complete
- bool mWrongAlarmType; // calendar contains only alarms of the wrong \
type
- KACalendar::Compat mCompatibility; // whether resource is in compatible \
format
-
- protected:
- typedef QMap<const KCal::Event*, KACalendar::Compat> CompatibilityMap;
- CompatibilityMap mCompatibilityMap; // whether individual events are in \
compatible format
- short mReconfiguring; // a batch of config changes is in progress
- bool mLoaded; // true if resource has finished loading
- bool mLoading; // true if resource is currently loading
-
- private:
- using KCal::ResourceCached::load; // prevent "hidden" warning
-};
-
-typedef KRES::Manager<AlarmResource> AlarmResourceManager;
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/alarmresources.cpp \
b/kalarm/resources/alarmresources.cpp deleted file mode 100644
index a38c041..0000000
--- a/kalarm/resources/alarmresources.cpp
+++ /dev/null
@@ -1,828 +0,0 @@
-/*
- * alarmresources.cpp - alarm calendar resources
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "alarmresource.h"
-#include "resourcelocal.h"
-#include "resourceremote.h"
-#include "alarmresources.moc"
-
-#include <KAlarmCal/kacalendar.h>
-
-#include <kresources/selectdialog.h>
-#include <kcal/calformat.h>
-#include <kcal/event.h>
-
-#include <kconfiggroup.h>
-#include <kstandarddirs.h>
-#include <klocale.h>
-#include <kapplication.h>
-#include <kurl.h>
-#include <kdebug.h>
-
-using namespace KCal;
-using namespace KAlarmCal;
-
-AlarmResources* AlarmResources::mInstance = 0;
-QString AlarmResources::mReservedFile;
-QString AlarmResources::mConstructionError;
-
-AlarmResources* AlarmResources::create(const KDateTime::Spec& timeSpec, bool \
activeOnly, bool passiveClient)
-{
- if (!mInstance)
- {
- AlarmResources* cal = new AlarmResources(timeSpec, activeOnly, \
passiveClient);
- if (!mConstructionError.isEmpty())
- delete cal;
- else
- mInstance = cal;
- }
- return mInstance;
-}
-
-AlarmResources::AlarmResources(const KDateTime::Spec& timeSpec, bool activeOnly, \
bool passiveClient)
- : Calendar(timeSpec),
- mActiveOnly(activeOnly),
- mPassiveClient(passiveClient),
- mNoGui(false),
- mAskDestination(false),
- mShowProgress(false),
- mOpen(false),
- mClosing(false)
-{
- mManager = new AlarmResourceManager(QString::fromLatin1("alarms"));
- mManager->addObserver(this);
- mAskDestination = true; // prompt the user for a resource every time an alarm \
is saved
-
- mManager->readConfig(0);
- for (AlarmResourceManager::Iterator it = mManager->begin(); it != \
mManager->end(); ++it)
- {
- if (!mActiveOnly || (*it)->alarmType() == CalEvent::ACTIVE)
- connectResource(*it);
- }
-
- if (!mPassiveClient && mManager->isEmpty())
- {
- KConfigGroup config(KGlobal::config(), "General");
- AlarmResource* resource;
- resource = addDefaultResource(config, CalEvent::ACTIVE);
- setStandardResource(resource);
- if (!mActiveOnly)
- {
- resource = addDefaultResource(config, CalEvent::ARCHIVED);
- setStandardResource(resource);
- resource = addDefaultResource(config, CalEvent::TEMPLATE);
- setStandardResource(resource);
- }
-
-#ifndef NDEBUG
- kDebug(KARES_DEBUG) << "AlarmResources used:";
- for (AlarmResourceManager::Iterator it = mManager->begin(); it != \
mManager->end(); ++it)
- kDebug(KARES_DEBUG) << (*it)->resourceName();
-#endif
- }
-}
-
-AlarmResources::~AlarmResources()
-{
- kDebug(KARES_DEBUG);
- close();
- delete mManager;
- mManager = 0;
- mInstance = 0;
-}
-
-void AlarmResources::setNoGui(bool noGui)
-{
- mNoGui = noGui;
- if (mNoGui)
- mShowProgress = false;
- AlarmResource::setNoGui(mNoGui);
-}
-
-AlarmResource* AlarmResources::addDefaultResource(CalEvent::Type type)
-{
- KConfigGroup config(KGlobal::config(), "General");
- return addDefaultResource(config, type);
-}
-
-AlarmResource* AlarmResources::addDefaultResource(const KConfigGroup& config, \
CalEvent::Type type)
-{
- QString configKey, defaultFile, title;
- switch (type)
- {
- case CalEvent::ACTIVE:
- configKey = QString::fromLatin1("Calendar");
- defaultFile = QString::fromLatin1("calendar.ics");
- title = i18nc("@info/plain", "Active Alarms");
- break;
- case CalEvent::TEMPLATE:
- configKey = QString::fromLatin1("TemplateCalendar");
- defaultFile = QString::fromLatin1("template.ics");
- title = i18nc("@info/plain", "Alarm Templates");
- break;
- case CalEvent::ARCHIVED:
- configKey = QString::fromLatin1("ExpiredCalendar");
- defaultFile = QString::fromLatin1("expired.ics");
- title = i18nc("@info/plain", "Archived Alarms");
- break;
- default:
- return 0;
- }
- AlarmResource* resource = 0;
- QString fileName = config.readPathEntry(configKey, QString());
- if (!fileName.isEmpty())
- {
- // Calendar is specified in KAlarm config file
- KUrl url(fileName);
- if (!url.isValid())
- {
- kError(KARES_DEBUG) << configKey << ": invalid name:" << fileName;
- mConstructionError = i18nc("@info", "%1: invalid calendar file name: \
<filename>%2</filename>", configKey, fileName);
- return 0;
- }
- if (!url.isLocalFile())
- resource = new KAResourceRemote(type, url);
- else if (fileName == mReservedFile)
- {
- kError(KARES_DEBUG) << configKey << ": name not allowed:" << fileName;
- mConstructionError = i18nc("@info", "%1: file name not permitted: \
<filename>%2</filename>", configKey, fileName);
- return 0;
- }
- else
- resource = new KAResourceLocal(type, url.toLocalFile());
- }
- if (!resource)
- {
- // No calendar is specified in config file, or the calendar
- // specified is invalid - use default file
- fileName = KStandardDirs::locateLocal("appdata", defaultFile);
- resource = new KAResourceLocal(type, fileName);
- }
-
- resource->setTimeSpec(timeSpec());
- resource->setResourceName(title);
- resourceManager()->add(resource);
- connectResource(resource);
- return resource;
-}
-
-AlarmResources::Result AlarmResources::addEvent(Event* event, CalEvent::Type type, \
QWidget* promptParent, bool noPrompt)
-{
- kDebug(KARES_DEBUG) << event->uid();
- bool cancelled;
- AlarmResource* resource = destination(type, promptParent, noPrompt, &cancelled);
- if (!resource)
- {
- delete event;
- if (cancelled)
- return Cancelled;
- kDebug(KARES_DEBUG) << "No resource";
- return Failed;
- }
- if (!addEvent(event, resource))
- {
- kDebug(KARES_DEBUG) << "Failed";
- return Failed; // event was deleted by addEvent()
- }
- return Success;
-}
-
-AlarmResource* AlarmResources::getStandardResource(CalEvent::Type type)
-{
- switch (type)
- {
- case CalEvent::ACTIVE:
- {
- AlarmResource* std = mManager->standardResource();
- if (std && std->standardResource() && std->alarmType() == \
CalEvent::ACTIVE && !std->readOnly())
- return std;
- break;
- }
- case CalEvent::ARCHIVED:
- case CalEvent::TEMPLATE:
- if (mActiveOnly)
- return 0;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); \
it != mManager->activeEnd(); ++it)
- {
- AlarmResource* r = *it;
- if (r->alarmType() == type && r->standardResource())
- return r;
- }
- break;
- default:
- return 0;
- }
-
- // There's no nominated default alarm resource of the right type.
- // If there's only one read/write alarm resource, use it.
- AlarmResource* std = 0;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- AlarmResource* r = *it;
- if (!r->readOnly() && r->alarmType() == type)
- {
- if (std)
- return 0; // there's more than one candidate
- std = r;
- }
- }
- if (std && type == CalEvent::ACTIVE && !mPassiveClient)
- setStandardResource(std); // mark it as the standard resource
- return std;
-}
-
-void AlarmResources::setStandardResource(AlarmResource* resource)
-{
- if (resource->standardResource())
- return; // it's already the standard resource for its alarm type
- CalEvent::Type type = resource->alarmType();
- bool active = (type == CalEvent::ACTIVE);
- for (AlarmResourceManager::Iterator it = mManager->begin(); it != \
mManager->end(); ++it)
- {
- AlarmResource* r = *it;
- if (r->alarmType() == type && r->standardResource())
- {
- r->setStandardResource(false);
- if (!active && !mPassiveClient)
- mManager->change(r); // save resource's new configuration
- }
- }
- resource->setStandardResource(true);
- if (active)
- {
- mManager->setStandardResource(resource);
- if (!mPassiveClient)
- mManager->writeConfig();
- }
- else if (!mPassiveClient)
- mManager->change(resource); // save resource's new configuration
- emit standardResourceChange(type);
-}
-
-void AlarmResources::writeConfig()
-{
- if (!mPassiveClient)
- mManager->writeConfig();
-}
-
-int AlarmResources::activeCount(CalEvent::Type type, bool writable)
-{
- int count = 0;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- AlarmResource* resource = *it;
- if (resource->alarmType() == type
- && (!writable || !resource->readOnly()))
- ++count;
- }
- return count;
-}
-
-AlarmResource* AlarmResources::destination(Incidence* incidence, QWidget* \
promptParent, bool* cancelled)
-{
- Event* event = dynamic_cast<Event*>(incidence);
- CalEvent::Type type = event ? CalEvent::status(event) : CalEvent::ACTIVE;
- return destination(type, promptParent, false, cancelled);
-}
-
-AlarmResource* AlarmResources::destination(CalEvent::Type type, QWidget* \
promptParent, bool noPrompt, bool* cancelled)
-{
- if (cancelled)
- *cancelled = false;
- AlarmResource* standard;
- switch (type)
- {
- case CalEvent::ACTIVE:
- break;
- case CalEvent::TEMPLATE:
- if (mActiveOnly)
- return 0;
- break;
- case CalEvent::ARCHIVED:
- if (mActiveOnly)
- return 0;
- // Archived alarms are always saved in the default resource
- return getStandardResource(CalEvent::ARCHIVED);
- default:
- return 0;
- }
- standard = getStandardResource(type);
- if (noPrompt || (!mAskDestination && standard))
- return standard;
- QList<KRES::Resource*> list;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- AlarmResource* resource = *it;
- if (!resource->readOnly() && resource->alarmType() == type)
- {
- // Insert the standard resource at the beginning so as to be the default
- if (resource == standard)
- list.insert(0, resource);
- else
- list.append(resource);
- }
- }
- switch (list.count())
- {
- case 0:
- return 0;
- case 1:
-// return static_cast<AlarmResource*>(list.first());
- default:
- {
- KRES::Resource* r = KRES::SelectDialog::getResource(list, promptParent);
- if (!r && cancelled)
- *cancelled = true;
- return static_cast<AlarmResource*>(r);
- }
- }
-}
-
-int AlarmResources::loadedState(CalEvent::Type type) const
-{
- if (!mOpen)
- return 0;
- bool loaded = false;
- bool notloaded = false;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- AlarmResource* res = *it;
- if (res->alarmType() == type)
- {
- if (res->isLoaded())
- {
- if (notloaded)
- return 1; // some loaded, some not loaded
- loaded = true;
- }
- else
- {
- if (loaded)
- return 1; // some loaded, some not loaded
- notloaded = true;
- }
- }
- }
- return !loaded ? 0 : notloaded ? 1 : 2;
-}
-
-bool AlarmResources::isLoading(CalEvent::Type type) const
-{
- if (mOpen)
- {
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it \
!= mManager->activeEnd(); ++it)
- {
- AlarmResource* res = *it;
- if (res->alarmType() == type && res->isLoading())
- return true;
- }
- }
- return false;
-}
-
-void AlarmResources::load(ResourceCached::CacheAction action)
-{
- kDebug(KARES_DEBUG);
- if (!mManager->standardResource())
- kDebug(KARES_DEBUG) << "Warning! No standard resource yet.";
-
- // Set the timezone for all resources. Otherwise we'll have those terrible tz \
troubles ;-((
- // Open all active resources
- QList<AlarmResource*> failed;
- for (AlarmResourceManager::Iterator it = mManager->begin(); it != \
mManager->end(); ++it)
- {
- AlarmResource* resource = *it;
- if (!mActiveOnly || resource->alarmType() == CalEvent::ACTIVE)
- {
- resource->setTimeSpec(timeSpec());
- if (resource->isActive())
- {
- if (!load(resource, action))
- failed.append(resource);
- }
- }
- }
- for (int i = 0, end = failed.count(); i < end; ++i)
- {
- failed[i]->setActive(false);
- emit signalResourceModified(failed[i]);
- }
-
- // Ensure that if there is only one active alarm resource,
- // it is marked as the standard resource.
- getStandardResource(CalEvent::ACTIVE);
-
- mOpen = true;
-}
-
-bool AlarmResources::load(AlarmResource* resource, ResourceCached::CacheAction \
action)
-{
- switch (action)
- {
- case ResourceCached::SyncCache:
- case ResourceCached::NoSyncCache:
- break;
- default:
- action = ResourceCached::SyncCache;
- break;
- }
- return resource->load(action);
-}
-
-// Called whenever a remote resource download has completed.
-void AlarmResources::slotCacheDownloaded(AlarmResource* resource)
-{
- if (resource->isActive())
- emit cacheDownloaded(resource);
-}
-
-void AlarmResources::remap(AlarmResource* resource)
-{
- for (ResourceMap::Iterator it = mResourceMap.begin(); it != mResourceMap.end(); \
)
- {
- if (it.value() == resource)
- it = mResourceMap.erase(it);
- else
- ++it;
- }
- Event::List events = resource->rawEvents();
- for (int i = 0, end = events.count(); i < end; ++i)
- mResourceMap[events[i]] = resource;
-}
-
-bool AlarmResources::reload()
-{
- save();
- close();
- load();
- return true;
-}
-
-void AlarmResources::close()
-{
- if (mOpen && !mClosing)
- {
- kDebug(KARES_DEBUG);
- mClosing = true;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it \
!= mManager->activeEnd(); ++it)
- (*it)->close();
- setModified(false);
- mOpen = false;
- mClosing = false;
- }
-}
-
-bool AlarmResources::save()
-{
- kDebug(KARES_DEBUG);
- if (!mOpen)
- return false;
- bool saved = false;
- if (isModified())
- {
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it \
!= mManager->activeEnd(); ++it)
- {
- if ((!mActiveOnly || (*it)->alarmType() == CalEvent::ACTIVE)
- && (*it)->hasChanges())
- {
- kDebug(KARES_DEBUG) << "Saving modified resource" << \
(*it)->identifier();
- (*it)->save();
- saved = true;
- }
- }
- setModified(false);
- }
- if (!saved)
- kDebug(KARES_DEBUG) << "No modified resources to save";
- return true;
-}
-
-bool AlarmResources::isSaving()
-{
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- if ((*it)->isSaving())
- return true;
- }
- return false;
-}
-
-void AlarmResources::showProgress(bool show)
-{
- if (show != mShowProgress)
- {
- mShowProgress = show;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it \
!= mManager->activeEnd(); ++it)
- (*it)->showProgress(show);
- }
-}
-
-bool AlarmResources::addEvent(Event* event, AlarmResource* resource)
-{
- bool validRes = false;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- if ((*it) == resource)
- validRes = true;
- }
- AlarmResource* oldResource = mResourceMap.contains(event) ? mResourceMap[event] \
: 0;
- mResourceMap[event] = resource;
- if (validRes && resource->addIncidence(event))
- {
- event->registerObserver(this);
- notifyIncidenceAdded(event);
- setModified(true);
- return true;
- }
- if (oldResource)
- mResourceMap[event] = oldResource;
- else
- mResourceMap.remove(event);
- delete event;
- return false;
-}
-
-AlarmResources::Result AlarmResources::addEvent(Event* event, QWidget* promptParent)
-{
- kDebug(KARES_DEBUG) << this;
- bool cancelled;
- AlarmResource* resource = destination(event, promptParent, &cancelled);
- if (resource)
- {
- mResourceMap[event] = resource;
- if (resource->addIncidence(event))
- {
- event->registerObserver(this);
- notifyIncidenceAdded(event);
- mResourceMap[event] = resource;
- setModified(true);
- return Success;
- }
- mResourceMap.remove(event);
- }
- else if (cancelled)
- return Cancelled;
- else
- kDebug(KARES_DEBUG) << "No resource";
- return Failed;
-}
-
-bool AlarmResources::deleteEvent(Event *event)
-{
- kDebug(KARES_DEBUG) << event->uid();
- bool status = false;
- ResourceMap::Iterator rit = mResourceMap.find(event);
- if (rit != mResourceMap.end())
- {
- status = rit.value()->deleteEvent(event);
- if (status)
- mResourceMap.erase(rit);
- }
- else
- {
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it \
!= mManager->activeEnd(); ++it)
- status = (*it)->deleteEvent(event) || status;
- }
- setModified(status);
- return status;
-}
-
-Event* AlarmResources::event(const QString& uid)
-{
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- {
- Event* event = (*it)->event(uid);
- if (event)
- {
- mResourceMap[event] = *it;
- return event;
- }
- }
- return 0;
-}
-
-Alarm::List AlarmResources::alarmsTo(const KDateTime &to)
-{
- Alarm::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- result += (*it)->alarmsTo(to);
- return result;
-}
-
-Alarm::List AlarmResources::alarms(const KDateTime &from, const KDateTime &to)
-{
- Alarm::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- result += (*it)->alarms(from, to);
- return result;
-}
-
-Event::List AlarmResources::rawEventsForDate(const QDate &date, const \
KDateTime::Spec& timespec, EventSortField sortField, SortDirection \
sortDirection)
-{
- Event::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- appendEvents(result, (*it)->rawEventsForDate(date, timespec), *it);
- return sortEvents(&result, sortField, sortDirection);
-}
-
-Event::List AlarmResources::rawEvents(const QDate& start, const QDate& end, const \
KDateTime::Spec& timespec, bool inclusive)
-{
- kDebug(KARES_DEBUG) << "(start,end,inclusive)";
- Event::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- appendEvents(result, (*it)->rawEvents(start, end, timespec, inclusive), \
*it);
- return result;
-}
-
-Event::List AlarmResources::rawEventsForDate(const KDateTime& dt)
-{
- kDebug(KARES_DEBUG) << "(dt)";
- Event::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- appendEvents(result, (*it)->rawEventsForDate(dt), *it);
- return result;
-}
-
-Event::List AlarmResources::rawEvents(EventSortField sortField, SortDirection \
sortDirection)
-{
- kDebug(KARES_DEBUG);
- Event::List result;
- for (AlarmResourceManager::ActiveIterator it = mManager->activeBegin(); it != \
mManager->activeEnd(); ++it)
- appendEvents(result, (*it)->rawEvents(EventSortUnsorted), *it);
- return sortEvents(&result, sortField, sortDirection);
-}
-
-Event::List AlarmResources::rawEvents(AlarmResource* resource, EventSortField \
sortField, SortDirection sortDirection)
-{
- kDebug(KARES_DEBUG) << "(resource)";
- Event::List result;
- if (!resource->isActive())
- return result;
- appendEvents(result, resource->rawEvents(EventSortUnsorted), resource);
- return sortEvents(&result, sortField, sortDirection);
-}
-
-void AlarmResources::appendEvents(Event::List& result, const Event::List& events, \
AlarmResource* resource)
-{
- result += events;
- for (int i = 0, end = events.count(); i < end; ++i)
- mResourceMap[events[i]] = resource;
-}
-
-// Called whenever a resource is added to those managed by the AlarmResources,
-// to initialise it and connect its signals.
-void AlarmResources::connectResource(AlarmResource* resource)
-{
- kDebug(KARES_DEBUG) << resource->resourceName();
- resource->disconnect(this); // just in case we're called twice
- connect(resource, SIGNAL(enabledChanged(AlarmResource*)), \
SLOT(slotActiveChanged(AlarmResource*)));
- connect(resource, SIGNAL(readOnlyChanged(AlarmResource*)), \
SLOT(slotReadOnlyChanged(AlarmResource*)));
- connect(resource, SIGNAL(wrongAlarmTypeChanged(AlarmResource*)), \
SLOT(slotWrongTypeChanged(AlarmResource*)));
- connect(resource, SIGNAL(locationChanged(AlarmResource*)), \
SLOT(slotLocationChanged(AlarmResource*)));
- connect(resource, SIGNAL(colourChanged(AlarmResource*)), \
SLOT(slotColourChanged(AlarmResource*)));
- connect(resource, SIGNAL(invalidate(AlarmResource*)), \
SLOT(slotResourceInvalidated(AlarmResource*)));
- connect(resource, SIGNAL(loaded(AlarmResource*)), \
SLOT(slotResourceLoaded(AlarmResource*)));
- connect(resource, SIGNAL(cacheDownloaded(AlarmResource*)), \
SLOT(slotCacheDownloaded(AlarmResource*)));
-// connect(resource, SIGNAL(downloading(AlarmResource*,ulong)),
-// SLOT(slotResourceDownloading(AlarmResource*,ulong)));
- connect(resource, SIGNAL(resourceSaved(AlarmResource*)), \
SLOT(slotResourceSaved(AlarmResource*)));
- connect(resource, SIGNAL(resourceChanged(ResourceCalendar*)), \
SLOT(slotResourceChanged(ResourceCalendar*)));
- connect(resource, SIGNAL(resourceLoadError(ResourceCalendar*,QString)),
- SLOT(slotLoadError(ResourceCalendar*,QString)));
- connect(resource, SIGNAL(resourceSaveError(ResourceCalendar*,QString)),
- SLOT(slotSaveError(ResourceCalendar*,QString)));
-}
-
-void AlarmResources::slotResourceInvalidated(AlarmResource* resource)
-{
- emit resourceStatusChanged(resource, Invalidated);
-}
-
-void AlarmResources::slotResourceLoaded(AlarmResource* resource)
-{
- remap(resource);
- Incidence::List incidences = resource->rawIncidences();
- for (int i = 0, end = incidences.count(); i < end; ++i)
- {
- incidences[i]->registerObserver(this);
- notifyIncidenceAdded(incidences[i]);
- }
- emit resourceLoaded(resource, resource->isActive());
-}
-
-void AlarmResources::slotResourceSaved(AlarmResource* resource)
-{
- if (resource->isActive())
- emit resourceSaved(resource);
-}
-
-/*void AlarmResources::slotResourceDownloading(AlarmResource* resource, unsigned \
long percent)
-{
- if (resource->isActive())
- emit downloading(resource, percent);
-}*/
-
-void AlarmResources::slotResourceChanged(ResourceCalendar* resource)
-{
- if (resource->isActive())
- emit calendarChanged();
-}
-
-void AlarmResources::slotLoadError(ResourceCalendar* resource, const QString& err)
-{
- if (resource->isActive())
- emit signalErrorMessage(err);
-}
-
-void AlarmResources::slotSaveError(ResourceCalendar* resource, const QString& err)
-{
- if (resource->isActive())
- emit signalErrorMessage(err);
-}
-
-void AlarmResources::slotResourceStatusChanged(AlarmResource* resource, Change \
change)
-{
- kDebug(KARES_DEBUG) << resource->resourceName() << ", " << (change == Added ? \
"Added" : change == Enabled ? "Enabled" : change == ReadOnly ? "ReadOnly" : change == \
WrongType ? "WrongType" : change == Location ? "Location" : \
"Colour");
- if (!resource->writable())
- {
- // The resource is no longer writable, so it can't be a standard resource
- // N.B. Setting manager's standard resource to 0 does nothing.
- if (resource->standardResource())
- resource->setStandardResource(false);
- }
- if (!mPassiveClient)
- mManager->change(resource); // save resource's new configuration
- emit resourceStatusChanged(resource, change);
- if (change == Location && resource->isActive())
- load(resource);
-}
-
-AlarmResource* AlarmResources::resourceWithId(const QString& resourceID) const
-{
- for (AlarmResourceManager::Iterator it = mManager->begin(); it != \
mManager->end(); ++it)
- {
- if ((*it)->identifier() == resourceID)
- return *it;
- }
- return 0;
-}
-
-AlarmResource* AlarmResources::resourceForIncidence(const QString& incidenceID)
-{
- return resource(incidence(incidenceID));
-}
-
-AlarmResource* AlarmResources::resource(const Incidence* incidence) const
-{
- if (!incidence)
- return 0;
- ResourceMap::ConstIterator it = \
mResourceMap.find(const_cast<Incidence*>(incidence));
- return (it != mResourceMap.constEnd()) ? it.value() : 0;
-}
-
-// Called by the resource manager when a resource is added to the collection
-void AlarmResources::resourceAdded(AlarmResource* resource)
-{
- kDebug(KARES_DEBUG) << resource->resourceName();
- connectResource(resource);
- if (resource->isActive())
- load(resource);
- emit resourceStatusChanged(resource, Added);
-}
-
-void AlarmResources::resourceDeleted(AlarmResource* resource)
-{
- kDebug(KARES_DEBUG);
- emit resourceStatusChanged(resource, Deleted);
-}
-
-/******************************************************************************
-* Set the time zone for all resources.
-*/
-void AlarmResources::doSetTimeSpec(const KDateTime::Spec& timeSpec)
-{
- AlarmResourceManager::Iterator i1;
- for (i1 = mManager->begin(); i1 != mManager->end(); ++i1)
- (*i1)->setTimeSpec(timeSpec);
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/alarmresources.h b/kalarm/resources/alarmresources.h
deleted file mode 100644
index a760444..0000000
--- a/kalarm/resources/alarmresources.h
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * alarmresources.h - alarm calendar resources
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on calendarresources.h in libkcal,
- * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
- * Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef ALARMRESOURCES_H
-#define ALARMRESOURCES_H
-
-#include "alarmresource.h"
-#include "kalarm_resources_export.h"
-
-#include <KAlarmCal/kacalendar.h>
-
-#include <kresources/manager.h>
-#include <kdatetime.h>
-
-class KConfigGroup;
-namespace KCal { class Event; }
-using KCal::CalendarLocal;
-using KCal::ResourceCalendar;
-using namespace KAlarmCal;
-
-
-/** Provides access to all alarm calendar resources. */
-class KALARM_RESOURCES_EXPORT AlarmResources : public KCal::Calendar, public \
KRES::ManagerObserver<AlarmResource>
-{
- Q_OBJECT
- public:
- enum Change { Added, Deleted, Invalidated, Enabled, ReadOnly, WrongType, \
Location, Colour };
- // Return code when the user can cancel an operation
- enum Result { Success, Cancelled, Failed };
-
- class Ticket
- {
- friend class AlarmResources;
- public:
- AlarmResource* resource() const { return mResource; }
- private:
- explicit Ticket(AlarmResource* r) : mResource(r) { }
- AlarmResource* mResource;
- };
-
- /** Create the alarm calendar resources instance.
- * If the alarm calendar resources instance has already been created,
- * the existing instance is returned regardless of parameters passed.
- * @return The alarm calendar resources instance, or 0 if a reserved
- * file name was used (in which case, use creationError() to
- * fetch the error message).
- */
- static AlarmResources* create(const KDateTime::Spec& timeSpec, bool \
activeOnly = false, bool passiveClient = false);
- static QString creationError() { return mConstructionError; }
- virtual ~AlarmResources();
- /** Return the alarm calendar resources instance.
- * @return The alarm calendar resources instance, or 0 if not already \
created.
- */
- static AlarmResources* instance() { return mInstance; }
- /** Set a reserved local calendar file path which can't be used by this \
class. */
- static void setReservedFile(const QString& path) { mReservedFile = path; \
}
-
- /** Set whether the application has a GUI. This determines whether error or
- * progress messages are displayed. */
- void setNoGui(bool);
-
- /** Specify that the client is passive, i.e. never makes changes to the
- * resource configuration. This will prevent any configuration changes
- * from being saved. */
- void setPassiveClient(bool p) { mPassiveClient = p; }
- bool passiveClient() { return mPassiveClient; }
-
- /** Return the standard resource for the given alarm type.
- * @return 0 if no standard resource is set.
- */
- AlarmResource* getStandardResource(CalEvent::Type);
- /** Set the specified resource to be the standard resource for its alarm \
type,
- * replacing any existing standard resource.
- */
- void setStandardResource(AlarmResource*);
-
- /** Add the standard KAlarm default resource for the given alarm type. */
- AlarmResource* addDefaultResource(CalEvent::Type);
-
- /** Return the number of active resources for a given alarm type. */
- int activeCount(CalEvent::Type, bool writable);
-
- void writeConfig();
- /** Set a function to write the application ID into a calendar. */
- void setCalIDFunction(void (*f)(CalendarLocal&))
- { AlarmResource::setCalIDFunction(f); }
- /** Set a function to create KAlarm event instances.
- * When the function is called, the CalendarLocal parameter is
- * set to null to indicate that the resource is about to be reloaded. */
- void setCustomEventFunction(void (*f)(AlarmResource*, CalendarLocal*))
- { AlarmResource::setCustomEventFunction(f); }
- /** Set a function to fix the calendar once it has been loaded. */
- void setFixFunction(KACalendar::Compat (*f)(CalendarLocal&, const QString&, \
AlarmResource*, AlarmResource::FixFunc, bool* wrongType))
- { AlarmResource::setFixFunction(f); }
-
- /** Add an event to the resource calendar.
- * The resource calendar takes ownership of the event.
- * @return Success if success; otherwise the event is deleted, and
- * Cancelled or Failed is returned.
- */
- Result addEvent(KCal::Event*, CalEvent::Type, QWidget* promptParent = 0, \
bool noPrompt = false);
-
- /** Return whether all, some or none of the active resources are loaded.
- * @return 0 if no resources are loaded,
- * 1 if some but not all active resources are loaded,
- * 2 if all active resources are loaded.
- */
- int loadedState(CalEvent::Type) const;
- bool isLoading(CalEvent::Type) const;
- void showProgress(bool);
-
- /** Loads all incidences from the resources. The resources must be added
- * first using either readConfig(KConfig*), which adds the system
- * resources, or manually using resourceAdded(AlarmResource*).
- */
- void load(KCal::ResourceCached::CacheAction = \
KCal::ResourceCached::DefaultCache);
- bool load(AlarmResource*, KCal::ResourceCached::CacheAction = \
KCal::ResourceCached::DefaultCache);
-
- /**
- * Reloads all incidences from all resources.
- * @return success or failure
- */
- virtual bool reload();
-
- /**
- Clear out the current Calendar, freeing all used memory etc.
- */
- virtual void close();
-
- /**
- Sync changes in memory to persistant storage.
- */
- virtual bool save();
-
- /**
- Determine if the Calendar is currently being saved.
-
- @return true if the Calendar is currently being saved; false otherwise.
- */
- virtual bool isSaving();
-
- /**
- Get the CalendarResourceManager used by this calendar.
-
- @return a pointer to the CalendarResourceManage.
- */
- AlarmResourceManager* resourceManager() const { return mManager; }
-
- /**
- Get the resource with the specified resource ID.
-
- @param resourceID the ID of the resource
- @return pointer to the resource, or null if not found
- */
- AlarmResource* resourceWithId(const QString& resourceID) const;
-
- /**
- Get the resource associated with a specified incidence.
-
- @param incidence is a pointer to an incidence whose resource
- is to be located.
- @return a pointer to the resource containing the incidence.
- */
- AlarmResource* resource(const KCal::Incidence*) const;
-
- /**
- Get the resource associated with a specified incidence ID.
-
- @param incidenceID the ID of the incidence whose resource is to be located.
- @return a pointer to the resource containing the incidence.
- */
- AlarmResource* resourceForIncidence(const QString& incidenceID);
-
- /**
- Read the Resources settings from a config file.
-
- @param config The KConfig object which points to the config file.
- If no object is given (null pointer) the standard config file is used.
-
- @note Call this method <em>before</em> load().
- */
- void readConfig(KConfig* config = 0);
-
- /**
- Set the destination policy such that Incidences are added to a
- Resource which is queried.
- @param ask if true, prompt for which resource to add to, if
- false, add to standard resource.
- */
- void setAskDestinationPolicy(bool ask) { mAskDestination = ask; }
-
- /** Find the resource to be used to store an event of a given type.
- * @param cancelled If non-null: set to true if the user cancelled
- * the prompt dialogue; set to false if any other error.
- */
- AlarmResource* destination(CalEvent::Type, QWidget* promptParent = 0, bool \
noPrompt = false, bool* cancelled = 0);
-
- /**
- Called when a resource is added to the managed collection.
- Overrides KRES::ManagerObserver<AlarmResource>::resourceAdded().
- This method must be public, because in-process added resources
- do not emit the corresponding signal, so this methodd has to be
- called manually!
-
- @param resource is a pointer to the AlarmResource to add.
- */
- virtual void resourceAdded(AlarmResource* resource);
-
-// Incidence Specific Methods //
-
- // Event Specific Methods //
-
- /**
- Insert an Event into the Calendar.
-
- @param event is a pointer to the Event to insert.
- @return true if the Event was successfully inserted; false otherwise.
- */
- virtual bool addEvent(KCal::Event* event) { return addEvent(event, \
(QWidget*)0); }
- /** @return Success if success; otherwise the event is deleted, and
- * Cancelled or Failed is returned.
- */
- Result addEvent(KCal::Event* event, QWidget* promptParent);
-
- /**
- Insert an Event into a Calendar Resource.
-
- @param event is a pointer to the Event to insert.
- @param resource is a pointer to the AlarmResource to be added to.
- @return true if the Event was successfully inserted; false otherwise.
- */
- bool addEvent(KCal::Event* event, AlarmResource* resource);
-
- /**
- Remove an Event from the Calendar.
-
- @param event is a pointer to the Event to remove.
- @return true if the Event was successfully removed; false otherwise.
-
- @note In most cases use deleteIncidence(Incidence*) instead.
- */
- virtual bool deleteEvent(KCal::Event* event);
-
- /**
- Removes all Events from the calendar.
- */
- virtual void deleteAllEvents() {}
-
- /**
- Return a sorted, unfiltered list of all Events.
-
- @param sortField specifies the EventSortField.
- @param sortDirection specifies the SortDirection.
- @return the list of all unfiltered Events sorted as specified.
- */
- virtual KCal::Event::List rawEvents(
- KCal::EventSortField sortField = KCal::EventSortUnsorted,
- KCal::SortDirection sortDirection = KCal::SortDirectionAscending);
-
- /**
- Return a sorted, unfiltered list of all Events for one resource.
- Call this in preference to AlarmResource::rawEvents(), to ensure
- that the overall events index is updated.
-
- @param resource the AlarmResource to retrieve events for
- @param sortField specifies the EventSortField.
- @param sortDirection specifies the SortDirection.
- @return the list of all unfiltered Events sorted as specified.
- */
- virtual KCal::Event::List rawEvents(AlarmResource* resource,
- KCal::EventSortField sortField = KCal::EventSortUnsorted,
- KCal::SortDirection sortDirection = KCal::SortDirectionAscending);
-
- /**
- Return an unfiltered list of all Events which occur on the given
- timestamp.
-
- @param dt request unfiltered Event list for this KDateTime only.
- @return the list of unfiltered Events occurring on the specified
- timestamp.
- */
- virtual KCal::Event::List rawEventsForDate(const KDateTime& dt);
-
- /**
- Return an unfiltered list of all Events occurring within a date range.
-
- @param start is the starting date.
- @param end is the ending date.
- @param timespec the time spec to use to interpret @p start and @p end
- @param inclusive if true only Events which are completely included
- within the date range are returned.
- @return the list of unfiltered Events occurring within the specified
- date range.
- */
- virtual KCal::Event::List rawEvents(const QDate& start, const QDate& end,
- const KDateTime::Spec& timespec = KDateTime::Spec(),
- bool inclusive = false);
-
- /**
- Return a sorted, unfiltered list of all Events which occur on the given
- date. The Events are sorted according to @a sortField and
- @a sortDirection.
-
- @param date request unfiltered Event list for this QDate only.
- @param timespec the time spec to use to interpret @p date
- @param sortField specifies the EventSortField.
- @param sortDirection specifies the SortDirection.
- @return the list of sorted, unfiltered Events occurring on @a date.
- */
- virtual KCal::Event::List rawEventsForDate(
- const QDate& date,
- const KDateTime::Spec& timespec = KDateTime::Spec(),
- KCal::EventSortField sortField = KCal::EventSortUnsorted,
- KCal::SortDirection sortDirection = KCal::SortDirectionAscending);
-
- /**
- Returns the Event associated with the given unique identifier.
-
- @param uid is a unique identifier string.
- @return a pointer to the Event.
- A null pointer is returned if no such Event exists.
- */
- virtual KCal::Event* event(const QString& uid);
-
- // Alarm Specific Methods //
-
- /**
- Return a list of Alarms within a time range for this Calendar.
-
- @param from is the starting timestamp.
- @param to is the ending timestamp.
- @return the list of Alarms for the for the specified time range.
- */
- virtual KCal::Alarm::List alarms(const KDateTime& from, const KDateTime& \
to);
-
- /**
- Return a list of Alarms that occur before the specified timestamp.
-
- @param to is the ending timestamp.
- @return the list of Alarms occurring before the specified KDateTime.
- */
- KCal::Alarm::List alarmsTo(const KDateTime& to);
-
- static void setDebugArea(int area) { AlarmResource::setDebugArea(area); }
-
- using QObject::event; // prevent warning about hidden virtual method
-
- signals:
- /** Signal that the Resource has been modified. */
- void signalResourceModified(AlarmResource*);
-
- /** Signal an error message. */
- void signalErrorMessage(const QString& err);
-
- /** Signal that a different standard resource has been set for the given \
alarm type. */
- void standardResourceChange(CalEvent::Type);
-
- void resourceSaved(AlarmResource*);
- /** Signal that a remote resource's cache has completed downloading. */
- void cacheDownloaded(AlarmResource*);
- /** Signal that one resource has completed loading. */
- void resourceLoaded(AlarmResource*, bool success);
- /** Emitted at start of download only if mShowProgress is true. */
- void downloading(AlarmResource*, unsigned long percent);
- /** Signal that a resource has been added or deleted, or a resource's
- * enabled or read-only status has changed. */
- void resourceStatusChanged(AlarmResource*, AlarmResources::Change);
-
- protected:
- virtual void connectResource(AlarmResource*);
- virtual void resourceModified(AlarmResource*) {}
- virtual void resourceDeleted(AlarmResource*);
-
- /**
- Let CalendarResource subclasses set the time specification
- (time zone, etc.)
- */
- virtual void doSetTimeSpec(const KDateTime::Spec& timeSpec);
-
- /**
- Increment the number of times this Resource has been changed.
-
- @param resource is a pointer to the AlarmResource to be counted.
- @return the new number of times this Resource has been changed.
- */
- int incrementChangeCount(AlarmResource* resource);
-
- /**
- Decrement the number of times this Resource has been changed.
-
- @param resource is a pointer to the AlarmResource to be counted.
- @return the new number of times this Resource has been changed.
- */
- int decrementChangeCount(AlarmResource* resource);
-
- protected slots:
- void slotLoadError(ResourceCalendar*, const QString& err);
- void slotSaveError(ResourceCalendar*, const QString& err);
-
- private:
- // Override unused virtual functions
- virtual bool addTodo(KCal::Todo*) { return true; }
- virtual bool deleteTodo(KCal::Todo*) { return true; }
- virtual void deleteAllTodos() {}
- virtual KCal::Todo::List rawTodos(KCal::TodoSortField = \
KCal::TodoSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { return \
KCal::Todo::List(); }
- virtual KCal::Todo::List rawTodosForDate(const QDate&) { return \
KCal::Todo::List(); }
- virtual KCal::Todo* todo(const QString&) { return 0; }
- virtual bool addJournal(KCal::Journal*) { return true; }
- virtual bool deleteJournal(KCal::Journal*) { return true; }
- virtual void deleteAllJournals() {}
- virtual KCal::Journal::List rawJournals(KCal::JournalSortField = \
KCal::JournalSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { \
return KCal::Journal::List(); }
- virtual KCal::Journal::List rawJournalsForDate(const QDate&) { return \
KCal::Journal::List(); }
- virtual KCal::Journal* journal(const QString&) { return 0; }
-
- private slots:
- void slotActiveChanged(AlarmResource* r) { slotResourceStatusChanged(r, \
Enabled); }
- void slotReadOnlyChanged(AlarmResource* r) { slotResourceStatusChanged(r, \
ReadOnly); }
- void slotWrongTypeChanged(AlarmResource* r) { slotResourceStatusChanged(r, \
WrongType); }
- void slotLocationChanged(AlarmResource* r) { slotResourceStatusChanged(r, \
Location); }
- void slotColourChanged(AlarmResource* r) { slotResourceStatusChanged(r, \
Colour); }
- void slotResourceLoaded(AlarmResource*);
- void slotResourceSaved(AlarmResource*);
- void slotCacheDownloaded(AlarmResource*);
- void slotResourceChanged(ResourceCalendar*);
- void slotResourceInvalidated(AlarmResource*);
-
- private:
- AlarmResources(const KDateTime::Spec& timeSpec, bool activeOnly, bool \
passiveClient);
- AlarmResource* addDefaultResource(const KConfigGroup&, CalEvent::Type);
- AlarmResource* destination(KCal::Incidence*, QWidget* promptParent, bool* \
cancelled = 0);
- void appendEvents(KCal::Event::List& result, const KCal::Event::List& \
events, AlarmResource*);
- void slotResourceStatusChanged(AlarmResource*, Change);
- void remap(AlarmResource*);
-
- static AlarmResources* mInstance;
- static QString mReservedFile; // disallowed file path
- static QString mConstructionError; // error string if an error \
occurred in creating instance
-
- KRES::Manager<AlarmResource>* mManager;
- typedef QMap<KCal::Incidence*, AlarmResource*> ResourceMap;
- ResourceMap mResourceMap;
- QMap<AlarmResource*, Ticket*> mTickets;
- QMap<AlarmResource*, int> mChangeCounts;
- bool mActiveOnly; // only resource calendars containing ACTIVE \
alarms are to be opened
- bool mPassiveClient; // true if client never initiates changes
- bool mNoGui; // application has no GUI, so don't display \
messages
- bool mAskDestination; // true to prompt user which resource to store \
new events in
- bool mShowProgress; // emit download progress signals
- bool mOpen;
- bool mClosing; // close() is in progress
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/kalarm_manager.desktop \
b/kalarm/resources/kalarm_manager.desktop deleted file mode 100644
index 6aaea1c..0000000
--- a/kalarm/resources/kalarm_manager.desktop
+++ /dev/null
@@ -1,60 +0,0 @@
-# KDE Config File
-[Desktop Entry]
-Name=Alarms
-Name[ar]=المنبهات
-Name[bg]=Ðларми
-Name[bs]=Alarmi
-Name[ca]=Alarmes
-Name[ca@valencia]=Alarmes
-Name[cs]=Alarmy
-Name[da]=Alarmer
-Name[de]=Erinnerungen
-Name[el]=ΣυναγεÏμοί
-Name[en_GB]=Alarms
-Name[es]=Alarmas
-Name[et]=Häired
-Name[fi]=Hälytykset
-Name[fr]=Alarmes
-Name[ga]=Aláraim
-Name[gl]=Alarmas
-Name[hu]=Emlékeztetők
-Name[ia]=Alarmas
-Name[it]=Avvisi
-Name[ja]=アラーãƒ
-Name[kk]=ЕÑкертулер
-Name[km]=ជូន​ដំណឹង
-Name[ko]=알람
-Name[lt]=Priminimai
-Name[lv]=AtgÄdinÄjumi
-Name[mai]=सचेतक
-Name[mr]=à¤à¤²à¤¾à¤°à¥à¤®à¥à¤¸
-Name[nb]=Varslinger
-Name[nds]=Alarms
-Name[ne]=संसूचक
-Name[nl]=Herinneringen
-Name[nn]=Alarmar
-Name[oc]=Alarmas
-Name[pa]=ਅਲਾਰਮ
-Name[pl]=Alarmy
-Name[pt]=Alarmes
-Name[pt_BR]=Alarmes
-Name[ro]=Alarme
-Name[ru]=ÐапоминаниÑ
-Name[sk]=Alarmy
-Name[sl]=Alarmi
-Name[sr]=Ðларми
-Name[sr@ijekavian]=Ðларми
-Name[sr@ijekavianlatin]=Alarmi
-Name[sr@latin]=Alarmi
-Name[sv]=Alarm
-Name[th]=à¹à¸ˆà¹‰à¸‡à¹€à¸•à¸·à¸à¸™
-Name[tr]=Alarmlar
-Name[ug]=قوÚغۇراقلار
-Name[uk]=ÐагадуваннÑ
-Name[wa]=Xhîletes
-Name[x-test]=xxAlarmsxx
-Name[zh_CN]=æ醒事项
-Name[zh_TW]=鬧é˜
-Type=Service
-X-KDE-ServiceTypes=KResources/Manager
-X-KDE-ResourceFamily=alarms
diff --git a/kalarm/resources/kalarm_resources_export.h \
b/kalarm/resources/kalarm_resources_export.h deleted file mode 100644
index c848733..0000000
--- a/kalarm/resources/kalarm_resources_export.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* This file is part of the KDE project
- Copyright (C) 2007 David Faure <faure@kde.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KALARM_RESOURCES_EXPORT_H
-#define KALARM_RESOURCES_EXPORT_H
-
-/* needed for KDE_EXPORT and KDE_IMPORT macros */
-#include <kdemacros.h>
-
-#ifndef KALARM_RESOURCES_EXPORT
-# if defined(KDEPIM_STATIC_LIBS)
- /* No export/import for static libraries */
-# define KALARM_RESOURCES_EXPORT
-# elif defined(MAKE_KALARM_RESOURCES_LIB)
- /* We are building this library */
-# define KALARM_RESOURCES_EXPORT KDE_EXPORT
-# else
- /* We are using this library */
-# define KALARM_RESOURCES_EXPORT KDE_IMPORT
-# endif
-#endif
-
-# ifndef KALARM_RESOURCES_EXPORT_DEPRECATED
-# define KALARM_RESOURCES_EXPORT_DEPRECATED KDE_DEPRECATED KALARM_RESOURCES_EXPORT
-# endif
-
-#endif
diff --git a/kalarm/resources/local.desktop b/kalarm/resources/local.desktop
deleted file mode 100644
index 4d48719..0000000
--- a/kalarm/resources/local.desktop
+++ /dev/null
@@ -1,104 +0,0 @@
-[Desktop Entry]
-Name=Alarms in Local File
-Name[ar]=التنبيهات ÙÙŠ المل٠المØلي
-Name[bg]=Ðларми в локален файл
-Name[bs]=Alarmi u lokalnoj datoteci
-Name[ca]=Alarmes en un fitxer local
-Name[ca@valencia]=Alarmes en un fitxer local
-Name[cs]=Kalendář v mÃstnÃm souboru
-Name[da]=Alarmer i lokal fil
-Name[de]=Erinnerungen in lokaler Datei
-Name[el]=ΣυναγεÏμοί σε τοπικό αÏχείο
-Name[en_GB]=Alarms in Local File
-Name[es]=Alarmas en un archivo local
-Name[et]=Häired kohalikus failis
-Name[fa]=هشدارها در پرونده Ù…ØÙ„ÛŒ
-Name[fi]=Hälytykset paikallisessa tiedostossa
-Name[fr]=Alarmes dans un fichier local
-Name[ga]=Aláraim i gComhad Logánta
-Name[gl]=Alarmas nun ficheiro local
-Name[hu]=Helyi fájlban tárolt emlékeztetők
-Name[ia]=Alarmas in file local
-Name[it]=Avvisi in file locale
-Name[ja]=ãƒãƒ¼ã‚«ãƒ«ãƒ•ã‚¡ã‚¤ãƒ«ã®ã‚¢ãƒ©ãƒ¼ãƒ
-Name[kk]=Жергілікті файлдағы еÑкертулер
-Name[km]=ជូន​ដំណឹង​ក្នុង​ឯកសារ​មូលដ្ឋាន
-Name[ko]=로컬 파ì¼ì— ì €ìž¥í•œ 알람
-Name[lt]=Priminimai vietiniame faile
-Name[lv]=AtgÄdinÄjumi lokÄlÄ failÄ
-Name[mr]=सà¥à¤¥à¤¾à¤¨à¤¿à¤• फाईलीतील à¤à¤²à¤¾à¤°à¥à¤®à¥à¤¸
-Name[nb]=Varslinger i lokal fil
-Name[nds]=Alarms binnen lokaal Datei
-Name[ne]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ फाइलमा संसूचक
-Name[nl]=Herinneringen in lokaal bestand
-Name[nn]=Alarmar i lokal fil
-Name[pa]=ਲੋਕਲ ਫਾਇਲ ਵਿੱਚ ਅਲਾਰਮ
-Name[pl]=Alarmy w pliku lokalnym
-Name[pt]=Alarmes num Ficheiro Local
-Name[pt_BR]=Alarmes em arquivo local
-Name[ro]=Alarme în fișier local
-Name[ru]=ÐÐ°Ð¿Ð¾Ð¼Ð¸Ð½Ð°Ð½Ð¸Ñ Ð² локальном файле
-Name[sk]=Alarmy v lokálnom súbore
-Name[sl]=Alarmi v krajevni datoteki
-Name[sr]=Ðларми у локалном фајлу
-Name[sr@ijekavian]=Ðларми у локалном фајлу
-Name[sr@ijekavianlatin]=Alarmi u lokalnom fajlu
-Name[sr@latin]=Alarmi u lokalnom fajlu
-Name[sv]=Alarm i lokal fil
-Name[tr]=Yerel Dosyadaki Alarmlar
-Name[uk]=ÐÐ°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½Ð½Ñ Ð² локальному файлі
-Name[wa]=Xhîletes e-n on fitchî coinrece
-Name[x-test]=xxAlarms in Local Filexx
-Name[zh_CN]=本地文件ä¸çš„æ醒事项
-Name[zh_TW]=本地檔案ä¸çš„鬧é˜
-Comment=Provides access to an alarm calendar stored in a single local file
-Comment[ar]=يوÙر الوصول لمنبه التقويم المØÙوظ ÙÙŠ \
مل٠مØلي Ù…Ùرد
-Comment[bs]=ObezbjeÄ‘uje prostup alarm kalendaru saÄuvanom u jednoj lokalnoj \
datoteci
-Comment[ca]=Proporciona accés a un calendari d'alarmes emmagatzemat en un fitxer \
local individual
-Comment[ca@valencia]=Proporciona l'accés a un calendari d'alarmes emmagatzemat en \
un fitxer local individual
-Comment[cs]=Poskytuje pÅ™Ãstup ke kalendáři alarmu uloženém v jednom lokálnÃm \
souboru
-Comment[da]=Giver adgang til en alarmkalender lagret i en enkelt lokal fil
-Comment[de]=Ermöglicht den Zugriff auf einen Erinnerungen-Kalender in einer lokalen \
Datei.
-Comment[el]=Î ÏοσφÎÏει Ï€Ïόσβαση σε ημεÏολόγιο \
συναγεÏμών αποθηκευμÎνο σε Îνα \
τοπικό αÏχείο
-Comment[en_GB]=Provides access to an alarm calendar stored in a single local file
-Comment[es]=Provee acceso al calendario de alarmas almacenado en un solo archivo \
local
-Comment[et]=Võimaldab kasutada kohalikku faili salvestatud häirete kalendrit
-Comment[fi]=Tarjoaa pääsyn yksittäiseen paikalliseen tiedostoon tallennettuun \
hälytyskalenteriin
-Comment[fr]=Fournit l'accès aux alarmes de calendrier stockées dans un unique \
fichier
-Comment[gl]=Dá aceso a un calendario de alarmas gardado nun ficheiro local
-Comment[hu]=Helyi fájlban tárolt emlékeztetÅ‘khöz biztosÃt hozzáférést
-Comment[ia]=Forni accesso a un calendario de alarma immagazinate in un singule file \
local
-Comment[it]=Consente l'accesso a degli avvisi memorizzati in un file locale
-Comment[ja]=å˜ä¸€ã®ãƒãƒ¼ã‚«ãƒ«ãƒ•ã‚¡ã‚¤ãƒ«ã«ä¿å˜ã•ã‚Œã¦ã„るアラーム\
カレンダーã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ã‚’æä¾›ã—ã¾ã™
-Comment[kk]=Бір жергілікті файлдағы еÑкертулер \
күнтізбеге қатынау
-Comment[km]=ផ្ដល់​សិទ្ធិ​ចូល​ដំណើរការ​ទៅ​ប្រážáž·áž‘ិន​ជូន​ដំណឹង \
ដែល​បាន​ទុក​នៅ​ក្នុង​ឯកសារ​មូលដ្ឋាន​​
-Comment[ko]=ë‹¨ì¼ ë¡œì»¬ 파ì¼ì— ì €ìž¥ë˜ì–´ 있는 알람 ë‹¬ë ¥ì— ì \
‘근하기
-Comment[lt]=Suteikia priėjimą prie priminimų kalendoriaus vietiniame faile
-Comment[lv]=NodroÅ¡ina piekļuvi atgÄdinÄjumu kalendÄram, kas glabÄjas vienÄ \
lokÄlÄ failÄ
-Comment[nb]=Gir tilgang til en varslingskalender lagret i en enkelt lokal fil
-Comment[nds]=Stellt Togriep op en binnen en enkelte lokaale Datei wohrten \
Alarm-Kalenner praat
-Comment[nl]=Geeft toegang naar een herinneringagenda, die in een enkel lokaal \
bestand opgeslagen is
-Comment[nn]=Gjev tilgang til alarmkalendrar lagra i lokale filer
-Comment[pl]=Zapewnia dostęp do kalendarza alarmów przechowywanego w pojedyńczym \
pliku lokalnym
-Comment[pt]=Oferece o acesso a um calendário de alarmes guardado num único \
ficheiro local
-Comment[pt_BR]=Fornece acesso a um calendário de alarmes armazenado em um único \
arquivo local
-Comment[ro]=Oferă acces la un calendar de alarme stocat într-un singur fișier \
local
-Comment[ru]=Хранение напоминаний в локальном файле
-Comment[sk]=Umožňuje prÃstup do kalendára alarmov uložený v jednoduchom \
lokálnom súbore
-Comment[sl]=OmogoÄa dostop do koledarja z alarmi, ki je shranjen v eni krajevni \
datoteki
-Comment[sr]=Омогућава приÑтуп алармном календару \
Ñмештеном у једном локалном фајлу
-Comment[sr@ijekavian]=Омогућава приÑтуп алармном \
календару Ñмештеном у једном \
локалном фајлу
-Comment[sr@ijekavianlatin]=Omogućava pristup alarmnom kalendaru smeštenom u jednom \
lokalnom fajlu
-Comment[sr@latin]=Omogućava pristup alarmnom kalendaru smeštenom u jednom lokalnom \
fajlu
-Comment[sv]=Ger tillgång till en alarmkalender lagrad i en enda lokal fil
-Comment[tr]=Tek bir yerel dosyada depolanmış bir alarm takvimine erişim sağlar
-Comment[uk]=Ðадає доÑтуп до ÐºÐ°Ð»ÐµÐ½Ð´Ð°Ñ€Ñ Ð½Ð°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½ÑŒ, \
Ñкий зберігаєтьÑÑ Ñƒ окремому \
локальному файлі
-Comment[wa]=Dene l' accès a on calindrî di xhîletes stoké dins on seu fitchî \
coinrece
-Comment[x-test]=xxProvides access to an alarm calendar stored in a single local \
filexx
-Comment[zh_CN]=æ供对å˜å‚¨åœ¨å•ä¸ªæœ¬åœ°æ–‡ä»¶ä¸çš„æ醒日历的访问支æŒ
-Comment[zh_TW]=æä¾›å˜å–儲å˜åœ¨æœ¬åœ°æª”案ä¸çš„鬧é˜è¡Œäº‹æ›†çš„功能
-X-KDE-Library=kalarm_local
-Type=Service
-X-KDE-ServiceTypes=KResources/Plugin
-X-KDE-ResourceFamily=alarms
-X-KDE-ResourceType=file
diff --git a/kalarm/resources/localdir.desktop b/kalarm/resources/localdir.desktop
deleted file mode 100644
index ffaf957..0000000
--- a/kalarm/resources/localdir.desktop
+++ /dev/null
@@ -1,104 +0,0 @@
-[Desktop Entry]
-Name=Alarms in Local Directory
-Name[ar]=التنبيهات ÙÙŠ الدليل المØلي
-Name[be]=КалÑндар у мÑÑцовай Ñ‚Ñчцы
-Name[bg]=Ðларми в локална директориÑ
-Name[bs]=Alarmi u lokalnom direktoriju
-Name[ca]=Alarmes en un directori local
-Name[ca@valencia]=Alarmes en un directori local
-Name[cs]=Alarmy v mÃstnà složce
-Name[da]=Alarmer i lokal mappe
-Name[de]=Erinnerungen in lokalem Ordner
-Name[el]=ΣυναγεÏμοί σε τοπικό κατάλογο
-Name[en_GB]=Alarms in Local Directory
-Name[es]=Alarmas en un directorio local
-Name[et]=Häired kohalikus kataloogis
-Name[fa]=هشدارها در Ùهرست راهنمای Ù…ØÙ„ÛŒ
-Name[fi]=Hälytykset paikallisessa kansiossa
-Name[fr]=Alarmes dans un dossier local
-Name[ga]=Aláraim i gComhadlann Logánta
-Name[gl]=Alarmas nun directorio local
-Name[hu]=Helyi mappában tárolt emlékeztetők
-Name[ia]=Alarmas in directorio local
-Name[it]=Avvisi in una directory locale
-Name[ja]=ãƒãƒ¼ã‚«ãƒ«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ã‚¢ãƒ©ãƒ¼ãƒ
-Name[kk]=Жергілікті капшықтағы еÑкертулер
-Name[km]=ជូន​ដំណឹង​ក្នុង​ážážâ€‹áž˜áž¼áž›ážŠáŸ’ឋាន​​​
-Name[ko]=로컬 ë””ë ‰í„°ë¦¬ì— ì €ìž¥í•œ 알람
-Name[lt]=Priminimai vietiniame aplanke
-Name[lv]=AtgÄdinÄjumi lokÄlÄ mapÄ“
-Name[mr]=सà¥à¤¥à¤¾à¤¨à¤¿à¤• संचयीकेतील \
à¤à¤²à¤¾à¤°à¥à¤®à¥à¤¸
-Name[nb]=Varslinger i lokal katalog
-Name[nds]=Alarms binnen lokaal Orner
-Name[ne]=सà¥à¤¥à¤¾à¤¨à¥€à¤¯ डाइरेकà¥à¤Ÿà¤°à¥€à¤®à¤¾ \
संसूचक
-Name[nl]=Herinneringen in lokale map
-Name[nn]=Alarmar i lokal mappe
-Name[pa]=ਲੋਕਲ ਡਾਇਰੈਕਟਰੀ ਵਿੱਚ ਅਲਾਰਮ
-Name[pl]=Alarmy w katalogu lokalnym
-Name[pt]=Alarmes numa Pasta Local
-Name[pt_BR]=Alarmes em pasta local
-Name[ro]=Alarme în dosar local
-Name[ru]=ÐÐ°Ð¿Ð¾Ð¼Ð¸Ð½Ð°Ð½Ð¸Ñ Ð² локальной папке
-Name[sk]=Alarmy v lokálnom prieÄinku
-Name[sl]=Alarmi v krajevnem imeniku
-Name[sr]=Ðларми у локалној фаÑцикли
-Name[sr@ijekavian]=Ðларми у локалној фаÑцикли
-Name[sr@ijekavianlatin]=Alarmi u lokalnoj fascikli
-Name[sr@latin]=Alarmi u lokalnoj fascikli
-Name[sv]=Alarm i lokal katalog
-Name[tr]=Yerel Dizinlerdeki Alarmlar
-Name[uk]=ÐÐ°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½Ð½Ñ Ð² локальному каталозі
-Name[wa]=Xhîletes e-n on ridant coinrece
-Name[x-test]=xxAlarms in Local Directoryxx
-Name[zh_CN]=本地目录ä¸çš„æ醒事项
-Name[zh_TW]=本地目錄ä¸çš„鬧é˜
-Comment=Provides access to an alarm calendar stored in a local directory, in which \
each calendar item is stored in a separate file
-Comment[ar]=يوÙر وصول لمنبه التقويم المØÙوظ ÙÙŠ \
الدليل المØلي ØŒ بØيث كل عنصر تقويم Ù…ØÙوظ ÙÙŠ مل٠\
منÙرد
-Comment[bs]=ObezbjeÄ‘uje prostup alarm kalendaru saÄuvanom u lokalnom direktoriju, \
u kojem svaki od kalendarskih primjeraka je saÄuvan u odvojenoj \
datoteci
-Comment[ca]=Proporciona accés a un calendari d'alarmes emmagatzemat en un directori \
local, en el que cada element del calendari està emmagatzemat en un \
fitxer separat
-Comment[ca@valencia]=Proporciona l'accés a un calendari d'alarmes emmagatzemat en \
un directori local, en el que cada element del calendari està emmagatzemat en un \
fitxer separat
-Comment[da]=Giver adgang til en alarmkalender lagret i en lokal mappe, hvori hvert \
enkelt kalenderelement lagres i en seperat fil
-Comment[de]=Ermöglicht den Zugriff auf einen Erinnerungen-Kalender in einem lokalen \
Ordner, in dem jeder Kalender-Eintrag als separate Datei gespeichert \
ist.
-Comment[el]=Î ÏοσφÎÏει Ï€Ïόσβαση σε ημεÏολόγιο \
συναγεÏμών αποθηκευμÎνο σε Îναν τοπικό \
κατάλογο, στον οποίο κάθε αντικείμενο \
αποθηκεÏεται σε ξεχωÏιστό αÏχείο
-Comment[en_GB]=Provides access to an alarm calendar stored in a local directory, in \
which each calendar item is stored in a separate file
-Comment[es]=Provee acceso a un calendario de alarmas almacenado en un directorio \
local, en el cual cada elemento del calendario es almacenado en un \
archivo separado
-Comment[et]=Võimaldab kasutada kohalikku kataloogi salvestatud häirete kalendrit, \
kus iga kalender on salvestatud eraldi faili
-Comment[fi]=Tarjoaa pääsyn paikalliseen kansioon tallennettuun \
hälytyskalenteriin, jossa jokainen kalenteritietue on erillinen \
tiedosto
-Comment[fr]=Fournit l'accès aux alarmes de calendrier stockées dans un dossier ; \
chaque entrée du calendrier étant stockée dans un fichier distinct
-Comment[gl]=Permite acceder a un calendario de alarmas almacenado nun directorio \
local no que cada elemento do calendario se almacena nun ficheiro \
diferente
-Comment[hu]=Helyi mappában tárolt emlékeztetÅ‘khöz biztosÃt hozzáférést \
(minden bejegyzés külön fájlban található)
-Comment[ia]=Forni accesso a un calendario de alarma immagazinate in un directorio \
local, in le qual cata elemento de calendario es immagazinate in un \
file separate
-Comment[it]=Consente l'accesso a degli avvisi memorizzati in una directory locale, \
in cui ogni voce di calendario è memorizzato in un file separato
-Comment[ja]=カレンダーアイテム\
ãŒãã‚Œãžã‚Œå€‹åˆ¥ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ä¿å˜ã•ã‚Œã¦ã„ã‚‹ãƒãƒ¼ã‚«ãƒ«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã®ã‚¢ãƒ©ãƒ¼ãƒ \
カレンダーã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ã‚’æä¾›ã—ã¾ã™
-Comment[kk]=Әрбір күнтізбе оқиғаÑÑ‹ бөлек файлда \
Ñақталған жергілікті қапшықтағы еÑкертулер \
күнтізбеге қатынау
-Comment[km]=ផ្ដល់​សិទ្ធិ​ចូល​ដំណើរកាá \
žšâ€‹áž‘ៅកាន់​ប្រážáž·áž‘ិន​ជូន​ដំណឹង​ដ \
ែល​បាន​រក្សាទុក​នៅ​ក្នុង​ážážâ€‹áž˜áž¼áž›ážŠáŸ’ឋាន \
ដែល​ធាážáž»â€‹áž”្រážáž·áž‘ិន​នីមួយៗ​គឺ​ហ\
្រូវបាន​រក្សាទុក​ជា​ឯកសារ​ដាច់ដោយឡែក​ពី​គ្នា
-Comment[ko]=알람 ë‹¬ë ¥ì˜ ê°ê° ë‹¬ë ¥ í•ëª©ì´ 파ì¼ë¡œ ì €ìž¥ë˜ì–´ 있는 \
로컬 ë””ë ‰í„°ë¦¬ì— ì ‘ê·¼í•©ë‹ˆë‹¤
-Comment[lt]=Suteikia priėjimą prie priminimų kalendoriaus vietiniame aplanke, \
kuriame kiekvienas įvykis saugomas atskirame faile
-Comment[lv]=NodroÅ¡ina piekļuvi atgÄdinÄjumu kalendÄram, kas glabÄjas vienÄ \
lokÄlÄ mapÄ“, katrs kalendÄrs atsviÅ¡Ä·Ä failÄ
-Comment[nb]=Gir tilgang til en varslingskalender lagret i en lokal mappe, der hver \
kalenderoppføring er lagret i en separat fil
-Comment[nds]=Stellt Togriep op en binnen en lokalen Orner wohrten Alarm-Kalenner \
praat, binnen den elk Kalennerindrag as enkelte Datei sekert is.
-Comment[nl]=Geeft toegang naar een herinneringagenda in een lokaal opgeslagen \
map,waarbij iedere agenda in een apart bestand opgeslagen is
-Comment[nn]=Gjev tilgang til alarmkalendrar lagra i ei lokal mappe, der kvart \
kalenderelement vert lagra i ei eiga fil.
-Comment[pl]=Zapewnia dostęp do kalendarza alarmów przechowywanego w lokalnym \
katalogu, w którym każdy element kalendarza jest zapisany w osobnym \
pliku
-Comment[pt]=Oferece o acesso a um calendário de alarmes guardado numa pasta local; \
cada item do calendário é guardado num ficheiro em separado
-Comment[pt_BR]=Fornece acesso a um calendário de alarmes armazenado em um único \
arquivo local, onde cada item do calendário é armazenado em um \
arquivo separado
-Comment[ro]=Oferă acces la un calendar de alarme stocat într-un dosar local, cu \
fiecare element din calendar stocat într-un fișier separat
-Comment[ru]=Хранение напоминаний в отдельных \
файлах в локальной папке
-Comment[sk]=Umožňuje prÃstup ku kalendáru alarmov uloženému v lokálnom \
adresári, v ktorom je každá položka kalendára uložená v \
samostatnom súbore
-Comment[sl]=OmogoÄa dostop do koledarja z alarmi, ki so shranjeni v krajevni mapi, \
kjer je vsak alarm shranjen v loÄeni datoteki
-Comment[sr]=Омогућава приÑтуп алармном календару \
Ñмештеном у локалној фаÑцикли у којој је Ñваки \
календар Ñмештен у поÑебан фајл
-Comment[sr@ijekavian]=Омогућава приÑтуп алармном \
календару Ñмјештеном у локалној фаÑцикли у \
којој је Ñваки календар Ñмештен у \
поÑебан фајл
-Comment[sr@ijekavianlatin]=Omogućava pristup alarmnom kalendaru smještenom u \
lokalnoj fascikli u kojoj je svaki kalendar smešten u poseban fajl
-Comment[sr@latin]=Omogućava pristup alarmnom kalendaru smeštenom u lokalnoj \
fascikli u kojoj je svaki kalendar smešten u poseban fajl
-Comment[sv]=Ger tillgång till en alarmkalender lagrad i en lokal katalog, där \
varje kalenderobjekt är lagrat i en separat fil
-Comment[tr]=Her takvim ögesinin ayrı bir dosyada depolandığı yerel bir dizinde \
depolanmış bir alarm takvimine erişim sağlar
-Comment[uk]=Ðадає доÑтуп до ÐºÐ°Ð»ÐµÐ½Ð´Ð°Ñ€Ñ Ð½Ð°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½ÑŒ, \
Ñкий зберігаєтьÑÑ Ñƒ локальному каталозі, де \
кожен Ð·Ð°Ð¿Ð¸Ñ ÐºÐ°Ð»ÐµÐ½Ð´Ð°Ñ€Ñ Ð·Ð±ÐµÑ€Ñ–Ð³Ð°Ñ”Ñ‚ÑŒÑÑ Ñƒ окремому \
файлі
-Comment[wa]=Dene l' accès a on calindrî di xhîletes stoké dins on ridant \
coinrece, ki tchaeke cayet do calindrî î est stoké dins on fitchî \
a pårt
-Comment[x-test]=xxProvides access to an alarm calendar stored in a local directory, \
in which each calendar item is stored in a separate filexx
-Comment[zh_CN]=æ供对å˜å‚¨åœ¨ä¸€ä¸ªæœ¬åœ°ç›®å½•ä¸çš„æ醒日历的访问支æŒï¼Œæ¯ä¸ªæ—¥åŽ†é¡¹ç›®éƒ½å˜å‚¨åœ¨å„自独立的文件内
-Comment[zh_TW]=æä¾›å˜å–儲å˜åœ¨æœ¬åœ°ç›®éŒ„ä¸çš„鬧é˜è¡Œäº‹æ›†çš„功能。æ¯ä¸€å€‹è¡Œäº‹æ›†æ˜¯å–®ç¨ä¸€å€‹æª”案
-X-KDE-Library=kalarm_localdir
-Type=Service
-X-KDE-ServiceTypes=KResources/Plugin
-X-KDE-ResourceFamily=alarms
-X-KDE-ResourceType=localdir
diff --git a/kalarm/resources/remote.desktop b/kalarm/resources/remote.desktop
deleted file mode 100644
index 0c00787..0000000
--- a/kalarm/resources/remote.desktop
+++ /dev/null
@@ -1,104 +0,0 @@
-[Desktop Entry]
-Name=Alarms in Remote File
-Name[ar]=التنبيهات ÙÙŠ مل٠بعيد
-Name[be]=КалÑндар у аддаленым файле
-Name[bg]=Ðларми в отдалечен файл
-Name[bs]=Alarmi u udaljenoj datoteci
-Name[ca]=Alarmes en un fitxer remot
-Name[ca@valencia]=Alarmes en un fitxer remot
-Name[cs]=Alarmy ve vzdáleném souboru
-Name[da]=Alarmer i ekstern fil
-Name[de]=Erinnerungen in Datei auf Fremdrechner
-Name[el]=ΣυναγεÏμοί σε απομακÏυσμÎνο αÏχείο
-Name[en_GB]=Alarms in Remote File
-Name[es]=Alarmas en un archivo remoto
-Name[et]=Häired võrgufailis
-Name[fa]=هشدارها در پرونده دور
-Name[fi]=Hälytykset etätiedostossa
-Name[fr]=Alarmes dans un fichier distant
-Name[ga]=Aláraim i gCianchomhad
-Name[gl]=Alarmas nun ficheiro remoto
-Name[hu]=Távoli fájlban tárolt emlékeztetők
-Name[ia]=Alarmas in file remote
-Name[it]=Avvisi in file remoto
-Name[ja]=リモートファイルã®ã‚¢ãƒ©ãƒ¼ãƒ
-Name[kk]=Қашықтағы файлдағы еÑкертулер
-Name[km]=ជូន​ដំណឹង​ក្នុង​ឯកសារ​ពី​ចម្ងាយ
-Name[ko]=ì›ê²© 파ì¼ì— ì €ìž¥í•œ 알람
-Name[lt]=Priminimai nutolusiame faile
-Name[lv]=AtgÄdinÄjumi attÄlinÄtÄ failÄ
-Name[mr]=दूरसà¥à¤¥ फाईलीतील à¤à¤²à¤¾à¤°à¥à¤®à¥à¤¸
-Name[nb]=Varslinger i fil på nettverk
-Name[nds]=Alarms binnen feern Datei
-Name[ne]=टाढाको फाइलमा संसूचक
-Name[nl]=Herinneringen in extern bestand
-Name[nn]=Alarmar i ekstern fil
-Name[pa]=ਰਿਮੋਟ ਫਾਇਲ ਵਿੱਚ ਅਲਾਰਮ
-Name[pl]=Alarmy w pliku zdalnym
-Name[pt]=Alarmes num Ficheiro Remoto
-Name[pt_BR]=Alarmes em arquivo remoto
-Name[ro]=Alarme în fișier distant
-Name[ru]=ÐÐ°Ð¿Ð¾Ð¼Ð¸Ð½Ð°Ð½Ð¸Ñ Ð² Ñетевом файле
-Name[sk]=Alarmy vo vzdialenom súbore
-Name[sl]=Alarmi v oddaljeni datoteki
-Name[sr]=Ðларми у удаљеном фајлу
-Name[sr@ijekavian]=Ðларми у удаљеном фајлу
-Name[sr@ijekavianlatin]=Alarmi u udaljenom fajlu
-Name[sr@latin]=Alarmi u udaljenom fajlu
-Name[sv]=Alarm i fjärrfil
-Name[tr]=Uzak Dosyadaki Alarmlar
-Name[uk]=ÐÐ°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½Ð½Ñ Ñƒ віддаленому файлі
-Name[wa]=Xhîletes e-n on fitchî då lon
-Name[x-test]=xxAlarms in Remote Filexx
-Name[zh_CN]=远程文件ä¸çš„æ醒事项
-Name[zh_TW]=é 端檔案的鬧é˜
-Comment=Provides access to an alarm calendar in a remote file using KDE's network \
framework KIO
-Comment[ar]=يوÙر وصول لمنبه التقويم ÙÙŠ مل٠بعيد \
بإستخدام إطار شبكة كدي KIO
-Comment[bs]=Obezbjeđuje pristup alarm kalendaru u udaljenoj datoteci koristeći \
KDE-ov mrežni okvir KIO
-Comment[ca]=Proporciona accés a un calendari d'alarmes en un fitxer remot usant la \
infraestructura KIO de xarxa del KDE
-Comment[ca@valencia]=Proporciona l'accés a un calendari d'alarmes en un fitxer \
remot usant la infraestructura KIO de xarxa del KDE
-Comment[da]=Giver adgang til en alarm-kalender i en ekstern fil der bruger KDE's \
netværks-framework KIO
-Comment[de]=Ermöglicht den Zugriff auf einen entfernten Erinnerungen-Kalender über \
KDEs Netzwerk-Zugriffsystem KIO.
-Comment[el]=Î ÏοσφÎÏει Ï€Ïόσβαση ημεÏολογίου \
ειδοποιήσεων σε Îνα απομακÏυσμÎνο αÏχείου με \
τη χÏήση του συστήματος KIO του KDE
-Comment[en_GB]=Provides access to an alarm calendar in a remote file using KDE's \
network framework KIO
-Comment[es]=Provee acceso a un calendario de alarmas en un archivo remoto utilizando \
la infraestructura KIO de red de KDE
-Comment[et]=Võimaldab kasutada võrgufailis leiduvat häirete kalendrit KDE \
võrguraamistiku KIO vahendusel
-Comment[fi]=Tarjoaa pääsyn etätiedostoon tallennettuun hälytyskalenteriin \
käyttäen KDE:n verkkorajapintaa (KIO)
-Comment[fr]=Fournit l'accès aux alarmes de calendrier stockées dans un fichier \
distant en utilisant les composants réseaux KIO de KDE
-Comment[gl]=Permite acceder a un calendario de alarmas dun ficheiro remoto \
empregando a infraestrutura de rede KIO do KDE
-Comment[hu]=Távoli fájlban tárolt emlékeztetÅ‘khöz biztosÃt hozzáférést a \
KIO keretrendszer segÃtségével
-Comment[ia]=Forni accesso a un calendario de alarma in un file remote usante le \
schema de rete de KDE KIO
-Comment[it]=Consente l'accesso ad un calendario di avvisi memorizzati su un file \
remoto tramite l'infrastruttura di rete KIO di KDE
-Comment[ja]=KDE ã®ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ãƒ•ãƒ¬ãƒ¼ãƒ ワーク KIO \
を使ã£ã¦ã€ãƒªãƒ¢ãƒ¼ãƒˆãƒ•ã‚¡ã‚¤ãƒ«ã«ä¿å˜ã•ã‚Œã¦ã„るアラーム\
カレンダーã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ã‚’æä¾›ã—ã¾ã™
-Comment[kk]=Қашықтағы файлдағы еÑкертулер \
күнтізбеге, KDE-нің KIO желі құрылымының \
көмегімен қатынау
-Comment[km]=ផ្ដល់​សិទ្ធិ​ចូល​ដំណើរកាá \
žšâ€‹áž‘ៅកាន់​ប្រážáž·áž‘ិន​ជូន​ដំណឹង​ន \
ៅ​ក្នុង​ឯកសារ​ពី​ចម្ងាយ​ដោយប្រើ​គ្រោងការណáŸâ€‹áž”ណ្ដាញ \
KIO ​របស់ KDE
-Comment[ko]=KIO를 사용해서 ì›ê²© 파ì¼ì˜ 알람 ë‹¬ë ¥ì— ì ‘ê·¼í•©ë‹ˆë‹¤
-Comment[lt]=Suteikia prieigą prie priminimų kalendoriaus nutolusiame faile \
naudojant KDE tinklo aplinkos KIO
-Comment[lv]=NodroÅ¡ina piekļuvi atgÄdinÄjumu kalendÄram, kas glabÄjas vienÄ \
attÄlinÄtÄ failÄ, izmantojot KDE tÄ«kla ietvaru KIO
-Comment[nb]=Gir tilgang til en varslingskalender i en fil på nettverket, ved bruk \
av KDEs rammeverk KIO for nettverk
-Comment[nds]=Stellt mit dat In-/Utgaavmoduul vun KDE sien Nettwark-Rahmenwerk \
Togriep op en binnen en feern Datei wohrten Alarm-Kalenner praat.
-Comment[nl]=Geeft toegang naar een herinneringagenda in een extern bestand \
gebruikmakend van KIO, een netwerkonderdeel van KDE
-Comment[nn]=Gjev tilgang til alarmkalendrar lagra i ei ekstern fil ved bruk av \
nettverksrammeverket KIO
-Comment[pl]=Zapewnia dostęp do kalendarza alarmów w pliku zdalnymp przy pomocy \
systemu sieciowego KDE - KIO
-Comment[pt]=Oferece o acesso a um calendário de alarmes num ficheiro remoto, usando \
um KIO da plataforma de rede do KDE
-Comment[pt_BR]=Fornece acesso a um calendário de alarmes em um arquivo remoto \
usando o KIO framework da rede do KDE
-Comment[ro]=Oferă acces la un calendar de alarme stocat într-un fișier distant, \
folosind infrastructura de rețea KIO din KDE
-Comment[ru]=Хранение напоминаний в Ñетевом файле, \
доÑтупном по протоколу KIO
-Comment[sk]=Umožňuje prÃstup do kalendára alarmov vo vzdialenom súbore \
použitÃm KDE sieÅ¥ovej Å¡truktúry KIO
-Comment[sl]=Z uporabo KDE-jevega omrežnega ogrodja KIO omogoÄa dostop do koledarja \
z alarmi, ki je shranjen v oddaljeni datoteki
-Comment[sr]=Омогућава приÑтуп алармном календару у \
удаљеном фајлу помоћу КДЕ‑овог мрежног \
радног оквира К‑У/И
-Comment[sr@ijekavian]=Омогућава приÑтуп алармном \
календару у удаљеном фајлу помоћу КДЕ‑овог \
мрежног радног оквира К‑У/И
-Comment[sr@ijekavianlatin]=Omogućava pristup alarmnom kalendaru u udaljenom fajlu \
pomoću KDE‑ovog mrežnog radnog okvira K‑U/I
-Comment[sr@latin]=Omogućava pristup alarmnom kalendaru u udaljenom fajlu pomoću \
KDE‑ovog mrežnog radnog okvira K‑U/I
-Comment[sv]=Ger tillgång till en alarmkalender i en fjärrfil med användning av \
KDE:s I/O-ramverk
-Comment[tr]=KDE'nin ağ çatısı KIO'yu kullanarak uzak bir dosyadaki bir alarm \
takvimine eriÅŸim saÄŸlar
-Comment[uk]=Ðадає доÑтуп до ÐºÐ°Ð»ÐµÐ½Ð´Ð°Ñ€Ñ Ð½Ð°Ð³Ð°Ð´ÑƒÐ²Ð°Ð½ÑŒ, \
Ñкий зберігаєтьÑÑ Ñƒ віддаленому файлі, за \
допомогою мережевих заÑобів KIO KDE
-Comment[wa]=Dene l' accès a on calindrî di xhîletes dins on fitchî då lon \
tot-z s' siervant di l' evironmint KIO rantoele da KDE
-Comment[x-test]=xxProvides access to an alarm calendar in a remote file using KDE's \
network framework KIOxx
-Comment[zh_CN]=通过 KDE 网络框架 \
KIO,æ供对å˜å‚¨åœ¨ä¸€ä¸ªè¿œç¨‹æ–‡ä»¶ä¸çš„æ醒日历的访问支æŒ
-Comment[zh_TW]=æä¾›å˜å–使用 KDE 網路架構 KIO 儲å˜åœ¨é \
端檔案ä¸çš„鬧é˜è¡Œäº‹æ›†çš„功能
-X-KDE-Library=kalarm_remote
-Type=Service
-X-KDE-ServiceTypes=KResources/Plugin
-X-KDE-ResourceFamily=alarms
-X-KDE-ResourceType=remote
diff --git a/kalarm/resources/resourcelocal.cpp b/kalarm/resources/resourcelocal.cpp
deleted file mode 100644
index 3048795..0000000
--- a/kalarm/resources/resourcelocal.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * resourcelocal.cpp - KAlarm local calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourcelocal.cpp in libkcal (updated to rev 765072),
- * Copyright (c) 1998 Preston Brown <pbrown@kde.org>
- * Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocal.moc"
-
-#include <kcal/calendarlocal.h>
-
-#include <kstandarddirs.h>
-#include <klocale.h>
-#include <kconfiggroup.h>
-#include <kdebug.h>
-
-#include <QFileInfo>
-
-using namespace KCal;
-
-
-KAResourceLocal::KAResourceLocal()
- : AlarmResource(),
- mFileReadOnly(false)
-{
- init();
-}
-
-KAResourceLocal::KAResourceLocal(const KConfigGroup& group)
- : AlarmResource(group),
- mFileReadOnly(false)
-{
- mURL = KUrl(group.readPathEntry("CalendarURL", QString()));
- init();
-}
-
-KAResourceLocal::KAResourceLocal(CalEvent::Type type, const QString& fileName)
- : AlarmResource(type),
- mURL(KUrl::fromPath(fileName)),
- mFileReadOnly(false)
-{
- init();
-}
-
-void KAResourceLocal::init()
-{
- setType("file"); // set resource type
-
- //setSavePolicy(SaveDelayed); // unnecessary for KAlarm, and would override \
base class setting
-
- connect(&mDirWatch, SIGNAL(dirty(QString)), SLOT(reload()));
- connect(&mDirWatch, SIGNAL(created(QString)), SLOT(reload()));
- connect(&mDirWatch, SIGNAL(deleted(QString)), SLOT(reload()));
-
- mDirWatch.addFile(mURL.toLocalFile());
- enableResource(isActive());
-}
-
-KAResourceLocal::~KAResourceLocal()
-{
- mDirWatch.stopScan();
- if (isOpen())
- close();
-}
-
-void KAResourceLocal::writeConfig(KConfigGroup& group)
-{
- group.writePathEntry("CalendarURL", mURL.prettyUrl());
- AlarmResource::writeConfig(group);
-}
-
-void KAResourceLocal::startReconfig()
-{
- mNewURL = mURL;
- AlarmResource::startReconfig();
-}
-
-void KAResourceLocal::applyReconfig()
-{
- if (mReconfiguring)
- {
- AlarmResource::applyReconfig();
- if (setFileName(mNewURL))
- mReconfiguring = 3; // indicate that location has changed
- AlarmResource::applyReconfig();
- }
-}
-
-bool KAResourceLocal::readOnly() const
-{
- return mFileReadOnly || AlarmResource::readOnly();
-}
-
-void KAResourceLocal::enableResource(bool enable)
-{
- kDebug(KARES_DEBUG) << enable << ":" << mURL.toLocalFile();
- if (enable)
- {
- lock(mURL.toLocalFile());
- mDirWatch.startScan();
- }
- else
- {
- lock(QString());
- mDirWatch.stopScan();
- }
-}
-
-bool KAResourceLocal::doLoad(bool)
-{
- if (!KStandardDirs::exists(mURL.toLocalFile()))
- {
- kDebug(KARES_DEBUG) << "File doesn't exist yet.";
- mLoaded = false;
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- clearChanges();
- updateCustomEvents(false); // calendar is now empty
- if (!isActive())
- return false;
- mLoading = true;
- if (!doSave(true)) // save the empty calendar, to create the calendar file
- {
- mLoading = false;
- return false;
- }
- mFileReadOnly = false;
- setCompatibility(KACalendar::Current);
- mLoading = false;
- mLoaded = true;
- setReloaded(true); // the resource has now been loaded at least once
- emit loaded(this);
- return true;
- }
- return loadFile();
-}
-
-void KAResourceLocal::reload()
-{
- kDebug(KARES_DEBUG) << mURL.toLocalFile();
- if (!isOpen())
- return;
- if (mLastModified == readLastModified())
- {
- kDebug(KARES_DEBUG) << "File not modified since last read.";
- QFileInfo fi(mURL.toLocalFile());
- mFileReadOnly = !fi.isWritable();
- return;
- }
- loadFile();
- emit resourceChanged(this);
-}
-
-bool KAResourceLocal::loadFile()
-{
- kDebug(KARES_DEBUG) << mURL.toLocalFile();
- mLoaded = false;
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- clearChanges();
- if (!isActive())
- {
- updateCustomEvents(false); // calendar is now empty
- return false;
- }
- mLoading = true;
- disableChangeNotification();
- bool success = calendar()->load(mURL.toLocalFile());
- enableChangeNotification();
- if (!success)
- {
- mLoading = false;
- updateCustomEvents();
- return false;
- }
- mLastModified = readLastModified();
- QFileInfo fi(mURL.toLocalFile());
- mFileReadOnly = !fi.isWritable();
- checkCompatibility(fileName());
- mLoading = false;
- updateCustomEvents();
- mLoaded = true;
- setReloaded(true); // the resource has now been loaded at least once
- emit loaded(this);
- return true;
-}
-
-bool KAResourceLocal::doSave(bool)
-{
- kDebug(KARES_DEBUG) << mURL.toLocalFile();
- if (mCalIDFunction)
- (*mCalIDFunction)(*calendar()); // write the application ID into the \
calendar
- bool success = calendar()->save(mURL.toLocalFile());
- clearChanges();
- mLastModified = readLastModified();
- emit resourceSaved(this);
- return success;
-}
-
-QDateTime KAResourceLocal::readLastModified()
-{
- QFileInfo fi(mURL.toLocalFile());
- return fi.lastModified();
-}
-
-QString KAResourceLocal::fileName() const
-{
- return mURL.toLocalFile();
-}
-
-bool KAResourceLocal::setFileName(const KUrl& newURL)
-{
- if (mReconfiguring == 1)
- {
- mNewURL = newURL;
- return true;
- }
- if ( !newURL.isLocalFile() || newURL.toLocalFile() == mURL.toLocalFile() )
- return false;
- kDebug(KARES_DEBUG) << newURL.toLocalFile();
- if (isOpen())
- close();
- bool active = isActive();
- if (active)
- enableResource(false);
- mDirWatch.removeFile(mURL.toLocalFile());
- mURL = newURL;
- mDirWatch.addFile(mURL.toLocalFile());
- if (active)
- enableResource(true);
- // Trigger loading the new resource, and ensure that the new configuration is \
saved
- emit locationChanged(this);
- return true;
-}
-
-bool KAResourceLocal::setLocation(const QString& fileName, const QString&)
-{
- KUrl newURL = KUrl::fromPath(fileName);
- return setFileName(newURL);
-}
-
-QString KAResourceLocal::displayLocation() const
-{
- return mURL.toLocalFile();
-}
-
-QString KAResourceLocal::displayType() const
-{
- return i18nc("@info/plain", "File");
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocal.h b/kalarm/resources/resourcelocal.h
deleted file mode 100644
index e4e3456..0000000
--- a/kalarm/resources/resourcelocal.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * resourcelocal.h - KAlarm local calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourcelocal.h in libkcal,
- * Copyright (c) 1998 Preston Brown <pbrown@kde.org>
- * Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef KARESOURCELOCAL_H
-#define KARESOURCELOCAL_H
-
-/* @file resourcelocal.h - KAlarm local calendar resource */
-
-#include "alarmresource.h"
-
-#include <kurl.h>
-#include <kdirwatch.h>
-
-#include <QDateTime>
-
-
-/** A KAlarm calendar resource stored as a local file. */
-class KALARM_RESOURCES_EXPORT KAResourceLocal : public AlarmResource
-{
- Q_OBJECT
- public:
- KAResourceLocal();
- /** Create resource from configuration information stored in a KConfig \
object. */
- explicit KAResourceLocal(const KConfigGroup&);
- /** Create resource for file named @a fileName. */
- KAResourceLocal(CalEvent::Type, const QString& fileName);
- virtual ~KAResourceLocal();
-
- QString fileName() const;
- bool setFileName(const KUrl&);
- virtual QString displayType() const;
- virtual QString displayLocation() const;
- virtual QStringList location() const { return QStringList(fileName()); }
- virtual bool setLocation(const QString& fileName, const QString& = \
QString());
- virtual bool readOnly() const;
- virtual void writeConfig(KConfigGroup&);
- virtual void startReconfig();
- virtual void applyReconfig();
-
- // Override unused virtual functions
- virtual KCal::Todo::List rawTodos(KCal::TodoSortField = \
KCal::TodoSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { return \
KCal::Todo::List(); }
- virtual KCal::Journal::List rawJournals(KCal::JournalSortField = \
KCal::JournalSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { \
return KCal::Journal::List(); }
-
- protected:
- virtual bool doLoad(bool syncCache);
- virtual bool doSave(bool syncCache);
- virtual bool doSave(bool syncCache, KCal::Incidence* i) { return \
AlarmResource::doSave(syncCache, i); }
- QDateTime readLastModified();
- virtual void enableResource(bool enable);
-
- protected slots:
- void reload();
-
- private:
- void init();
- bool loadFile();
- // Inherited virtual methods which should not be used by derived classes.
- using ResourceCalendar::doLoad;
- using ResourceCalendar::doSave;
-
- KUrl mURL;
- KUrl mNewURL; // new file name to be applied by applyReconfig()
- KDirWatch mDirWatch;
- QDateTime mLastModified;
- bool mFileReadOnly; // calendar file is a read-only file
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocal_plugin.cpp \
b/kalarm/resources/resourcelocal_plugin.cpp deleted file mode 100644
index ec8e95f..0000000
--- a/kalarm/resources/resourcelocal_plugin.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * resourcelocal_plugin.cpp - KAlarm local alarm calendar file resource plugin
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocal.h"
-#include "resourcelocalwidget.h"
-
-#include <kglobal.h>
-#include <klocale.h>
-
-extern "C"
-{
- KDE_EXPORT void* init_kalarm_local()
- {
-#ifndef KALARM_STANDALONE
- KGlobal::locale()->insertCatalog("libkcal");
-#endif
- return new KRES::PluginFactory<KAResourceLocal, \
ResourceLocalConfigWidget>();
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocaldir.cpp \
b/kalarm/resources/resourcelocaldir.cpp deleted file mode 100644
index 9c3b608..0000000
--- a/kalarm/resources/resourcelocaldir.cpp
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * resourcelocaldir.cpp - KAlarm local directory calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourcelocaldir.cpp in libkcal (updated to rev 779953,938673,938806),
- * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocaldir.moc"
-
-#include <kcal/calendarlocal.h>
-#include <kcal/event.h>
-
-#include <klocale.h>
-#include <kstandarddirs.h>
-#include <kconfiggroup.h>
-
-#include <QDir>
-#include <QFile>
-#include <QtAlgorithms>
-
-using namespace KCal;
-
-static QDateTime readLastModified(const QString& filePath);
-
-
-KAResourceLocalDir::KAResourceLocalDir()
- : AlarmResource(),
- mDirReadOnly(false)
-{
- init();
-}
-
-KAResourceLocalDir::KAResourceLocalDir(const KConfigGroup& group)
- : AlarmResource(group),
- mDirReadOnly(false)
-{
- mURL = KUrl(group.readPathEntry("CalendarURL", QString()));
- init();
-}
-
-KAResourceLocalDir::KAResourceLocalDir(CalEvent::Type type, const QString& dirName)
- : AlarmResource(type),
- mURL(KUrl::fromPath(dirName)),
- mDirReadOnly(false)
-{
- init();
-}
-
-void KAResourceLocalDir::init()
-{
- setType("dir"); // set resource type
-
- //setSavePolicy(SaveDelayed); // unnecessary for KAlarm, and would override \
base class setting
-
- connect(&mDirWatch, SIGNAL(dirty(QString)), SLOT(slotUpdated(QString)));
- connect(&mDirWatch, SIGNAL(created(QString)), SLOT(slotUpdated(QString)));
- connect(&mDirWatch, SIGNAL(deleted(QString)), SLOT(slotUpdated(QString)));
- mDirWatch.addDir(mURL.toLocalFile(), KDirWatch::WatchFiles);
-
- enableResource(isActive());
-
- // Initially load all files in the directory, then just load changes
- setReloadPolicy(ReloadOnStartup);
-}
-
-KAResourceLocalDir::~KAResourceLocalDir()
-{
- mDirWatch.stopScan();
- if (isOpen())
- close();
-}
-
-void KAResourceLocalDir::writeConfig(KConfigGroup& group)
-{
- group.writePathEntry("CalendarURL", mURL.prettyUrl());
- AlarmResource::writeConfig(group);
-}
-
-void KAResourceLocalDir::startReconfig()
-{
- mNewURL = mURL;
- AlarmResource::startReconfig();
-}
-
-void KAResourceLocalDir::applyReconfig()
-{
- if (mReconfiguring)
- {
- AlarmResource::applyReconfig();
- if (setDirName(mNewURL))
- mReconfiguring = 3; // indicate that location has changed
- AlarmResource::applyReconfig();
- }
-}
-
-bool KAResourceLocalDir::readOnly() const
-{
- return mDirReadOnly || AlarmResource::readOnly();
-}
-
-void KAResourceLocalDir::setReadOnly(bool ro)
-{
- // Re-evaluate the directory's read-only status (since KDirWatch
- // doesn't pick up permissions changes on the directory itself).
- QFileInfo dirInfo(mURL.toLocalFile());
- mDirReadOnly = !dirInfo.isWritable();
- AlarmResource::setReadOnly(ro);
-}
-
-void KAResourceLocalDir::enableResource(bool enable)
-{
- kDebug(KARES_DEBUG) << enable << ":" << mURL.toLocalFile();
- if (enable)
- {
- lock(mURL.toLocalFile());
- mDirWatch.startScan();
- }
- else
- {
- lock(QString());
- mDirWatch.stopScan();
- }
-}
-
-bool KAResourceLocalDir::doOpen()
-{
- QFileInfo dirInfo(mURL.toLocalFile());
- return dirInfo.isDir() && dirInfo.isReadable();
-}
-
-void KAResourceLocalDir::slotUpdated(const QString& filepath)
-{
-#ifdef __GNUC__
-#warning Only reload the individual file which has changed
-#endif
- if (filepath.contains(QRegExp("(~|\\.new|\\.tmp)$"))
- || filepath.startsWith(mURL.toLocalFile() + "/qt_temp."))
- return; // ignore backup or temporary file
- doLoad(false);
-}
-/******************************************************************************
-* Load the files in the local directory, and add their events to our calendar.
-* If 'syncCache' is true, all files are loaded; if false, only changed files
-* are loaded.
-* Events which contain no alarms are ignored..
-* Reply = true if any file in the directory was loaded successfully.
-*/
-bool KAResourceLocalDir::doLoad(bool syncCache)
-{
- kDebug(KARES_DEBUG) << mURL.toLocalFile() << (syncCache ?": load all" :": load \
changes only");
- if (!isActive() || !isOpen())
- return false;
- ModifiedMap oldLastModified;
- CompatibilityMap oldCompatibilityMap;
- Incidence::List changes;
- mLoading = true;
- mLoaded = false;
- disableChangeNotification();
- setCompatibility(KACalendar::ByEvent);
- if (syncCache)
- {
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- clearChanges();
- }
- else
- {
-emit invalidate(this); // necessary until load changes only is fixed
- oldLastModified = mLastModified;
- oldCompatibilityMap = mCompatibilityMap;
- changes = changedIncidences();
- }
- mLastModified.clear();
- mCompatibilityMap.clear();
- QString dirName = mURL.toLocalFile();
- bool success = false;
- bool foundFile = false;
- if (KStandardDirs::exists(dirName) || KStandardDirs::exists(dirName + '/'))
- {
- kDebug(KARES_DEBUG) << "Opening" << dirName;
- FixFunc prompt = PROMPT_PART;
- QFileInfo dirInfo(dirName);
- if (!(dirInfo.isDir() && dirInfo.isReadable()))
- {
- setWrongAlarmType(false, false);
- return false;
- }
- mDirReadOnly = !dirInfo.isWritable();
- QDir dir(dirName, QString(), QDir::Unsorted, QDir::Files | QDir::Readable);
- QStringList entries = dir.entryList(QDir::Files | QDir::Readable);
- QStringList writable = dir.entryList(QDir::Files | QDir::Writable);
- for (int i = 0, end = entries.count(); i < end; ++i)
- {
- // Check the next file in the directory
- QString id = entries[i];
- if (id.contains(QRegExp("(~|\\.new|\\.tmp)$"))
- || id.startsWith(QLatin1String("qt_temp.")))
- continue; // ignore backup or temporary file
- QString fileName = dirName + '/' + id;
- foundFile = true;
-
- if (!syncCache)
- {
- // Only load new or changed events
-#ifdef __GNUC__
-#warning All events are actually loaded, not just new or changed
-#endif
- clearChange(id);
- Event* ev = calendar()->event(id);
- if (ev && changes.indexOf(ev) < 0)
- {
- ModifiedMap::ConstIterator mit = oldLastModified.constFind(id);
- if (mit != oldLastModified.constEnd() && mit.value() == \
readLastModified(fileName))
- {
- // The file hasn't changed, and its event is unchanged
- // in our calendar, so just transfer the event to the
- // new maps without rereading the file.
- mCompatibilityMap[ev] = oldCompatibilityMap[ev];
- mLastModified[id] = mit.value();
- success = true;
- continue;
- }
- }
- // It's either a new file, or it has changed
- if (ev)
- calendar()->deleteEvent(ev);
- }
- // Load the file and check whether it's the current KAlarm format.
- // If not, only prompt the user once whether to convert it.
- if (loadFile(fileName, id, !writable.contains(id), prompt))
- success = true;
- }
- if (!foundFile)
- success = true; // don't return error if there are no files
- }
- else if (syncCache)
- {
- kDebug(KARES_DEBUG) << "Creating" << dirName;
-
- // Create the directory. Use 0775 to allow group-writable if the umask
- // allows it (permissions will be 0775 & ~umask). This is desired e.g. for
- // group-shared directories!
- success = KStandardDirs::makeDir(dirName, 0775);
- mDirReadOnly = false;
- }
-
- if (!syncCache)
- {
- if (mLastModified.isEmpty())
- {
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- }
- else
- {
- // Delete any events in the calendar for which files were not found
- Event::List oldEvents = calendar()->rawEvents();
- for (int i = 0, end = oldEvents.count(); i < end; ++i)
- {
- if (!mCompatibilityMap.contains(oldEvents[i]))
- calendar()->deleteEvent(oldEvents[i]);
- }
- }
- }
-
- setWrongAlarmType(!checkAlarmTypes(*calendar())); // check if it contains only \
wrong alarm types
-
- mLoading = false;
- enableChangeNotification();
- updateCustomEvents();
- if (success)
- {
- mLoaded = true;
- setReloaded(true); // the resource has now been loaded at least once
- emit loaded(this);
- if (!syncCache)
- emit resourceChanged(this);
- }
- return success;
-}
-
-/******************************************************************************
-* Load one file from the local directory, and return its event in 'event'.
-* Any event whose ID is not the same as the file name, or any event not
-* containing alarms, is ignored.
-* Reply = true if the calendar loaded successfully (even if empty).
-*/
-bool KAResourceLocalDir::loadFile(const QString& fileName, const QString& id, bool \
readOnly, FixFunc& prompt)
-{
- bool success = false;
- CalendarLocal calendar(this->calendar()->timeSpec());
- if (!calendar.load(fileName))
- {
- // Loading this file failed, but just assume that it's not a calendar file
- kDebug(KARES_DEBUG) << fileName << "failed";
- }
- else
- {
- KACalendar::Compat compat = checkCompatibility(calendar, fileName, prompt);
- switch (compat)
- {
- case KACalendar::Converted: // user elected to convert. Don't prompt \
again.
- prompt = CONVERT;
- compat = KACalendar::Current;
- break;
- case KACalendar::Convertible: // user elected not to convert. Don't \
prompt again.
- prompt = NO_CONVERT;
- break;
- case KACalendar::Current:
- case KACalendar::Incompatible:
- case KACalendar::ByEvent:
- break;
- }
- kDebug(KARES_DEBUG) << fileName << ": compatibility=" << compat;
- Event::List rawEvents = calendar.rawEvents();
- for (int i = 0, end = rawEvents.count(); i < end; ++i)
- {
- Event* ev = rawEvents[i];
- if (ev->uid() != id)
- {
- kError(KARES_DEBUG) << "Wrong event ID (" << ev->uid();
- continue; // ignore any event with the wrong ID - it shouldn't be \
there!
- }
- Alarm::List alarms = ev->alarms();
- if (!alarms.isEmpty())
- {
- Event* event = ev->clone();
- if (readOnly)
- event->setReadOnly(true);
- this->calendar()->addEvent(event);
- mCompatibilityMap[event] = compat;
- }
- }
- success = true; // at least one file has been opened successfully
- }
- mLastModified[id] = readLastModified(fileName);
- return success;
-}
-
-bool KAResourceLocalDir::doSave(bool)
-{
- kDebug(KARES_DEBUG) << mURL.toLocalFile();
- bool success = true;
- Incidence::List list = addedIncidences();
- list += changedIncidences();
- qSort(list);
- Incidence* last = 0;
- for (int i = 0, end = list.count(); i < end; ++i)
- {
- if (list[i] != last)
- {
- last = list[i];
- if (!doSave(true, last))
- success = false;
- }
- }
- emit resourceSaved(this);
- return success;
-}
-
-bool KAResourceLocalDir::doSave(bool, Incidence* incidence)
-{
- if (mDeletedIncidences.contains(incidence))
- {
- mDeletedIncidences.removeAll(incidence);
- return true;
- }
-
- QString id = incidence->uid();
- QString fileName = mURL.toLocalFile() + '/' + id;
- kDebug(KARES_DEBUG) << fileName;
-
- CalendarLocal cal(calendar()->timeSpec());
- cal.setCustomProperties(calendar()->customProperties()); // copy all VCALENDAR \
custom properties to each file
- if (mCalIDFunction)
- (*mCalIDFunction)(cal); // write the application ID \
into the calendar
- bool success = cal.addIncidence(incidence->clone());
- if (success)
- {
- mDirWatch.stopScan(); // prohibit the dirty() signal and a following reload
- success = cal.save(fileName);
- mDirWatch.startScan();
- clearChange(id);
- mLastModified[id] = readLastModified(fileName);
- }
- return success;
-}
-
-bool KAResourceLocalDir::addEvent(Event* event)
-{
- if (!AlarmResource::addEvent(event))
- return false;
- mCompatibilityMap[event] = KACalendar::Current;
- return true;
-}
-
-bool KAResourceLocalDir::deleteEvent(Event* event)
-{
- kDebug(KARES_DEBUG);
- if (!deleteIncidenceFile(event))
- return false;
- // Remove event from added/changed lists, to avoid it being recreated in \
doSave()
- clearChange(event);
- disableChangeNotification(); // don't record this deletion as pending
- bool success = calendar()->deleteEvent(event);
- if (success)
- mDeletedIncidences.append(event);
- enableChangeNotification();
- return success;
-}
-
-bool KAResourceLocalDir::deleteIncidenceFile(Incidence* incidence)
-{
- QFile file(mURL.toLocalFile() + '/' + incidence->uid());
- if (!file.exists())
- return true;
- mDirWatch.stopScan();
- bool removed = file.remove();
- mDirWatch.startScan();
- return removed;
-}
-
-QString KAResourceLocalDir::dirName() const
-{
- return mURL.toLocalFile();
-}
-
-bool KAResourceLocalDir::setDirName(const KUrl& newURL)
-{
- if (mReconfiguring == 1)
- {
- mNewURL = newURL;
- return true;
- }
- if (!newURL.isLocalFile() || newURL.toLocalFile() == mURL.toLocalFile())
- return false;
- kDebug(KARES_DEBUG) << newURL.toLocalFile();
- if (isOpen())
- close();
- bool active = isActive();
- if (active)
- enableResource(false);
- mDirWatch.removeDir(mURL.toLocalFile());
- mURL = newURL;
- mDirWatch.addDir(mURL.toLocalFile(), KDirWatch::WatchFiles);
- if (active)
- enableResource(true);
- // Trigger loading the new resource, and ensure that the new configuration is \
saved
- emit locationChanged(this);
- return true;
-}
-
-bool KAResourceLocalDir::setLocation(const QString& dirName, const QString&)
-{
- KUrl newURL = KUrl::fromPath(dirName);
- return setDirName(newURL);
-}
-
-QString KAResourceLocalDir::displayLocation() const
-{
- return mURL.toLocalFile();
-}
-
-QString KAResourceLocalDir::displayType() const
-{
- return i18nc("@info/plain Directory in filesystem", "Directory");
-}
-
-QDateTime readLastModified(const QString& filePath)
-{
- QFileInfo fi(filePath);
- return fi.lastModified();
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocaldir.h \
b/kalarm/resources/resourcelocaldir.h deleted file mode 100644
index 683d5ef..0000000
--- a/kalarm/resources/resourcelocaldir.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * resourcelocaldir.h - KAlarm local directory alarm calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourcelocaldir.h in libkcal,
- * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCELOCALDIR_H
-#define RESOURCELOCALDIR_H
-
-/* @file resourcelocaldir.h - KAlarm local directory alarm calendar resource */
-
-#include "alarmresource.h"
-
-#include <kurl.h>
-#include <kdirwatch.h>
-#include <QMap>
-#include <QList>
-
-namespace KCal {
- class Incidence;
-}
-
-
-/** A KAlarm calendar resource stored in a directory as one file per alarm. */
-class KALARM_RESOURCES_EXPORT KAResourceLocalDir : public AlarmResource
-{
- Q_OBJECT
- public:
- KAResourceLocalDir();
- /** Create resource from configuration information stored in a KConfig \
object. */
- explicit KAResourceLocalDir(const KConfigGroup&);
- /** Create resource for directory named @p dirName. */
- KAResourceLocalDir(CalEvent::Type, const QString& dirName);
- virtual ~KAResourceLocalDir();
-
- const KUrl& url() const { return mURL; }
- QString dirName() const;
- bool setDirName(const KUrl&);
- virtual QString displayType() const;
- virtual QString displayLocation() const;
- virtual QStringList location() const { return QStringList(dirName()); }
- virtual bool setLocation(const QString& dirName, const QString& = \
QString());
- virtual bool readOnly() const;
- virtual void setReadOnly(bool);
- virtual bool addEvent(KCal::Event*);
- virtual bool deleteEvent(KCal::Event*);
- virtual void writeConfig(KConfigGroup&);
- virtual void startReconfig();
- virtual void applyReconfig();
-
- // Override unused virtual functions
- virtual KCal::Todo::List rawTodos(KCal::TodoSortField = \
KCal::TodoSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { return \
KCal::Todo::List(); }
- virtual KCal::Journal::List rawJournals(KCal::JournalSortField = \
KCal::JournalSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { \
return KCal::Journal::List(); }
-
- protected:
- virtual bool doOpen();
- /** Load the resource. If 'syncCache' is true, all files in the directory
- * are reloaded. If 'syncCache' is false, only changed files are reloaded. \
*/
- virtual bool doLoad(bool syncCache);
-
- virtual bool doSave(bool syncCache);
- bool doSave(bool syncCache, KCal::Incidence*);
- virtual void enableResource(bool enable);
-
- private slots:
- void slotUpdated(const QString& filepath);
-
- private:
- void init();
- bool loadFile(const QString& fileName, const QString& id, bool \
readOnly, FixFunc& prompt);
- bool deleteIncidenceFile(KCal::Incidence *incidence);
- // Inherited virtual methods which are not used by derived classes
- using ResourceCalendar::doLoad;
- virtual bool doSave() { return false; }
- virtual bool doSave(KCal::Incidence*) { return false; }
-
- KUrl mURL;
- KUrl mNewURL; // new directory to be applied by applyReconfig()
- KDirWatch mDirWatch;
- typedef QMap<QString, QDateTime> ModifiedMap;
- ModifiedMap mLastModified;
- QList<KCal::Incidence*> mDeletedIncidences;
- bool mDirReadOnly; // directory is read-only
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocaldir_plugin.cpp \
b/kalarm/resources/resourcelocaldir_plugin.cpp deleted file mode 100644
index f8a0105..0000000
--- a/kalarm/resources/resourcelocaldir_plugin.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * resourcelocaldir_plugin.cpp - KAlarm local directory alarm calendar resource \
plugin
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocaldir.h"
-#include "resourcelocaldirwidget.h"
-
-#include <kglobal.h>
-#include <klocale.h>
-
-extern "C"
-{
- KDE_EXPORT void* init_kalarm_localdir()
- {
-#ifndef KALARM_STANDALONE
- KGlobal::locale()->insertCatalog("libkcal");
-#endif
- return new KRES::PluginFactory<KAResourceLocalDir, \
ResourceLocalDirConfigWidget>();
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocaldirwidget.cpp \
b/kalarm/resources/resourcelocaldirwidget.cpp deleted file mode 100644
index 608f3e8..0000000
--- a/kalarm/resources/resourcelocaldirwidget.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * resourcelocaldirwidget.cpp - configuration widget for local directory calendar \
resource
- * Program: kalarm
- * Copyright © 2006,2008,2010 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocaldir.h"
-#include "resourcelocaldirwidget.moc"
-
-#include <klocale.h>
-#include <kurlrequester.h>
-#include <kmessagebox.h>
-#include <kdebug.h>
-
-#include <QLabel>
-#include <QGridLayout>
-
-
-ResourceLocalDirConfigWidget::ResourceLocalDirConfigWidget(QWidget* parent)
- : ResourceConfigWidget(parent)
-{
- QGridLayout* layout = new QGridLayout(this);
-
- QLabel* label = new QLabel(i18nc("@label:textbox", "Location:"), this);
- layout->addWidget(label, 1, 0);
- mURL = new KUrlRequester(this);
- mURL->setMode(KFile::Directory | KFile::LocalOnly);
- layout->addWidget(mURL, 1, 1);
-}
-
-void ResourceLocalDirConfigWidget::loadSettings(KRES::Resource* resource)
-{
-// KAResourceLocalDir* res = dynamic_cast<KAResourceLocalDir*>(resource);
- KAResourceLocalDir* res = static_cast<KAResourceLocalDir*>(resource);
- if (!res)
- kError(KARES_DEBUG) << "KAResourceLocalDir: cast failed";
- else
- {
- ResourceConfigWidget::loadSettings(resource);
- mURL->setUrl(res->dirName());
- kDebug(KARES_DEBUG) << "Directory" << mURL->url();
- }
-}
-
-void ResourceLocalDirConfigWidget::saveSettings(KRES::Resource *resource)
-{
-// KAResourceLocalDir* res = dynamic_cast<KAResourceLocalDir*>(resource);
- KAResourceLocalDir* res = static_cast<KAResourceLocalDir*>(resource);
- if (!res)
- kDebug(KARES_DEBUG) << "KAResourceLocalDir: cast failed";
- else
- {
- res->setDirName(mURL->url());
- if (mURL->url().isEmpty())
- {
- KMessageBox::information(this, i18nc("@info", "No location specified. \
The calendar will be invalid."));
- resource->setReadOnly(true);
- }
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocaldirwidget.h \
b/kalarm/resources/resourcelocaldirwidget.h deleted file mode 100644
index 3edad27..0000000
--- a/kalarm/resources/resourcelocaldirwidget.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * resourcelocaldirwidget.h - configuration widget for a local directory calendar \
resource
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCELOCALDIRWIDGET_H
-#define RESOURCELOCALDIRWIDGET_H
-
-/* @file resourcelocaldirwidget.h - configuration widget for a local directory alarm \
calendar resource */
-
-#include "resourcewidget.h"
-#include "kalarm_resources_export.h"
-
-class KUrlRequester;
-
-/**
- Configuration widget for local directory alarm calendar resource.
- @see KAResourceLocalDir
-*/
-class KALARM_RESOURCES_EXPORT ResourceLocalDirConfigWidget : public \
ResourceConfigWidget
-{
- Q_OBJECT
- public:
- explicit ResourceLocalDirConfigWidget(QWidget* parent = 0);
-
- public slots:
- virtual void loadSettings(KRES::Resource*);
- virtual void saveSettings(KRES::Resource*);
-
- private:
- KUrlRequester* mURL;
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocalwidget.cpp \
b/kalarm/resources/resourcelocalwidget.cpp deleted file mode 100644
index 4b10017..0000000
--- a/kalarm/resources/resourcelocalwidget.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * resourcelocalwidget.cpp - configuration widget for a local file calendar \
resource
- * Program: kalarm
- * Copyright © 2006,2008,2010 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourcelocal.h"
-#include "resourcelocalwidget.moc"
-
-#include <kurlrequester.h>
-#include <klocale.h>
-#include <kmessagebox.h>
-#include <kdebug.h>
-
-#include <QLabel>
-#include <QGridLayout>
-
-#include <typeinfo>
-
-
-ResourceLocalConfigWidget::ResourceLocalConfigWidget(QWidget* parent)
- : ResourceConfigWidget(parent)
-{
- QGridLayout* layout = new QGridLayout(this);
-
- QLabel* label = new QLabel(i18nc("@label:textbox", "Location:"), this);
- layout->addWidget(label, 1, 0);
- mURL = new KUrlRequester(this);
- mURL->setFilter(QString::fromLatin1("*.vcs *.ics|%1").arg(i18nc("@info/plain", \
"Calendar Files")));
- layout->addWidget(mURL, 1, 1);
-}
-
-void ResourceLocalConfigWidget::loadSettings(KRES::Resource* resource)
-{
-kDebug(KARES_DEBUG)<<typeid(resource).name();
-// KAResourceLocal* res = dynamic_cast<KAResourceLocal*>(resource);
- KAResourceLocal* res = static_cast<KAResourceLocal*>(resource);
- if (!res)
- kError(KARES_DEBUG) << "KAResourceLocal: cast failed";
- else
- {
- ResourceConfigWidget::loadSettings(resource);
- mURL->setUrl(res->fileName());
-#ifndef NDEBUG
- kDebug(KARES_DEBUG) << "File" << mURL->url() << " type" << res->typeName();
-#endif
- }
-}
-
-void ResourceLocalConfigWidget::saveSettings(KRES::Resource* resource)
-{
-// KAResourceLocal* res = dynamic_cast<KAResourceLocal*>(resource);
- KAResourceLocal* res = static_cast<KAResourceLocal*>(resource);
- if (!res)
- kDebug(KARES_DEBUG) << "KAResourceLocal: cast failed";
- else
- {
- res->setFileName(mURL->url());
- if (mURL->url().isEmpty())
- {
- KMessageBox::information(this, i18nc("@info", "No location specified. \
The calendar will be invalid."));
- resource->setReadOnly(true);
- }
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcelocalwidget.h \
b/kalarm/resources/resourcelocalwidget.h deleted file mode 100644
index c07b1dc..0000000
--- a/kalarm/resources/resourcelocalwidget.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * resourcelocalwidget.h - configuration widget for local file calendar resource
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCELOCALWIDGET_H
-#define RESOURCELOCALWIDGET_H
-
-/* @file resourcelocalwidget.h - configuration widget for local file calendar \
resource */
-
-#include "resourcewidget.h"
-#include "kalarm_resources_export.h"
-
-class KUrlRequester;
-
-/**
- Configuration widget for local file alarm calendar resource.
- @see KAResourceLocal
-*/
-class KALARM_RESOURCES_EXPORT ResourceLocalConfigWidget : public \
ResourceConfigWidget
-{
- Q_OBJECT
- public:
- explicit ResourceLocalConfigWidget(QWidget* parent = 0);
-
- public slots:
- virtual void loadSettings(KRES::Resource*);
- virtual void saveSettings(KRES::Resource*);
-
- private:
- KUrlRequester* mURL;
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourceremote.cpp \
b/kalarm/resources/resourceremote.cpp deleted file mode 100644
index 684d2b6..0000000
--- a/kalarm/resources/resourceremote.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * resourceremote.cpp - KAlarm remote alarm calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourceremote.cpp in kresources (updated to rev 721447),
- * Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourceremote.moc"
-
-//#include <libkdepim/progressmanager.h>
-#include <kcal/calendarlocal.h>
-
-#include <kio/job.h>
-#include <kio/jobuidelegate.h>
-#include <kio/jobclasses.h>
-#include <klocale.h>
-#include <kstandarddirs.h>
-
-using namespace KCal;
-
-
-KAResourceRemote::KAResourceRemote()
- : AlarmResource(),
- mDownloadJob(0),
- mUploadJob(0),
- mShowProgress(true),
- mUseCacheFile(true),
- mRemoteReadOnly(false)
-{
- init();
-}
-
-KAResourceRemote::KAResourceRemote(const KConfigGroup& group)
- : AlarmResource(group),
- mDownloadJob(0),
- mUploadJob(0),
- mShowProgress(true),
- mUseCacheFile(true),
- mRemoteReadOnly(false)
-{
- mDownloadUrl = KUrl(group.readEntry("DownloadUrl"));
- mUploadUrl = KUrl(group.readEntry("UploadUrl"));
- ResourceCached::readConfig(group );
- init();
-}
-
-KAResourceRemote::KAResourceRemote(CalEvent::Type type, const KUrl& downloadUrl, \
const KUrl& uploadUrl)
- : AlarmResource(type),
- mDownloadUrl(downloadUrl),
- mUploadUrl(uploadUrl.isEmpty() ? mDownloadUrl : uploadUrl),
- mDownloadJob(0),
- mUploadJob(0),
- mShowProgress(false),
- mUseCacheFile(false),
- mRemoteReadOnly(false)
-{
- init();
-}
-
-void KAResourceRemote::init()
-{
- setType("remote"); // set resource type
- lock(cacheFile());
-}
-
-KAResourceRemote::~KAResourceRemote()
-{
- if (isOpen())
- close();
-}
-
-void KAResourceRemote::doClose()
-{
- cancelDownload();
- if (mUploadJob)
- {
- mUploadJob->kill();
- mUploadJob = 0;
- }
- AlarmResource::doClose();
-}
-
-void KAResourceRemote::writeConfig(KConfigGroup& group)
-{
- group.writeEntry("DownloadUrl", mDownloadUrl.url());
- group.writeEntry("UploadUrl", mUploadUrl.url());
- AlarmResource::writeConfig(group);
-}
-
-void KAResourceRemote::startReconfig()
-{
- mNewDownloadUrl = mDownloadUrl;
- mNewUploadUrl = mUploadUrl;
- AlarmResource::startReconfig();
-}
-
-void KAResourceRemote::applyReconfig()
-{
- if (mReconfiguring)
- {
- AlarmResource::applyReconfig();
- if (setUrls(mNewDownloadUrl, mNewUploadUrl))
- mReconfiguring = 3; // indicate that location has changed
- AlarmResource::applyReconfig();
- }
-}
-
-bool KAResourceRemote::readOnly() const
-{
- return mRemoteReadOnly || AlarmResource::readOnly();
-}
-
-void KAResourceRemote::enableResource(bool enable)
-{
- if (!enable)
- cancelDownload(false);
-}
-
-bool KAResourceRemote::doLoad(bool syncCache)
-{
- if (mUploadJob)
- syncCache = false; // still uploading, so the cache is up-to-date
- if (mDownloadJob)
- {
- kWarning(KARES_DEBUG) << "Download still in progress";
- return true;
- }
- mLoaded = false;
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- clearChanges();
- if (!isActive())
- {
- updateCustomEvents(false); // calendar is now empty
- return false;
- }
- mLoading = true;
-
- if (mUseCacheFile || !syncCache)
- {
- disableChangeNotification();
- syncCache = !loadFromCache(); // if cache file doesn't exist yet, we need \
to download
- mUseCacheFile = false;
- enableChangeNotification();
- }
- emit resourceChanged(this);
-
- if (!syncCache)
- {
- kDebug(KARES_DEBUG) << mDownloadUrl.prettyUrl() << ": from cache";
- slotLoadJobResult(0);
- }
- else if (!lock()->lock())
- {
- kDebug(KARES_DEBUG) << mDownloadUrl.prettyUrl() << ": cache file is locked - \
something else must be loading the file";
- updateCustomEvents();
- }
- else
- {
- kDebug(KARES_DEBUG) << mDownloadUrl.prettyUrl() << ": downloading...";
- mDownloadJob = KIO::file_copy(mDownloadUrl, KUrl(cacheFile()), -1, \
KIO::Overwrite |
- ((mShowProgress && hasGui()) ? KIO::DefaultFlags : \
KIO::HideProgressInfo));
- connect(mDownloadJob, SIGNAL(result(KJob*)), \
SLOT(slotLoadJobResult(KJob*)));
-#if 0
- if (mShowProgress && hasGui())
- {
- connect(mDownloadJob, SIGNAL(percent(KJob*,ulong)),
- SLOT(slotPercent(KJob*,ulong)));
- emit downloading(this, 0);
- }
-#endif
- }
- return true;
-}
-
-void KAResourceRemote::slotPercent(KJob*, unsigned long percent)
-{
- Q_UNUSED(percent);
-#if 0
- emit downloading(this, percent);
-#endif
-}
-
-void KAResourceRemote::slotLoadJobResult(KJob* job)
-{
- bool err = false;
- if (job)
- {
- emit invalidate(this);
- calendar()->close();
- setWrongAlarmType(false, false);
- clearChanges();
- if (job->error())
- {
- if (hasGui())
- {
- KIO::FileCopyJob* j = qobject_cast<KIO::FileCopyJob*>(job);
- if (j)
- j->ui()->showErrorMessage();
- }
- kError(KARES_DEBUG) << "Resource" << identifier() << " download error:" \
<< job->errorString();
- setEnabled(false);
- err = true;
- }
- else
- {
- kDebug(KARES_DEBUG) << mDownloadUrl.prettyUrl() << ": success";
- setReloaded(true); // the resource has now been downloaded at least \
once
- emit cacheDownloaded(this);
- disableChangeNotification();
- loadFromCache();
- enableChangeNotification();
- }
-
-#if 0
- emit downloading(this, (unsigned long)-1);
-#endif
- }
- mDownloadJob = 0;
-
- if (!err)
- {
- checkCompatibility(cacheFile());
- mLoaded = true;
- }
- mLoading = false;
- lock()->unlock();
- updateCustomEvents();
- emit loaded(this);
- if (job && !err)
- emit resourceChanged(this);
-}
-
-void KAResourceRemote::cancelDownload(bool disable)
-{
- if (mDownloadJob)
- {
- mDownloadJob->kill();
- mDownloadJob = 0;
- if (disable)
- setEnabled(false);
-#if 0
- emit downloading(this, (unsigned long)-1);
-#endif
- mLoading = false;
- lock()->unlock();
- updateCustomEvents();
- emit loaded(this);
- }
-}
-
-bool KAResourceRemote::doSave(bool syncCache)
-{
- kDebug(KARES_DEBUG) << mUploadUrl.prettyUrl();
- if (readOnly() || !hasChanges())
- return true;
- if (mDownloadJob)
- {
- kWarning(KARES_DEBUG) << "Download still in progress";
- return false;
- }
- if (mUploadJob)
- {
- kWarning(KARES_DEBUG) << "Upload still in progress";
- return false;
- }
-
- mChangedIncidences = allChanges();
- if (mCalIDFunction)
- (*mCalIDFunction)(*calendar()); // write the application ID into the \
calendar
- saveToCache();
- if (syncCache)
- {
- mUploadJob = KIO::file_copy(KUrl(cacheFile()), mUploadUrl, -1, \
KIO::Overwrite | (hasGui()?KIO::DefaultFlags:KIO::HideProgressInfo));
- connect(mUploadJob, SIGNAL(result(KJob*)), SLOT(slotSaveJobResult(KJob*)));
- }
- return true;
-}
-
-void KAResourceRemote::slotSaveJobResult(KJob* job)
-{
- if (job->error())
- {
- if (hasGui())
- {
- KIO::FileCopyJob* j = qobject_cast<KIO::FileCopyJob*>(job);
- if (j)
- j->ui()->showErrorMessage();
- }
- kError(KARES_DEBUG) << "Resource" << identifier() << " upload error:" << \
job->errorString();
- }
- else
- {
- kDebug(KARES_DEBUG) << mUploadUrl.prettyUrl() << ": success";
- clearChanges();
- }
-
- mUploadJob = 0;
- emit resourceSaved(this);
- if (closeAfterSave())
- close();
-}
-
-bool KAResourceRemote::setUrls(const KUrl& downloadUrl, const KUrl& uploadUrl)
-{
- if (mReconfiguring == 1)
- {
- mNewDownloadUrl = downloadUrl;
- mNewUploadUrl = uploadUrl;
- return true;
- }
- if (downloadUrl.equals(mDownloadUrl)
- && uploadUrl.equals(mUploadUrl))
- return false;
- kDebug(KARES_DEBUG) << downloadUrl.prettyUrl() << "," << uploadUrl.prettyUrl();
- if (isOpen())
- close();
- bool active = isActive();
- if (active)
- enableResource(false);
- mDownloadUrl = downloadUrl;
- mUploadUrl = uploadUrl;
- if (active)
- enableResource(true);
- // Trigger loading the new resource, and ensure that the new configuration is \
saved
- emit locationChanged(this);
- return true;
-}
-
-bool KAResourceRemote::setLocation(const QString& downloadUrl, const QString& \
uploadUrl)
-{
- return setUrls(KUrl(downloadUrl), KUrl(uploadUrl));
-}
-
-QStringList KAResourceRemote::location() const
-{
- return QStringList(downloadUrl().url()) << uploadUrl().url();
-}
-
-QString KAResourceRemote::displayLocation() const
-{
- return mDownloadUrl.prettyUrl();
-}
-
-QString KAResourceRemote::displayType() const
-{
- return i18nc("@info/plain", "URL");
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourceremote.h b/kalarm/resources/resourceremote.h
deleted file mode 100644
index 8fb89c2..0000000
--- a/kalarm/resources/resourceremote.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * resourceremote.h - KAlarm remote alarm calendar resource
- * Program: kalarm
- * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
- * Based on resourceremote.h in kresources,
- * Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCEREMOTE_H
-#define RESOURCEREMOTE_H
-
-/* @file resourceremote.h - KAlarm remote alarm calendar resource */
-
-#include "alarmresource.h"
-
-#include <kcal/incidence.h>
-#include <kurl.h>
-
-class KJob;
-
-namespace KIO {
- class FileCopyJob;
- class Job;
-}
-namespace KPIM { class ProgressItem; }
-namespace KCal { class CalendarLocal; }
-
-
-/** A KAlarm calendar resource stored as a remote file. */
-class KALARM_RESOURCES_EXPORT KAResourceRemote : public AlarmResource
-{
- Q_OBJECT
- public:
- KAResourceRemote();
- /** Create resource from configuration information stored in a KConfig \
object. */
- explicit KAResourceRemote(const KConfigGroup&);
- /** Create remote resource.
- * @param downloadUrl URL used to download iCalendar file
- * @param uploadUrl URL used to upload iCalendar file. */
- KAResourceRemote(CalEvent::Type, const KUrl& downloadUrl, const KUrl& \
uploadUrl = KUrl());
- virtual ~KAResourceRemote();
- bool setUrls(const KUrl& downloadUrl, const KUrl& uploadUrl);
- KUrl downloadUrl() const { return mDownloadUrl; }
- KUrl uploadUrl() const { return mUploadUrl; }
- virtual QString displayType() const;
- virtual QString displayLocation() const;
- virtual QStringList location() const;
- virtual bool setLocation(const QString& downloadUrl, const QString& \
uploadUrl);
- virtual bool readOnly() const;
- virtual void showProgress(bool show) { mShowProgress = show; }
- virtual void writeConfig(KConfigGroup&);
- virtual void startReconfig();
- virtual void applyReconfig();
- virtual bool isSaving() { return mUploadJob; }
- virtual bool cached() const { return true; }
-
- // Override abstract virtual functions
- virtual KCal::Todo::List rawTodos(KCal::TodoSortField = \
KCal::TodoSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { return \
KCal::Todo::List(); }
- virtual KCal::Journal::List rawJournals(KCal::JournalSortField = \
KCal::JournalSortUnsorted, KCal::SortDirection = KCal::SortDirectionAscending) { \
return KCal::Journal::List(); }
-
- public slots:
- virtual void cancelDownload(bool disable = true);
-
- protected:
- virtual bool doLoad(bool syncCache);
- virtual bool doSave(bool syncCache);
- virtual bool doSave(bool syncCache, KCal::Incidence* i) { return \
AlarmResource::doSave(syncCache, i); }
- virtual void doClose();
- virtual void enableResource(bool enable);
-
- private slots:
- void slotLoadJobResult(KJob*);
- void slotSaveJobResult(KJob*);
- void slotPercent(KJob*, unsigned long percent);
-
- private:
- void init();
- // Inherited virtual methods which are not used by derived classes
- using ResourceCalendar::doLoad;
- virtual bool doSave() { return false; }
- virtual bool doSave(KCal::Incidence*) { return false; }
-
- KUrl mDownloadUrl;
- KUrl mUploadUrl;
- KIO::FileCopyJob* mDownloadJob;
- KIO::FileCopyJob* mUploadJob;
- KCal::Incidence::List mChangedIncidences;
- KUrl mNewDownloadUrl; // new download URL to be \
applied by applyReconfig()
- KUrl mNewUploadUrl; // new upload URL to be applied \
by applyReconfig()
- bool mShowProgress; // emit download progress \
signals
- bool mUseCacheFile; // true to initially use cache \
until file can be downloaded
- bool mRemoteReadOnly; // the remote file is read-only
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourceremote_plugin.cpp \
b/kalarm/resources/resourceremote_plugin.cpp deleted file mode 100644
index de3bff6..0000000
--- a/kalarm/resources/resourceremote_plugin.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * resourceremote_plugin.cpp - KAlarm remote alarm calendar file resource plugin
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourceremote.h"
-#include "resourceremotewidget.h"
-
-#include <kglobal.h>
-#include <klocale.h>
-
-extern "C"
-{
- KDE_EXPORT void* init_kalarm_remote()
- {
-#ifndef KALARM_STANDALONE
- KGlobal::locale()->insertCatalog("libkcal");
- KGlobal::locale()->insertCatalog("kres_remote");
-#endif
- return new KRES::PluginFactory<KAResourceRemote, \
ResourceRemoteConfigWidget>();
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourceremotewidget.cpp \
b/kalarm/resources/resourceremotewidget.cpp deleted file mode 100644
index 72b42ab..0000000
--- a/kalarm/resources/resourceremotewidget.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * resourceremotewidget.cpp - configuration widget for a remote file calendar \
resource
- * Program: kalarm
- * Copyright © 2006,2008 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "resourceremote.h"
-#include "resourceremotewidget.moc"
-
-#include <kcal/resourcecachedconfig.h>
-
-#include <kurlrequester.h>
-#include <klocale.h>
-#include <kmessagebox.h>
-#include <kdebug.h>
-
-#include <QLabel>
-#include <QGridLayout>
-
-
-ResourceRemoteConfigWidget::ResourceRemoteConfigWidget(QWidget* parent)
- : ResourceConfigWidget(parent)
-{
- QGridLayout* layout = new QGridLayout(this);
-
- QLabel* label = new QLabel(i18nc("@label:textbox", "Download from:"), this);
- layout->addWidget(label, 1, 0);
- mDownloadUrl = new KUrlRequester(this);
- mDownloadUrl->setMode(KFile::File);
- layout->addWidget(mDownloadUrl, 1, 1);
-
- label = new QLabel(i18nc("@label:textbox", "Upload to:"), this);
- layout->addWidget(label, 2, 0);
- mUploadUrl = new KUrlRequester(this);
- mUploadUrl->setMode(KFile::File);
- layout->addWidget(mUploadUrl, 2, 1);
-
- mReloadConfig = new KCal::ResourceCachedReloadConfig(this);
- layout->addWidget(mReloadConfig, 3, 0, 1, 2);
-
- mSaveConfig = new KCal::ResourceCachedSaveConfig(this);
- layout->addWidget(mSaveConfig, 4, 0, 1, 2);
-}
-
-void ResourceRemoteConfigWidget::loadSettings(KRES::Resource* resource)
-{
-// KAResourceRemote* res = dynamic_cast<KAResourceRemote*>(resource);
- KAResourceRemote* res = static_cast<KAResourceRemote*>(resource);
- if (!res)
- kError(KARES_DEBUG) << "KAResourceRemote: cast failed";
- else
- {
- ResourceConfigWidget::loadSettings(resource);
- mDownloadUrl->setUrl(res->downloadUrl().url());
- mUploadUrl->setUrl(res->uploadUrl().url());
- mReloadConfig->loadSettings(res);
- mSaveConfig->loadSettings(res);
-#ifndef NDEBUG
- kDebug(KARES_DEBUG) << "File" << mDownloadUrl->url() << " type" << \
res->typeName();
-#endif
- }
-}
-
-void ResourceRemoteConfigWidget::saveSettings(KRES::Resource* resource)
-{
-// KAResourceRemote* res = dynamic_cast<KAResourceRemote*>(resource);
- KAResourceRemote* res = static_cast<KAResourceRemote*>(resource);
- if (!res)
- kDebug(KARES_DEBUG) << "KAResourceRemote: cast failed";
- else
- {
- res->setUrls(mDownloadUrl->url(), mUploadUrl->url());
- mReloadConfig->saveSettings(res);
- mSaveConfig->saveSettings(res);
-
- if (mUploadUrl->url().isEmpty() && !resource->readOnly())
- {
- KMessageBox::information(this, i18nc("@info", "You have specified no \
upload URL: the alarm calendar will be read-only."),
- "RemoteResourseNoUploadURL");
- resource->setReadOnly(true);
- }
- }
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourceremotewidget.h \
b/kalarm/resources/resourceremotewidget.h deleted file mode 100644
index d32e607..0000000
--- a/kalarm/resources/resourceremotewidget.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * resourceremotewidget.h - configuration widget for remote file calendar \
resource
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCEREMOTEWIDGET_H
-#define RESOURCEREMOTEWIDGET_H
-
-/* @file resourceremotewidget.h - configuration widget for remote file calendar \
resource */
-
-#include "resourcewidget.h"
-#include "kalarm_resources_export.h"
-
-class KUrlRequester;
-namespace KRES { class Resource; }
-namespace KCal {
- class ResourceCachedReloadConfig;
- class ResourceCachedSaveConfig;
-}
-
-/**
- Configuration widget for remote file alarm calendar resource.
- @see KAResourceRemote
-*/
-class KALARM_RESOURCES_EXPORT ResourceRemoteConfigWidget : public \
ResourceConfigWidget
-{
- Q_OBJECT
- public:
- explicit ResourceRemoteConfigWidget(QWidget* parent = 0);
-
- public slots:
- virtual void loadSettings(KRES::Resource*);
- virtual void saveSettings(KRES::Resource*);
-
- private:
- KUrlRequester* mDownloadUrl;
- KUrlRequester* mUploadUrl;
- KCal::ResourceCachedReloadConfig* mReloadConfig;
- KCal::ResourceCachedSaveConfig* mSaveConfig;
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcewidget.cpp \
b/kalarm/resources/resourcewidget.cpp deleted file mode 100644
index 57fa318..0000000
--- a/kalarm/resources/resourcewidget.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * resourcewidget.cpp - base class for resource configuration widgets
- * Program: kalarm
- * Copyright © 2006,2009 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h"
-
-#include "alarmresource.h"
-#include "resourcewidget.moc"
-
-#include <kmessagebox.h>
-#include <klocale.h>
-
-//#include <typeinfo>
-
-
-ResourceConfigWidget::ResourceConfigWidget(QWidget* parent)
- : KRES::ConfigWidget(parent)
-{
- resize(245, 115);
-}
-
-void ResourceConfigWidget::loadSettings(KRES::Resource* resource)
-{
-// AlarmResource* res = dynamic_cast<AlarmResource*>(resource);
- AlarmResource* res = static_cast<AlarmResource*>(resource);
- if (res)
- connect(res, SIGNAL(notWritable(AlarmResource*)), \
SLOT(slotNotWritable(AlarmResource*)));
-}
-
-/******************************************************************************
-* Called when the user tries to change the resource to read-write, but this is
-* not allowed because the resource was not written by KAlarm (or was written by
-* a later version of KAlarm).
-* Display an error message.
-*/
-void ResourceConfigWidget::slotNotWritable(AlarmResource* resource)
-{
- QString text = i18nc("@info", "Calendar <resource>%1</resource> cannot be made \
writable since it either was not created by <application>KAlarm</application>, or was \
created by a newer version of <application>KAlarm</application>", \
resource->resourceName());
- KMessageBox::sorry(this, text);
-}
-
-// vim: et sw=4:
diff --git a/kalarm/resources/resourcewidget.h b/kalarm/resources/resourcewidget.h
deleted file mode 100644
index 8ecd624..0000000
--- a/kalarm/resources/resourcewidget.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * resourcewidget.h - base class for resource configuration widgets
- * Program: kalarm
- * Copyright © 2006 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef RESOURCEWIDGET_H
-#define RESOURCEWIDGET_H
-
-/* @file resourcewidget.h - base class for resource configuration widgets */
-
-#include <kresources/configwidget.h>
-
-class AlarmResource;
-
-/**
- Configuration widget for alarm calendar resource.
- @see AlarmResource
-*/
-class ResourceConfigWidget : public KRES::ConfigWidget
-{
- Q_OBJECT
- public:
- explicit ResourceConfigWidget(QWidget* parent = 0);
-
- public slots:
- virtual void loadSettings(KRES::Resource*);
-
- private slots:
- void slotNotWritable(AlarmResource*);
-};
-
-#endif
-
-// vim: et sw=4:
diff --git a/kalarm/templatelistfiltermodel.cpp b/kalarm/templatelistfiltermodel.cpp
deleted file mode 100644
index 56f18db..0000000
--- a/kalarm/templatelistfiltermodel.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * templatelistfiltermodel.cpp - proxy model class for lists of alarm templates
- * Program: kalarm
- * Copyright © 2007,2009-2011 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "kalarm.h" //krazy:exclude=includes (kalarm.h must be first)
-#include "templatelistfiltermodel.h"
-
-#include <KAlarmCal/kaevent.h>
-#include <KAlarmCal/kacalendar.h>
-
-#include <kdebug.h>
-
-using namespace KAlarmCal;
-
-// TemplateListFilterModel provides sorting and filtering for the alarm list model.
-
-
-void TemplateListFilterModel::setTypeFilter(KAEvent::Actions type)
-{
- if (type != mTypeFilter)
- {
- mTypeFilter = type;
- invalidateFilter();
- }
-}
-
-void TemplateListFilterModel::setTypesEnabled(KAEvent::Actions type)
-{
- if (type != mTypesEnabled)
- {
- mTypesEnabled = type;
- invalidateFilter();
- }
-}
-
-bool TemplateListFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex&) \
const
-{
- QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0);
- if (sourceModel()->data(sourceIndex, EventListModel::StatusRole).toInt() != \
CalEvent::TEMPLATE)
- return false;
- if (mTypeFilter == KAEvent::ACT_ALL)
- return true;
- KAEvent::Actions type = \
static_cast<EventListModel*>(sourceModel())->event(sourceIndex)->actionTypes();
- if (type == KAEvent::ACT_DISPLAY_COMMAND)
- type = KAEvent::ACT_DISPLAY;
- return type & mTypeFilter;
-}
-
-bool TemplateListFilterModel::filterAcceptsColumn(int sourceCol, const QModelIndex&) \
const
-{
- return sourceCol == EventListModel::TemplateNameColumn
- || sourceCol == EventListModel::TypeColumn;
-}
-
-QModelIndex TemplateListFilterModel::mapFromSource(const QModelIndex& sourceIndex) \
const
-{
- int proxyColumn;
- switch (sourceIndex.column())
- {
- case EventListModel::TypeColumn:
- proxyColumn = TypeColumn;
- break;
- case EventListModel::TemplateNameColumn:
- proxyColumn = TemplateNameColumn;
- break;
- default:
- return QModelIndex();
- }
- QModelIndex ix = EventListFilterModel::mapFromSource(sourceIndex);
- return index(ix.row(), proxyColumn, ix.parent());
-}
-
-QModelIndex TemplateListFilterModel::mapToSource(const QModelIndex& proxyIndex) \
const
-{
- int sourceColumn;
- switch (proxyIndex.column())
- {
- case TypeColumn:
- sourceColumn = EventListModel::TypeColumn;
- break;
- case TemplateNameColumn:
- sourceColumn = EventListModel::TemplateNameColumn;
- break;
- default:
- return QModelIndex();
- }
- return EventListFilterModel::mapToSource(proxyIndex);
-}
-
-Qt::ItemFlags TemplateListFilterModel::flags(const QModelIndex& index) const
-{
- QModelIndex sourceIndex = mapToSource(index);
- Qt::ItemFlags f = sourceModel()->flags(sourceIndex);
- if (mTypesEnabled == KAEvent::ACT_ALL)
- return f;
- KAEvent::Actions type = \
static_cast<EventListModel*>(sourceModel())->event(sourceIndex)->actionTypes();
- if (type == KAEvent::ACT_DISPLAY_COMMAND)
- type = KAEvent::ACT_DISPLAY;
- if (!(type & mTypesEnabled))
- f = static_cast<Qt::ItemFlags>(f & ~(Qt::ItemIsEnabled | \
Qt::ItemIsSelectable));
- return f;
-}
-
-// vim: et sw=4:
diff --git a/kalarm/templatelistfiltermodel.h b/kalarm/templatelistfiltermodel.h
deleted file mode 100644
index 46c3354..0000000
--- a/kalarm/templatelistfiltermodel.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * templatelistfiltermodel.h - proxy model class for lists of alarm templates
- * Program: kalarm
- * Copyright © 2007,2009,2010 by David Jarvie <djarvie@kde.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef TEMPLATELISTFILTERMODEL_H
-#define TEMPLATELISTFILTERMODEL_H
-
-#include "kalarm.h"
-
-#include "eventlistmodel.h"
-
-
-class TemplateListFilterModel : public EventListFilterModel
-{
- Q_OBJECT
- public:
- enum { // data columns
- TypeColumn, TemplateNameColumn,
- ColumnCount
- };
-
- explicit TemplateListFilterModel(EventListModel* baseModel, QObject* parent \
= 0)
- : EventListFilterModel(baseModel, parent),
- mTypesEnabled(KAEvent::ACT_ALL),
- mTypeFilter(KAEvent::ACT_ALL) {}
- void setTypeFilter(KAEvent::Actions);
- void setTypesEnabled(KAEvent::Actions);
- virtual QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
- virtual QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
- virtual Qt::ItemFlags flags(const QModelIndex&) const;
-
- protected:
- virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& \
sourceParent) const;
- virtual bool filterAcceptsColumn(int sourceCol, const QModelIndex& \
sourceParent) const;
-
- private:
- KAEvent::Actions mTypesEnabled; // disable types not in this mask
- KAEvent::Actions mTypeFilter; // hide types not in this mask
-};
-
-#endif // TEMPLATELISTFILTERMODEL_H
-
-// vim: et sw=4:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic