File indexing completed on 2024-11-24 04:42:28
0001 /* 0002 * datamodel.cpp - model independent access to calendar functions 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2020 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "datamodel.h" 0010 0011 #include "fileresourcedatamodel.h" 0012 #define DATA_MODEL FileResourceDataModel 0013 0014 0015 void DataModel::initialise() 0016 { 0017 DATA_MODEL::instance(); 0018 // Record in kalarmrc, for information only, which backend is in use. 0019 Preferences::setBackend(ResourceDataModelBase::mInstance->dataStorageBackend()); 0020 Preferences::self()->save(); 0021 } 0022 0023 void DataModel::terminate() 0024 { 0025 if (ResourceDataModelBase::mInstance) 0026 ResourceDataModelBase::mInstance->terminate(); 0027 } 0028 0029 void DataModel::reload() 0030 { 0031 if (ResourceDataModelBase::mInstance) 0032 ResourceDataModelBase::mInstance->reload(); 0033 } 0034 0035 bool DataModel::reload(Resource& resource) 0036 { 0037 return ResourceDataModelBase::mInstance && ResourceDataModelBase::mInstance->reload(resource); 0038 } 0039 0040 bool DataModel::isMigrationComplete() 0041 { 0042 return ResourceDataModelBase::mInstance && ResourceDataModelBase::mInstance->isMigrationComplete(); 0043 } 0044 0045 void DataModel::removeDuplicateResources() 0046 { 0047 if (ResourceDataModelBase::mInstance) 0048 ResourceDataModelBase::mInstance->removeDuplicateResources(); 0049 } 0050 0051 void DataModel::widgetNeedsDatabase(QWidget* widget) 0052 { 0053 if (ResourceDataModelBase::mInstance) 0054 ResourceDataModelBase::mInstance->widgetNeedsDatabase(widget); 0055 } 0056 0057 ResourceCreator* DataModel::createResourceCreator(KAlarmCal::CalEvent::Type defaultType, QWidget* parent) 0058 { 0059 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->createResourceCreator(defaultType, parent) : nullptr; 0060 } 0061 0062 void DataModel::updateCalendarToCurrentFormat(Resource& resource, bool ignoreKeepFormat, QObject* parent) 0063 { 0064 if (ResourceDataModelBase::mInstance) 0065 ResourceDataModelBase::mInstance->updateCalendarToCurrentFormat(resource, ignoreKeepFormat, parent); 0066 } 0067 0068 ResourceListModel* DataModel::createResourceListModel(QObject* parent) 0069 { 0070 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->createResourceListModel(parent) : nullptr; 0071 } 0072 0073 ResourceFilterCheckListModel* DataModel::createResourceFilterCheckListModel(QObject* parent) 0074 { 0075 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->createResourceFilterCheckListModel(parent) : nullptr; 0076 } 0077 0078 AlarmListModel* DataModel::createAlarmListModel(QObject* parent) 0079 { 0080 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->createAlarmListModel(parent) : nullptr; 0081 } 0082 0083 AlarmListModel* DataModel::allAlarmListModel() 0084 { 0085 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->allAlarmListModel() : nullptr; 0086 } 0087 0088 TemplateListModel* DataModel::createTemplateListModel(QObject* parent) 0089 { 0090 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->createTemplateListModel(parent) : nullptr; 0091 } 0092 0093 TemplateListModel* DataModel::allTemplateListModel() 0094 { 0095 return ResourceDataModelBase::mInstance ? ResourceDataModelBase::mInstance->allTemplateListModel() : nullptr; 0096 } 0097 0098 // vim: et sw=4: