diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-19 12:41:17 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-19 20:21:59 +0200 |
commit | de1d5f6a949f8335b3dbe000057805a8efdd4487 (patch) | |
tree | bcbec7062a4990c08dc98741256aed0454d3a199 /src/widgets/dialogs | |
parent | 71b4b6b555799a6ebc6f9a7699aecb4522f7f817 (diff) |
QFileSystemModel: don't display a modal messagebox on error
A model is the wrong place to display a modal dialog when a call to
setData failed. The call returns false already, and the caller can
handle the error appropriately, presumably knowing best what failed and
how to present the user with options.
Task-number: QTBUG-66177
Change-Id: I069209d51a577177bc278aeb08a92c95029dc962
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index f088712987..4b933cdb8d 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -43,10 +43,6 @@ #include <qmimedata.h> #include <qurl.h> #include <qdebug.h> -#if QT_CONFIG(messagebox) -#include <qmessagebox.h> -#endif -#include <qapplication.h> #include <QtCore/qcollator.h> #if QT_CONFIG(regularexpression) # include <QtCore/qregularexpression.h> @@ -853,20 +849,6 @@ QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const return node(index)->icon(); } -static void displayRenameFailedMessage(const QString &newName) -{ -#if QT_CONFIG(messagebox) - const QString message = - QFileSystemModel::tr("<b>The name \"%1\" cannot be used.</b>" - "<p>Try using another name, with fewer characters or no punctuation marks.") - .arg(newName); - QMessageBox::information(nullptr, QFileSystemModel::tr("Invalid filename"), - message, QMessageBox::Ok); -#else - Q_UNUSED(newName); -#endif // QT_CONFIG(messagebox) -} - /*! \reimp */ @@ -887,10 +869,8 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in const QString parentPath = filePath(parent(idx)); - if (newName.isEmpty() || QDir::toNativeSeparators(newName).contains(QDir::separator())) { - displayRenameFailedMessage(newName); + if (newName.isEmpty() || QDir::toNativeSeparators(newName).contains(QDir::separator())) return false; - } #if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN) // QTBUG-65683: Remove file system watchers prior to renaming to prevent @@ -901,7 +881,6 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in #if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN) d->watchPaths(watchedPaths); #endif - displayRenameFailedMessage(newName); return false; } else { /* |