aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2015-06-04 15:21:02 +0200
committerEike Ziller <eike.ziller@theqtcompany.com>2015-06-10 15:32:55 +0000
commitfef9d7ff94ec497016d7a7120f8b60fde65ce8bf (patch)
tree4e16765dfc78d9ebb101d1b745acdcd3c8d64352 /src/plugins/resourceeditor/qrceditor/resourcefile.cpp
parentbe0aa40520d8a133b1f975de8750b5b8e25da2be (diff)
Editor manager: Abort with a single message if file is not readable.
We show a dialog that offers opening a file in a different editor type if opening a file fails, but we should not do that if opening the file fails because it is not readable. With this change, documents now specify if they failed to open a file because reading failed, or because they could not handle the file contents. Task-number: QTCREATORBUG-14495 Change-Id: I5d4b7cfa74b87ef21b9b55bc30b3ebe2f8238dfa Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Diffstat (limited to 'src/plugins/resourceeditor/qrceditor/resourcefile.cpp')
-rw-r--r--src/plugins/resourceeditor/qrceditor/resourcefile.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
index 45093744e7..e1d0e00a73 100644
--- a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
+++ b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp
@@ -113,19 +113,19 @@ ResourceFile::~ResourceFile()
clearPrefixList();
}
-bool ResourceFile::load()
+Core::IDocument::OpenResult ResourceFile::load()
{
m_error_message.clear();
if (m_file_name.isEmpty()) {
m_error_message = tr("The file name is empty.");
- return false;
+ return Core::IDocument::OpenResult::ReadError;
}
QFile file(m_file_name);
if (!file.open(QIODevice::ReadOnly)) {
m_error_message = file.errorString();
- return false;
+ return Core::IDocument::OpenResult::ReadError;
}
QByteArray data = file.readAll();
// Detect line ending style
@@ -143,13 +143,13 @@ bool ResourceFile::load()
if (!doc.setContent(data, &error_msg, &error_line, &error_col)) {
m_error_message = tr("XML error on line %1, col %2: %3")
.arg(error_line).arg(error_col).arg(error_msg);
- return false;
+ return Core::IDocument::OpenResult::CannotHandle;
}
QDomElement root = doc.firstChildElement(QLatin1String("RCC"));
if (root.isNull()) {
m_error_message = tr("The <RCC> root element is missing.");
- return false;
+ return Core::IDocument::OpenResult::CannotHandle;
}
QDomElement relt = root.firstChildElement(QLatin1String("qresource"));
@@ -181,7 +181,7 @@ bool ResourceFile::load()
}
}
- return true;
+ return Core::IDocument::OpenResult::Success;
}
QString ResourceFile::contents() const
@@ -1068,11 +1068,11 @@ QModelIndex ResourceModel::deleteItem(const QModelIndex &idx)
return index(file_idx, 0, prefix_model_idx);
}
-bool ResourceModel::reload()
+Core::IDocument::OpenResult ResourceModel::reload()
{
beginResetModel();
- const bool result = m_resource_file.load();
- if (result)
+ Core::IDocument::OpenResult result = m_resource_file.load();
+ if (result == Core::IDocument::OpenResult::Success)
setDirty(false);
endResetModel();
return result;