Incidenceeditor

incidencewhatwhere.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Bertjan Broeksema <broeksema@kde.org>
3 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "incidencewhatwhere.h"
9using namespace Qt::Literals::StringLiterals;
10
11#include "ui_dialogdesktop.h"
12
13#include "incidenceeditor_debug.h"
14#include <KLocalizedString>
15
16using namespace IncidenceEditorNG;
17
18IncidenceWhatWhere::IncidenceWhatWhere(Ui::EventOrTodoDesktop *ui)
19 : IncidenceEditor(nullptr)
20 , mUi(ui)
21{
22 setObjectName("IncidenceWhatWhere"_L1);
23 connect(mUi->mSummaryEdit, &QLineEdit::textChanged, this, &IncidenceWhatWhere::checkDirtyStatus);
24 connect(mUi->mLocationEdit, &QLineEdit::textChanged, this, &IncidenceWhatWhere::checkDirtyStatus);
25}
26
28{
29 qCDebug(INCIDENCEEDITOR_LOG);
30 mLoadedIncidence = incidence;
31 if (mLoadedIncidence) {
32 mUi->mSummaryEdit->setText(mLoadedIncidence->summary());
33 mUi->mLocationEdit->setText(mLoadedIncidence->location());
34 } else {
35 mUi->mSummaryEdit->clear();
36 mUi->mLocationEdit->clear();
37 }
38
39 mUi->mLocationEdit->setVisible(type() != KCalendarCore::Incidence::TypeJournal);
40 mUi->mLocationLabel->setVisible(type() != KCalendarCore::Incidence::TypeJournal);
41
42 mWasDirty = false;
43}
44
46{
47 Q_ASSERT(incidence);
48 incidence->setSummary(mUi->mSummaryEdit->text());
49 incidence->setLocation(mUi->mLocationEdit->text());
50}
51
53{
54 if (mLoadedIncidence) {
55 return (mUi->mSummaryEdit->text() != mLoadedIncidence->summary()) || (mUi->mLocationEdit->text() != mLoadedIncidence->location());
56 } else {
57 return mUi->mSummaryEdit->text().isEmpty() && mUi->mLocationEdit->text().isEmpty();
58 }
59}
60
62{
63 if (mUi->mSummaryEdit->text().isEmpty()) {
64 mUi->mSummaryEdit->setFocus();
65 }
66}
67
69{
70 if (mUi->mSummaryEdit->text().isEmpty()) {
71 qCDebug(INCIDENCEEDITOR_LOG) << "Specify a summary";
72 mLastErrorString = i18nc("@info", "Please enter a summary.");
73 return false;
74 } else {
75 mLastErrorString.clear();
76 return true;
77 }
78}
79
80void IncidenceWhatWhere::validate()
81{
82 if (mUi->mSummaryEdit->text().isEmpty()) {
83 mUi->mSummaryEdit->setFocus();
84 }
85}
86
87#include "moc_incidencewhatwhere.cpp"
KCal Incidences are complicated objects.
KCalendarCore::IncidenceBase::IncidenceType type() const
Returns the type of the Incidence that is currently loaded.
QSharedPointer< IncidenceT > incidence() const
Convenience method to get a pointer for a specific const Incidence Type.
void save(const KCalendarCore::Incidence::Ptr &incidence) override
Store the current values of the editor into.
bool isDirty() const override
Returns whether or not the current values in the editor differ from the initial values.
bool isValid() const override
Returns whether or not the content of this editor is valid.
void load(const KCalendarCore::Incidence::Ptr &incidence) override
Load the values of.
void focusInvalidField() override
Sets focus on the invalid field.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void textChanged(const QString &text)
void clear()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.