Skip to content
Browse files

Merge pull request #2752 from 0003088/master

#2717: Improve qt-gui error message popup
  • Loading branch information...
markus2330 committed Jun 10, 2019
2 parents a9e3c3e + 4a9d529 commit 3624c12fb04d6d370aaee311da2f913fa140e2f1
@@ -572,6 +572,7 @@ mounted, use `kdb gen -F <plugin>:<file> elektra <parentKey> <outputName>` to lo
- Added a new error concept for error codes to be implemented soon. _(Michael Zronek)_
- Added error categorization guidelines to be used with the error concept. _(Michael Zronek)_
- Drastically improved the error message format. For more information look [here](../../doc/decisions/ _(Michael Zronek)_
- Improved qt-gui error popup to conform with the new error message format. _(Raffael Pancheri)_
- We fixed the format specifiers in the [“Hello, Elektra” example]( _(René Schwaiger)_
- Expanded the Python Tutorial to cover installation under Alpine Linux. _(Philipp Gackstatter)_
- We wrote a tutorial which is intended to [help newcomers contributing to libelektra](../tutorials/ _(Thomas Bretterbauer)_
@@ -662,10 +662,43 @@ void TreeViewModel::synchronize ()
catch (KDBException const & e)
emit showMessage (tr ("Error"), tr ("Synchronizing failed, could not write merged configuration."), e.what ());
QMap<QString, QString> message = getErrorMessage (e);

emit showMessage (
tr ("Error"), message.value ("error"),
QString ("%1%2%3").arg (message.value ("at"), message.value ("mountpoint"), message.value ("configfile")));

QMap<QString, QString> TreeViewModel::getErrorMessage (KDBException const & e)
QRegExp error_regex ("Sorry, ((.*\\n){2})");
QRegExp at_regex ("At: (.*)\\n");
QRegExp mountpoint_regex ("Mountpoint: (.*)\\n");
QRegExp configfile_regex ("Configfile: (.*)\\n");

QMap<QString, QString> message;
QString error = QString (e.what ());

error_regex.setMinimal (true);
at_regex.setMinimal (true);
mountpoint_regex.setMinimal (true);
configfile_regex.setMinimal (true);

error_regex.indexIn (error);
at_regex.indexIn (error);
mountpoint_regex.indexIn (error);
configfile_regex.indexIn (error);

message.insert ("error", error_regex.cap ());
message.insert ("at", at_regex.cap ());
message.insert ("mountpoint", mountpoint_regex.cap ());
message.insert ("configfile", configfile_regex.cap ());

return message;

void TreeViewModel::clearMetaModel ()
beginResetModel ();
@@ -306,6 +306,13 @@ class TreeViewModel : public QAbstractListModel
void connectDBus ();

* @brief Extract the contents of an KDBException::what() function for usage in a TreeViewModel::showMessage() function.
* @param e The KDBException.
* @return A QMap with the contents of the KDBException.
QMap<QString, QString> getErrorMessage (kdb::KDBException const & e);

QHash<int, QByteArray> roleNames () const override;

0 comments on commit 3624c12

Please sign in to comment.
You can’t perform that action at this time.