From ff4f8d7dbf914f2529030701c877053ebacfa0fe Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 31 Jul 2017 23:11:42 +0200 Subject: [PATCH] dbhub: Use different icon for user's directory --- src/RemoteModel.cpp | 11 ++++++++++- src/RemoteModel.h | 1 + src/icons/folder_user.png | Bin 0 -> 730 bytes src/icons/icons.qrc | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/icons/folder_user.png diff --git a/src/RemoteModel.cpp b/src/RemoteModel.cpp index de850206..b5311413 100644 --- a/src/RemoteModel.cpp +++ b/src/RemoteModel.cpp @@ -110,6 +110,13 @@ RemoteModel::~RemoteModel() void RemoteModel::setNewRootDir(const QString& url, const QString& cert) { + // Extract user name + QString cn = remoteDatabase.clientCertificates()[cert].subjectInfo(QSslCertificate::CommonName).at(0); + QStringList cn_parts = cn.split("@"); + if(cn_parts.size() < 2) + return; + currentUserName = cn_parts.first(); + // Save settings currentRootDirectory = url; currentClientCert = cert; @@ -194,7 +201,9 @@ QVariant RemoteModel::data(const QModelIndex& index, int role) const if(role == Qt::DecorationRole && index.column() == 0) { // Use different icons depending on item type - if(type == "folder") + if(type == "folder" && index.parent() == QModelIndex() && item->value(RemoteModelColumnName) == currentUserName) + return QImage(":/icons/folder_user"); + else if(type == "folder") return QImage(":/icons/folder"); else if(type == "database") return QImage(":/icons/database"); diff --git a/src/RemoteModel.h b/src/RemoteModel.h index 4d62ec6d..65945f00 100644 --- a/src/RemoteModel.h +++ b/src/RemoteModel.h @@ -105,6 +105,7 @@ private: // lazy population. QString currentRootDirectory; QString currentClientCert; + QString currentUserName; }; #endif diff --git a/src/icons/folder_user.png b/src/icons/folder_user.png new file mode 100644 index 0000000000000000000000000000000000000000..f021c3e12a72a17b100089cd10d1ff9f2788c224 GIT binary patch literal 730 zcmV<00ww*4P)>`eEHOekrZG3#;v?6H6fhbs1c-xE%qmL1FD6Pgsp z%Q7MO@KoovHHK8U1J?_FIzK;SjKg2b`K_PgZHE@VJXO=*(cIEX$#{4s+#sCnPFUw_rU#+IR6UWkSw_(UZ&g zlAKBNq7_M($idCjGh@|$KtL56ha|q=database.png cog_go.png page_paste.png + folder_user.png