Make the KOrganizer plugin loading work again.
[kdepim.git] / incidenceeditor-ng / src / incidenceeditor-ng.h
blobcd770a695d8037286ae270f9805cae56e1189e7c
1 /*
2 Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org>
3 Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
21 #ifndef INCIDENCEEDITOR_NG_H
22 #define INCIDENCEEDITOR_NG_H
24 #include "incidenceeditors_ng_export.h"
26 #include <KCalCore/Incidence>
27 #include <AkonadiCore/Item>
28 namespace IncidenceEditorNG
31 /**
32 * KCal Incidences are complicated objects. The user interfaces to create/modify
33 * are therefore complex too. The IncedenceEditor class is a divide and conquer
34 * approach to this complexity. An IncidenceEditor is an editor for a specific
35 * part(s) of an Incidence.
37 class INCIDENCEEDITORS_NG_EXPORT IncidenceEditor : public QObject
39 Q_OBJECT
40 public:
41 virtual ~IncidenceEditor();
43 /**
44 * Load the values of @param incidence into the editor widgets. The passed
45 * incidence is kept for comparing with the current values of the editor.
47 virtual void load(const KCalCore::Incidence::Ptr &incidence) = 0;
48 /// This was introduced to replace categories with Akonadi::Tags
49 virtual void load(const Akonadi::Item &item);
51 /**
52 * Store the current values of the editor into @param incidince.
54 virtual void save(const KCalCore::Incidence::Ptr &incidence) = 0;
55 /// This was introduced to replace categories with Akonadi::Tags
56 virtual void save(Akonadi::Item &item);
58 /**
59 * Returns whether or not the current values in the editor differ from the
60 * initial values.
62 virtual bool isDirty() const = 0;
64 /**
65 * Returns whether or not the content of this editor is valid. The default
66 * implementation returns always true.
68 virtual bool isValid() const;
70 /**
71 Returns the last error, which is set in isValid() on error,
72 and cleared on success.
74 QString lastErrorString() const;
76 /**
77 * Sets focus on the invalid field.
79 virtual void focusInvalidField();
81 /**
82 * Returns the type of the Incidence that is currently loaded.
84 KCalCore::IncidenceBase::IncidenceType type() const;
86 /** Convenience method to get a pointer for a specific const Incidence Type. */
87 template <typename IncidenceT>
88 QSharedPointer<IncidenceT> incidence() const
90 return mLoadedIncidence.dynamicCast<IncidenceT>();
93 /**
94 Re-implement this and print important member values and widget
95 enabled/disabled states that could have lead to isDirty() returning
96 true when the user didn't do any interaction with the editor.
98 This method is called in CombinedIncidenceEditor before crashing
99 due to assert( !editor->isDirty() )
101 virtual void printDebugInfo() const;
103 Q_SIGNALS:
105 * Signals whether the dirty status of this editor has changed. The new dirty
106 * status is passed as argument.
108 void dirtyStatusChanged(bool isDirty);
110 public Q_SLOTS:
112 * Checks if the dirty status has changed until last check and emits the
113 * dirtyStatusChanged signal if needed.
115 void checkDirtyStatus();
117 protected:
118 /** Only subclasses can instantiate IncidenceEditors */
119 IncidenceEditor(QObject *parent = Q_NULLPTR);
121 template <typename IncidenceT>
122 QSharedPointer<IncidenceT> incidence(const KCalCore::Incidence::Ptr &inc)
124 return inc.dynamicCast<IncidenceT>();
127 protected:
128 KCalCore::Incidence::Ptr mLoadedIncidence;
129 mutable QString mLastErrorString;
130 bool mWasDirty;
131 bool mLoadingIncidence;
134 } // IncidenceEditorNG
136 #endif // INCIDENCEEDITOR_H