Commit 6eacac2d authored by Volker Krause's avatar Volker Krause
Browse files

Move the use of KMessageBox out of TodoModel

Add an error signal for the previous use instead. Using a widget message
box isn't necessarily the desired way to communicate errors for all
applications. This matters particularly for QML-based apps like Kalendar.
parent 00ec6236
Pipeline #166474 passed with stage
in 4 minutes and 21 seconds
......@@ -22,7 +22,6 @@
#include <KCalUtils/VCalDrag>
#include "calendarview_debug.h"
#include <KMessageBox>
#include <QIcon>
#include <QMimeData>
......@@ -542,10 +541,7 @@ bool TodoModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
KCalendarCore::Incidence::Ptr tmp = destTodo;
while (tmp) {
if (tmp->uid() == todo->uid()) { // correct, don't use instanceIdentifier() here
KMessageBox::information(nullptr,
i18n("Cannot move to-do to itself or a child of itself."),
i18n("Drop To-do"),
QStringLiteral("NoDropTodoOntoItself"));
Q_EMIT dropOnSelfRejected();
return false;
}
const QString parentUid = tmp->relatedTo();
......
......@@ -93,6 +93,12 @@ public:
Q_REQUIRED_RESULT QHash<int, QByteArray> roleNames() const override;
Q_SIGNALS:
/** Emitted when dropMimeData() rejected a drop
* on the same item or any of its children.
*/
void dropOnSelfRejected();
private:
friend class TodoModelPrivate;
std::unique_ptr<TodoModelPrivate> const d;
......
......@@ -35,6 +35,7 @@
#include <KConfig>
#include <KJob>
#include <KMessageBox>
#include <QGridLayout>
#include <QHeaderView>
......@@ -175,6 +176,12 @@ TodoView::TodoView(const EventViews::PrefsPtr &prefs, bool sidebarView, QWidget
setPreferences(prefs);
if (!sModels) {
sModels = new ModelStack(prefs, parent);
connect(sModels->todoModel, &TodoModel::dropOnSelfRejected, this, []() {
KMessageBox::information(nullptr,
i18n("Cannot move to-do to itself or a child of itself."),
i18n("Drop To-do"),
QStringLiteral("NoDropTodoOntoItself"));
});
}
sModels->registerView(this);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment