summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Mazo <ahippo@yandex.com>2016-03-06 20:06:43 -0500
committerAndrey Mazo <ahippo@yandex.com>2016-03-07 08:58:56 +0300
commit804b8426a565fb0197bdedcea88a41ff0f3670f5 (patch)
tree210bb1210c699236cffc65d05ee5826c02714038
parent510178065b53ea3ae6ef747a817b9686fa719e8c (diff)
Fix pass-name in commit message on Windows
Fix removal of path of a password store on Windows. Before the change: "Add for C:/Users/<MyUser>/password-store/zzz/qqq using QtPass." After the change: "Add for zzz/qqq using QtPass." And the same for "Remove" messages. Use the same removal method in store model too.
-rw-r--r--mainwindow.cpp11
-rw-r--r--storemodel.cpp2
2 files changed, 6 insertions, 7 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 4a71ca73..c522403a 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -614,11 +614,11 @@ QString MainWindow::getDir(const QModelIndex &index, bool forPass) {
return forPass ? "" : abspath;
QFileInfo info = model.fileInfo(proxyModel.mapToSource(index));
QString filePath =
- (info.isFile() ? info.absolutePath() : info.absoluteFilePath()) + '/';
+ (info.isFile() ? info.absolutePath() : info.absoluteFilePath());
if (forPass) {
- filePath.replace(QRegExp("^" + passStore), "");
- filePath.replace(QRegExp("^" + abspath), "");
+ filePath = QDir(abspath).relativeFilePath(filePath);
}
+ filePath += '/';
return filePath;
}
@@ -628,8 +628,8 @@ QString MainWindow::getFile(const QModelIndex &index, bool forPass) {
return QString();
QString filePath = model.filePath(proxyModel.mapToSource(index));
if (forPass) {
+ filePath = QDir(passStore).relativeFilePath(filePath);
filePath.replace(QRegExp("\\.gpg$"), "");
- filePath.replace(QRegExp("^" + passStore), "");
}
return filePath;
}
@@ -1131,9 +1131,8 @@ void MainWindow::setPassword(QString file, bool overwrite, bool isNew = false) {
if (!useWebDav && useGit) {
if (!overwrite)
executeWrapper(gitExecutable, "add \"" + file + '"');
- QString path = file;
+ QString path = QDir(passStore).relativeFilePath(file);
path.replace(QRegExp("\\.gpg$"), "");
- path.replace(QRegExp("^" + passStore), "");
executeWrapper(gitExecutable, "commit \"" + file + "\" -m \"" +
(overwrite ? "Edit" : "Add") + " for " +
path + " using QtPass.\"");
diff --git a/storemodel.cpp b/storemodel.cpp
index ada0540e..8e7d8345 100644
--- a/storemodel.cpp
+++ b/storemodel.cpp
@@ -41,8 +41,8 @@ bool StoreModel::ShowThis(const QModelIndex index) const {
} else {
QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent());
QString path = fs->filePath(useIndex);
+ path = QDir(store).relativeFilePath(path);
path.replace(QRegExp("\\.gpg$"), "");
- path.replace(QRegExp("^" + store), "");
retVal = path.contains(filterRegExp());
}
return retVal;