DocumentManager: Refactor saveModified methods

Introduce methods to save a document/list of documents/all documents,
both silently and with a dialog to the DocumentManager.

All of these return a bool that signifies whether the save was
successful or not.

Detailed information on which files failed to load or whether the
save was canceled by the user are still available as optional
in/out parameters.

Change-Id: Id17798302f2a8ba6b85a07c1f0b91f03b20da03f
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Tobias Hunger
2014-01-21 13:25:19 +01:00
parent 063075ecad
commit 88a4421a84
9 changed files with 181 additions and 108 deletions

View File

@@ -1945,8 +1945,9 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd)
} else if (cmd.matches(_("wa"), _("wall"))) {
// :w[all]
QList<IDocument *> toSave = DocumentManager::modifiedDocuments();
QList<IDocument *> failed = DocumentManager::saveModifiedDocumentsSilently(toSave);
if (failed.isEmpty())
QList<IDocument *> failed;
bool success = DocumentManager::saveModifiedDocuments(toSave, QString(), 0, QString(), 0, &failed);
if (!success)
handler->showMessage(MessageInfo, tr("Saving succeeded"));
else
handler->showMessage(MessageError, tr("%n files not saved", 0, failed.size()));