summaryrefslogtreecommitdiffstats
path: root/storemodel.cpp
diff options
context:
space:
mode:
authorAnne Jan Brouwer <ajbrouwer@totalactivemedia.nl>2014-08-17 00:25:44 +0200
committerAnne Jan Brouwer <ajbrouwer@totalactivemedia.nl>2014-08-17 00:25:44 +0200
commit44c32981ac266e962bb33ab3bb7f76ec5b668a37 (patch)
treed55485e9a66ac0c4ce5edcc4326d59833ec84977 /storemodel.cpp
parent0fb2b5f1dc6015e5e9352860a8194acdee0d37c1 (diff)
regexp power
Diffstat (limited to 'storemodel.cpp')
-rw-r--r--storemodel.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/storemodel.cpp b/storemodel.cpp
index 7e889d3f..213ba8c3 100644
--- a/storemodel.cpp
+++ b/storemodel.cpp
@@ -48,8 +48,8 @@ bool StoreModel::ShowThis(const QModelIndex index) const
{
QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent());
QString path = fs->filePath(useIndex);
- path.replace(".gpg", "");
- path.replace(store, "");
+ path.replace(QRegExp("\\.gpg$"), "");
+ path.replace(QRegExp("^" + store), "");
if ( ! path.contains(filterRegExp()))
{
retVal = false;
@@ -62,7 +62,35 @@ bool StoreModel::ShowThis(const QModelIndex index) const
return retVal;
}
+/**
+ * @brief StoreModel::setModelAndStore
+ * @param sourceModel
+ * @param passStore
+ */
void StoreModel::setModelAndStore(QFileSystemModel *sourceModel, QString passStore) {
fs = sourceModel;
store = passStore;
}
+
+/**
+ * @brief StoreModel::data
+ * @param index
+ * @param role
+ * @return
+ */
+QVariant StoreModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ QVariant initial_value;
+ initial_value = QSortFilterProxyModel::data(index, role);
+
+ if (role == Qt::DisplayRole) {
+ QString name = initial_value.toString();
+ name.replace(QRegExp("\\.gpg$"), "");
+ initial_value.setValue(name);
+ }
+
+ return initial_value;
+}