SVN_SILENT made messages (.desktop file)
[kdepim.git] / incidenceeditor-ng / incidencewhatwhere.cpp
blobd01b7cc7d81b9f335cc0a65ec6a1251ceef5e546
1 /*
2 Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org>
3 Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
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 #include "incidencewhatwhere.h"
22 #ifdef KDEPIM_MOBILE_UI
23 #include "ui_dialogmobile.h"
24 #include "ui_dialogmoremobile.h"
25 #else
26 #include "ui_dialogdesktop.h"
27 #endif
29 #include <QDebug>
30 #include <KLocalizedString>
32 using namespace IncidenceEditorNG;
34 IncidenceWhatWhere::IncidenceWhatWhere(Ui::EventOrTodoDesktop *ui)
35 : IncidenceEditor(0), mUi(ui)
37 setObjectName("IncidenceWhatWhere");
38 connect(mUi->mSummaryEdit, &QLineEdit::textChanged, this, &IncidenceWhatWhere::checkDirtyStatus);
39 connect(mUi->mLocationEdit, &QLineEdit::textChanged, this, &IncidenceWhatWhere::checkDirtyStatus);
42 void IncidenceWhatWhere::load(const KCalCore::Incidence::Ptr &incidence)
44 qDebug();
45 mLoadedIncidence = incidence;
46 if (mLoadedIncidence) {
47 mUi->mSummaryEdit->setText(mLoadedIncidence->summary());
48 mUi->mLocationEdit->setText(mLoadedIncidence->location());
49 } else {
50 mUi->mSummaryEdit->clear();
51 mUi->mLocationEdit->clear();
54 mUi->mLocationEdit->setVisible(type() != KCalCore::Incidence::TypeJournal);
55 mUi->mLocationLabel->setVisible(type() != KCalCore::Incidence::TypeJournal);
57 mWasDirty = false;
60 void IncidenceWhatWhere::save(const KCalCore::Incidence::Ptr &incidence)
62 Q_ASSERT(incidence);
63 incidence->setSummary(mUi->mSummaryEdit->text());
64 incidence->setLocation(mUi->mLocationEdit->text());
67 bool IncidenceWhatWhere::isDirty() const
69 if (mLoadedIncidence) {
70 return
71 (mUi->mSummaryEdit->text() != mLoadedIncidence->summary()) ||
72 (mUi->mLocationEdit->text() != mLoadedIncidence->location());
73 } else {
74 return
75 mUi->mSummaryEdit->text().isEmpty() &&
76 mUi->mLocationEdit->text().isEmpty();
80 bool IncidenceWhatWhere::isValid() const
82 if (mUi->mSummaryEdit->text().isEmpty()) {
83 qDebug() << "Specify a title";
84 mLastErrorString = i18nc("@info", "Please specify a title.");
85 return false;
86 } else {
87 mLastErrorString.clear();
88 return true;
92 void IncidenceWhatWhere::validate()
94 if (mUi->mSummaryEdit->text().isEmpty()) {
95 mUi->mSummaryEdit->setFocus();