summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2017-01-09 14:53:38 +0100
committerAnne Jan Brouwer <brouwer@annejan.com>2017-01-09 14:53:38 +0100
commit58148a40f419a92d76c5851837343d74e8804da2 (patch)
tree23cdf029cc5b5f47e8f799f36595f809bfbdfca4 /src
parent6759fc6935d50f2b6c6b076cbdd9c01ff8dfd4fc (diff)
Auto update Changelog, missing doc-blocks
Diffstat (limited to 'src')
-rw-r--r--src/executor.h19
-rw-r--r--src/pass.cpp15
-rw-r--r--src/passworddialog.cpp5
-rw-r--r--src/storemodel.cpp275
4 files changed, 169 insertions, 145 deletions
diff --git a/src/executor.h b/src/executor.h
index b468d2dd..c5b9e784 100644
--- a/src/executor.h
+++ b/src/executor.h
@@ -88,15 +88,26 @@ signals:
/**
* @brief finished signal that is emited when process finishes
*
+ * @param id id of the process
* @param exitCode return code of the process
- * @param output stdout produced by the process, if requested when
- * executing
- * @param errout stderr produced by the process, if requested or if
- * process failed
+ * @param output stdout produced by the process
+ * @param errout stderr produced by the process
*/
void finished(int id, int exitCode, const QString &output,
const QString &errout);
+ /**
+ * @brief starting signal that is emited when process starts
+ */
void starting();
+ /**
+ * @brief error signal that is emited when process finishes with an
+ * error
+ *
+ * @param id id of the process
+ * @param exitCode return code of the process
+ * @param output stdout produced by the process
+ * @param errout stderr produced by the process
+ */
void error(int id, int exitCode, const QString &output,
const QString &errout);
};
diff --git a/src/pass.cpp b/src/pass.cpp
index 18aca8af..27114fe0 100644
--- a/src/pass.cpp
+++ b/src/pass.cpp
@@ -264,7 +264,12 @@ QString Pass::getRecipientString(QString for_file, QString separator,
/**
* @brief Pass::executePass easy wrapper for running pass
+ *
+ * @param id
* @param args
+ * @param input
+ * @param readStdout
+ * @param readStderr
*/
void Pass::executePass(int id, const QStringList &args, QString input,
bool readStdout, bool readStderr) {
@@ -274,7 +279,12 @@ void Pass::executePass(int id, const QStringList &args, QString input,
/**
* @brief Pass::executeGpg easy wrapper for running gpg commands
+ *
+ * @param id
* @param args
+ * @param input
+ * @param readStdout
+ * @param readStderr
*/
void Pass::executeGpg(int id, const QStringList &args, QString input,
bool readStdout, bool readStderr) {
@@ -283,7 +293,12 @@ void Pass::executeGpg(int id, const QStringList &args, QString input,
}
/**
* @brief Pass::executeGit easy wrapper for running git commands
+ *
+ * @param id
* @param args
+ * @param input
+ * @param readStdout
+ * @param readStderr
*/
void Pass::executeGit(int id, const QStringList &args, QString input,
bool readStdout, bool readStderr) {
diff --git a/src/passworddialog.cpp b/src/passworddialog.cpp
index aad8ac8f..ac3d63ef 100644
--- a/src/passworddialog.cpp
+++ b/src/passworddialog.cpp
@@ -1,7 +1,7 @@
#include "passworddialog.h"
#include "debughelper.h"
-#include "ui_passworddialog.h"
#include "qtpasssettings.h"
+#include "ui_passworddialog.h"
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
@@ -9,12 +9,11 @@
/**
* @brief PasswordDialog::PasswordDialog basic constructor.
* @param passConfig configuration constant
- * @param pass pass or pass replacement wrapper
* @param parent
*/
PasswordDialog::PasswordDialog(const passwordConfiguration &passConfig,
QWidget *parent)
- : QDialog(parent), ui(new Ui::PasswordDialog), m_passConfig(passConfig){
+ : QDialog(parent), ui(new Ui::PasswordDialog), m_passConfig(passConfig) {
templating = false;
allFields = false;
ui->setupUi(this);
diff --git a/src/storemodel.cpp b/src/storemodel.cpp
index a1f4609d..ecc26db2 100644
--- a/src/storemodel.cpp
+++ b/src/storemodel.cpp
@@ -1,29 +1,26 @@
#include "storemodel.h"
#include <QDebug>
-#include <QStringListModel>
-#include <QMimeData>
#include <QMessageBox>
+#include <QMimeData>
+#include <QStringListModel>
-
-QDataStream &operator<<(QDataStream &out, const dragAndDropInfoPasswordStore &dragAndDropInfoPasswordStore)
-{
- out << dragAndDropInfoPasswordStore.isDir
- << dragAndDropInfoPasswordStore.isFile
- << dragAndDropInfoPasswordStore.path;
- return out;
+QDataStream &
+operator<<(QDataStream &out,
+ const dragAndDropInfoPasswordStore &dragAndDropInfoPasswordStore) {
+ out << dragAndDropInfoPasswordStore.isDir
+ << dragAndDropInfoPasswordStore.isFile
+ << dragAndDropInfoPasswordStore.path;
+ return out;
}
-
-
-QDataStream &operator>>(QDataStream &in, dragAndDropInfoPasswordStore &dragAndDropInfoPasswordStore)
-{
- in >> dragAndDropInfoPasswordStore.isDir
- >> dragAndDropInfoPasswordStore.isFile
- >> dragAndDropInfoPasswordStore.path;
- return in;
+QDataStream &
+operator>>(QDataStream &in,
+ dragAndDropInfoPasswordStore &dragAndDropInfoPasswordStore) {
+ in >> dragAndDropInfoPasswordStore.isDir >>
+ dragAndDropInfoPasswordStore.isFile >> dragAndDropInfoPasswordStore.path;
+ return in;
}
-
/**
* @brief StoreModel::StoreModel
* SubClass of QSortFilterProxyModel via
@@ -65,11 +62,11 @@ bool StoreModel::ShowThis(const QModelIndex index) const {
break;
}
} else {
- QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent());
- QString path = fs->filePath(useIndex);
- path = QDir(store).relativeFilePath(path);
- path.replace(QRegExp("\\.gpg$"), "");
- retVal = path.contains(filterRegExp());
+ QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent());
+ QString path = fs->filePath(useIndex);
+ path = QDir(store).relativeFilePath(path);
+ path.replace(QRegExp("\\.gpg$"), "");
+ retVal = path.contains(filterRegExp());
}
return retVal;
}
@@ -111,143 +108,145 @@ QVariant StoreModel::data(const QModelIndex &index, int role) const {
* @brief StoreModel::supportedDropActions enable drop.
* @return
*/
-Qt::DropActions StoreModel::supportedDropActions() const
-{
- return Qt::CopyAction | Qt::MoveAction;
+Qt::DropActions StoreModel::supportedDropActions() const {
+ return Qt::CopyAction | Qt::MoveAction;
}
/**
* @brief StoreModel::supportedDragActions enable drag.
* @return
*/
-Qt::DropActions StoreModel::supportedDragActions() const
-{
- return Qt::CopyAction | Qt::MoveAction;
+Qt::DropActions StoreModel::supportedDragActions() const {
+ return Qt::CopyAction | Qt::MoveAction;
}
-Qt::ItemFlags StoreModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags defaultFlags = QSortFilterProxyModel::flags(index);
+Qt::ItemFlags StoreModel::flags(const QModelIndex &index) const {
+ Qt::ItemFlags defaultFlags = QSortFilterProxyModel::flags(index);
- if (index.isValid()){
- return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
- }else{
- return Qt::ItemIsDropEnabled | defaultFlags;
- }
-}
-
-QStringList StoreModel::mimeTypes() const
-{
- QStringList types;
- types << "application/vnd+qtpass.dragAndDropInfoPasswordStore";
- return types;
+ if (index.isValid()) {
+ return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
+ } else {
+ return Qt::ItemIsDropEnabled | defaultFlags;
+ }
}
-QMimeData *StoreModel::mimeData(const QModelIndexList &indexes) const
-{
- dragAndDropInfoPasswordStore info;
-
- QByteArray encodedData;
- // only use the first, otherwise we should enable multiselection
- QModelIndex index = indexes.at(0);
- if (index.isValid()) {
- QModelIndex useIndex = mapToSource(index);
-
- info.isDir = fs->fileInfo(useIndex).isDir();
- info.isFile = fs->fileInfo(useIndex).isFile();
- info.path = fs->fileInfo(useIndex).absoluteFilePath();
- QDataStream stream(&encodedData, QIODevice::WriteOnly);
- stream << info;
- }
-
- QMimeData *mimeData = new QMimeData();
- mimeData->setData("application/vnd+qtpass.dragAndDropInfoPasswordStore", encodedData);
- return mimeData;
+QStringList StoreModel::mimeTypes() const {
+ QStringList types;
+ types << "application/vnd+qtpass.dragAndDropInfoPasswordStore";
+ return types;
}
+QMimeData *StoreModel::mimeData(const QModelIndexList &indexes) const {
+ dragAndDropInfoPasswordStore info;
+ QByteArray encodedData;
+ // only use the first, otherwise we should enable multiselection
+ QModelIndex index = indexes.at(0);
+ if (index.isValid()) {
+ QModelIndex useIndex = mapToSource(index);
+ info.isDir = fs->fileInfo(useIndex).isDir();
+ info.isFile = fs->fileInfo(useIndex).isFile();
+ info.path = fs->fileInfo(useIndex).absoluteFilePath();
+ QDataStream stream(&encodedData, QIODevice::WriteOnly);
+ stream << info;
+ }
-bool StoreModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
-{
- QModelIndex useIndex = this->index(parent.row(), parent.column(), parent.parent());
- QByteArray encodedData = data->data("application/vnd+qtpass.dragAndDropInfoPasswordStore");
- QDataStream stream(&encodedData, QIODevice::ReadOnly);
- dragAndDropInfoPasswordStore info;
- stream >> info;
- if (data->hasFormat("application/vnd+qtpass.dragAndDropInfoPasswordStore") == false)
- return false;
+ QMimeData *mimeData = new QMimeData();
+ mimeData->setData("application/vnd+qtpass.dragAndDropInfoPasswordStore",
+ encodedData);
+ return mimeData;
+}
+bool StoreModel::canDropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column,
+ const QModelIndex &parent) const {
+ qDebug() << action << row;
+
+ QModelIndex useIndex =
+ this->index(parent.row(), parent.column(), parent.parent());
+ QByteArray encodedData =
+ data->data("application/vnd+qtpass.dragAndDropInfoPasswordStore");
+ QDataStream stream(&encodedData, QIODevice::ReadOnly);
+ dragAndDropInfoPasswordStore info;
+ stream >> info;
+ if (data->hasFormat("application/vnd+qtpass.dragAndDropInfoPasswordStore") ==
+ false)
+ return false;
- if (column > 0){
- return false;
- }
+ if (column > 0) {
+ return false;
+ }
- // you can drop a folder on a folder
- if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.isDir){
- return true;
- }
- // you can drop a file on a folder
- if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.isFile){
- return true;
- }
- // you can drop a file on a file
- if (fs->fileInfo(mapToSource(useIndex)).isFile() && info.isFile){
- return true;
- }
+ // you can drop a folder on a folder
+ if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.isDir) {
+ return true;
+ }
+ // you can drop a file on a folder
+ if (fs->fileInfo(mapToSource(useIndex)).isDir() && info.isFile) {
+ return true;
+ }
+ // you can drop a file on a file
+ if (fs->fileInfo(mapToSource(useIndex)).isFile() && info.isFile) {
+ return true;
+ }
- return false;
+ return false;
}
-bool StoreModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
-{
- if (!canDropMimeData(data, action, row, column, parent))
- return false;
+bool StoreModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent) {
+ if (!canDropMimeData(data, action, row, column, parent))
+ return false;
- if (action == Qt::IgnoreAction){
- return true;
+ if (action == Qt::IgnoreAction) {
+ return true;
+ }
+ QByteArray encodedData =
+ data->data("application/vnd+qtpass.dragAndDropInfoPasswordStore");
+
+ QDataStream stream(&encodedData, QIODevice::ReadOnly);
+ dragAndDropInfoPasswordStore info;
+ stream >> info;
+ QModelIndex destIndex =
+ this->index(parent.row(), parent.column(), parent.parent());
+ QFileInfo destFileinfo = fs->fileInfo(mapToSource(destIndex));
+ QFileInfo srcFileInfo = QFileInfo(info.path);
+ QDir qdir;
+ QString cleanedSrc = qdir.cleanPath(srcFileInfo.absoluteFilePath());
+ QString cleanedDest = qdir.cleanPath(destFileinfo.absoluteFilePath());
+ if (info.isDir) {
+ QDir srcDir = QDir(info.path);
+ // dropped dir onto dir
+ if (destFileinfo.isDir()) {
+ QDir destDir = QDir(cleanedDest).filePath(srcFileInfo.fileName());
+ QString cleanedDestDir = qdir.cleanPath(destDir.absolutePath());
+ if (action == Qt::MoveAction) {
+ QtPassSettings::getPass()->Move(cleanedSrc, cleanedDestDir);
+ } else if (action == Qt::CopyAction) {
+ QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDestDir);
+ }
}
- QByteArray encodedData = data->data("application/vnd+qtpass.dragAndDropInfoPasswordStore");
-
- QDataStream stream(&encodedData, QIODevice::ReadOnly);
- dragAndDropInfoPasswordStore info;
- stream >> info;
- QModelIndex destIndex = this->index(parent.row(), parent.column(), parent.parent());
- QFileInfo destFileinfo = fs->fileInfo(mapToSource(destIndex));
- QFileInfo srcFileInfo = QFileInfo(info.path);
- QDir qdir;
- QString cleanedSrc = qdir.cleanPath(srcFileInfo.absoluteFilePath());
- QString cleanedDest = qdir.cleanPath(destFileinfo.absoluteFilePath());
- if(info.isDir){
- QDir srcDir = QDir(info.path);
- // dropped dir onto dir
- if(destFileinfo.isDir()){
- QDir destDir = QDir(cleanedDest).filePath(srcFileInfo.fileName());
- QString cleanedDestDir = qdir.cleanPath(destDir.absolutePath());
- if(action == Qt::MoveAction){
- QtPassSettings::getPass()->Move(cleanedSrc, cleanedDestDir);
- }else if(action == Qt::CopyAction){
- QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDestDir);
- }
- }
- }else if(info.isFile){
- // dropped file onto a directory
- if(destFileinfo.isDir()){
- if(action == Qt::MoveAction){
- QtPassSettings::getPass()->Move(cleanedSrc, cleanedDest);
- }else if(action == Qt::CopyAction){
- QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDest);
- }
- }else if(destFileinfo.isFile()){
- // dropped file onto a file
- int answer = QMessageBox::question(0, tr("force overwrite?"), tr("overwrite %1 with %2?").arg(cleanedDest).arg(cleanedSrc), QMessageBox::Yes | QMessageBox::No);
- bool force = answer==QMessageBox::Yes;
- if(action == Qt::MoveAction){
- QtPassSettings::getPass()->Move(cleanedSrc, cleanedDest, force);
- }else if(action == Qt::CopyAction){
- QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDest, force);
- }
- }
-
+ } else if (info.isFile) {
+ // dropped file onto a directory
+ if (destFileinfo.isDir()) {
+ if (action == Qt::MoveAction) {
+ QtPassSettings::getPass()->Move(cleanedSrc, cleanedDest);
+ } else if (action == Qt::CopyAction) {
+ QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDest);
+ }
+ } else if (destFileinfo.isFile()) {
+ // dropped file onto a file
+ int answer = QMessageBox::question(
+ 0, tr("force overwrite?"),
+ tr("overwrite %1 with %2?").arg(cleanedDest).arg(cleanedSrc),
+ QMessageBox::Yes | QMessageBox::No);
+ bool force = answer == QMessageBox::Yes;
+ if (action == Qt::MoveAction) {
+ QtPassSettings::getPass()->Move(cleanedSrc, cleanedDest, force);
+ } else if (action == Qt::CopyAction) {
+ QtPassSettings::getPass()->Copy(cleanedSrc, cleanedDest, force);
+ }
}
- return true;
+ }
+ return true;
}