summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Maradonna <penguyman@stronzi.org>2018-04-18 16:01:22 +0200
committerClaudio Maradonna <penguyman@stronzi.org>2018-04-18 16:01:22 +0200
commit386faf151953214391430363064a44bb2ab5e549 (patch)
treeb72a8e5a10ba19a0e46e02b3a7eafa9307b4aeb9
parent33d948d057a06e29d1ff93e7c77625f46c50a338 (diff)
Cleaning #includes. This should make compilation faster and should help to make a good refactoring
-rw-r--r--main/main.cpp7
-rw-r--r--src/configdialog.cpp1
-rw-r--r--src/configdialog.h13
-rw-r--r--src/deselectabletreeview.h9
-rw-r--r--src/enums.h49
-rw-r--r--src/filecontent.h88
-rw-r--r--src/keygendialog.cpp1
-rw-r--r--src/keygendialog.h6
-rw-r--r--src/mainwindow.cpp8
-rw-r--r--src/mainwindow.h15
-rw-r--r--src/pass.h12
-rw-r--r--src/passworddialog.cpp2
-rw-r--r--src/passworddialog.h4
-rw-r--r--src/qpushbuttonwithclipboard.h3
-rw-r--r--src/qtpasssettings.cpp2
-rw-r--r--src/qtpasssettings.h6
-rw-r--r--src/realpass.cpp3
-rw-r--r--src/storemodel.cpp5
-rw-r--r--src/storemodel.h6
-rw-r--r--src/trayicon.cpp4
-rw-r--r--src/trayicon.h7
-rw-r--r--src/usersdialog.h5
-rw-r--r--src/util.cpp4
-rw-r--r--src/util.h1
24 files changed, 137 insertions, 124 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 8a18409c..559db3a9 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1,4 +1,8 @@
#include "mainwindow.h"
+#if SINGLE_APP
+#include "singleapplication.h"
+#endif
+
#include <QApplication>
#include <QTranslator>
@@ -72,8 +76,7 @@ int main(int argc, char *argv[]) {
// locale = "nl_NL";
// locale = "he_IL";
// locale = "ar_MA";
- translator.load(QString(":localization/localization_") + locale +
- QString(".qm"));
+ translator.load(QString(":localization/localization_%1.qm").arg(locale));
app.installTranslator(&translator);
app.setLayoutDirection(QObject::tr("LTR") == "RTL" ? Qt::RightToLeft
: Qt::LeftToRight);
diff --git a/src/configdialog.cpp b/src/configdialog.cpp
index 43eff5f8..94fa0f1a 100644
--- a/src/configdialog.cpp
+++ b/src/configdialog.cpp
@@ -6,6 +6,7 @@
#include "ui_configdialog.h"
#include <QClipboard>
#include <QDir>
+#include <QFileDialog>
#include <QMessageBox>
#ifdef Q_OS_WIN
#include <windows.h>
diff --git a/src/configdialog.h b/src/configdialog.h
index 232843cf..07caecb3 100644
--- a/src/configdialog.h
+++ b/src/configdialog.h
@@ -1,16 +1,15 @@
#ifndef CONFIGDIALOG_H_
#define CONFIGDIALOG_H_
-#include "mainwindow.h"
-#include <QCloseEvent>
+#include "enums.h"
+#include "passwordconfiguration.h"
+
#include <QDialog>
-#include <QFileDialog>
-#include <QTableWidgetItem>
namespace Ui {
-struct UserInfo;
+ struct UserInfo;
-class ConfigDialog;
+ class ConfigDialog;
} // namespace Ui
/*!
@@ -19,6 +18,8 @@ class ConfigDialog;
This class should also take the handling from the MainWindow class.
*/
+class MainWindow;
+class QCloseEvent;
class ConfigDialog : public QDialog {
Q_OBJECT
diff --git a/src/deselectabletreeview.h b/src/deselectabletreeview.h
index ebd84c84..ea021723 100644
--- a/src/deselectabletreeview.h
+++ b/src/deselectabletreeview.h
@@ -1,8 +1,11 @@
#ifndef DESELECTABLETREEVIEW_H
#define DESELECTABLETREEVIEW_H
-#include "QMouseEvent"
-#include "QTreeView"
-#include "mainwindow.h"
+
+//#include "mainwindow.h"
+
+#include <QCoreApplication>
+#include <QMouseEvent>
+#include <QTreeView>
#include <QTime>
/**
diff --git a/src/enums.h b/src/enums.h
index cc241ecb..3fa9aea9 100644
--- a/src/enums.h
+++ b/src/enums.h
@@ -7,31 +7,32 @@
*/
namespace Enums {
-enum clipBoardType {
- CLIPBOARD_NEVER = 0,
- CLIPBOARD_ALWAYS = 1,
- CLIPBOARD_ON_DEMAND = 2
-};
+ enum clipBoardType {
+ CLIPBOARD_NEVER = 0,
+ CLIPBOARD_ALWAYS = 1,
+ CLIPBOARD_ON_DEMAND = 2
+ };
+
+ enum PROCESS {
+ GIT_INIT = 0,
+ GIT_ADD,
+ GIT_COMMIT,
+ GIT_RM,
+ GIT_PULL,
+ GIT_PUSH,
+ PASS_SHOW,
+ PASS_INSERT,
+ PASS_REMOVE,
+ PASS_INIT,
+ GPG_GENKEYS,
+ PASS_MOVE,
+ PASS_COPY,
+ GIT_MOVE,
+ GIT_COPY,
+ PROCESS_COUNT,
+ INVALID
+ };
-enum PROCESS {
- GIT_INIT = 0,
- GIT_ADD,
- GIT_COMMIT,
- GIT_RM,
- GIT_PULL,
- GIT_PUSH,
- PASS_SHOW,
- PASS_INSERT,
- PASS_REMOVE,
- PASS_INIT,
- GPG_GENKEYS,
- PASS_MOVE,
- PASS_COPY,
- GIT_MOVE,
- GIT_COPY,
- PROCESS_COUNT,
- INVALID
-};
} // namespace Enums
#endif // ENUMS_H
diff --git a/src/filecontent.h b/src/filecontent.h
index 7d75ea38..02b3a5af 100644
--- a/src/filecontent.h
+++ b/src/filecontent.h
@@ -1,13 +1,13 @@
#ifndef FILECONTENT_H
#define FILECONTENT_H
-#include <utility>
+//#include <utility>
#include <QList>
#include <QString>
struct NamedValue {
- QString name;
- QString value;
+ QString name;
+ QString value;
};
/**
@@ -15,54 +15,54 @@ struct NamedValue {
* but also has a method to take a specific NamedValue pair out of the list.
*/
class NamedValues : public QList<NamedValue> {
-public:
- NamedValues();
- NamedValues(std::initializer_list<NamedValue> values);
+ public:
+ NamedValues();
+ NamedValues(std::initializer_list<NamedValue> values);
- QString takeValue(const QString &name);
+ QString takeValue(const QString &name);
};
-class FileContent
-{
-public:
- /**
- * @brief parse parses the given fileContent in a FileContent object.
- * The password is accessible through getPassword.
- * The named value pairs (name: value) are parsed and depeding on the templateFields and allFields parameters
- * accessible through getNamedValues or getRemainingData.
- *
- * @param fileContent the file content to parse.
- *
- * @param templateFields the fields in the template.
- * Fields in the template will always be in getNamedValues() at the beginning of the list in the same order.
- *
- * @param allFields whether all fields should be considered as named values.
- * If set to false only templateFields are returned in getNamedValues().
- *
- * @return
- */
- static FileContent parse(const QString &fileContent, const QStringList& templateFields, bool allFields);
+class FileContent {
+ public:
+ /**
+ * @brief parse parses the given fileContent in a FileContent object.
+ * The password is accessible through getPassword.
+ * The named value pairs (name: value) are parsed and depeding on the templateFields and allFields parameters
+ * accessible through getNamedValues or getRemainingData.
+ *
+ * @param fileContent the file content to parse.
+ *
+ * @param templateFields the fields in the template.
+ * Fields in the template will always be in getNamedValues() at the beginning of the list in the same order.
+ *
+ * @param allFields whether all fields should be considered as named values.
+ * If set to false only templateFields are returned in getNamedValues().
+ *
+ * @return
+ */
+ static FileContent parse(const QString &fileContent, const QStringList& templateFields, bool allFields);
- /**
- * @return the password from the parsed file.
- */
- QString getPassword() const;
+ /**
+ * @return the password from the parsed file.
+ */
+ QString getPassword() const;
- /**
- * @return the named values in the file in the order of appearence, with template values first.
- */
- NamedValues getNamedValues() const;
+ /**
+ * @return the named values in the file in the order of appearence, with template values first.
+ */
+ NamedValues getNamedValues() const;
- /**
- * @return the data that is not the password and not in getNamedValues.
- */
- QString getRemainingData() const;
-private:
- FileContent(const QString &password, const NamedValues &namedValues, const QString &remainingData);
+ /**
+ * @return the data that is not the password and not in getNamedValues.
+ */
+ QString getRemainingData() const;
- QString password;
- NamedValues namedValues;
- QString remainingData;
+ private:
+ FileContent(const QString &password, const NamedValues &namedValues, const QString &remainingData);
+
+ QString password;
+ NamedValues namedValues;
+ QString remainingData;
};
#endif // FILECONTENT_H
diff --git a/src/keygendialog.cpp b/src/keygendialog.cpp
index 9e3d27cc..a2c3f7fe 100644
--- a/src/keygendialog.cpp
+++ b/src/keygendialog.cpp
@@ -1,3 +1,4 @@
+#include "configdialog.h"
#include "keygendialog.h"
#include "debughelper.h"
#include "qprogressindicator.h"
diff --git a/src/keygendialog.h b/src/keygendialog.h
index 64af8307..f60fb2d0 100644
--- a/src/keygendialog.h
+++ b/src/keygendialog.h
@@ -1,18 +1,18 @@
#ifndef KEYGENDIALOG_H_
#define KEYGENDIALOG_H_
-#include "configdialog.h"
-#include <QCloseEvent>
#include <QDialog>
namespace Ui {
-class KeygenDialog;
+ class KeygenDialog;
}
/*!
\class KeygenDialog
\brief Handles GPG keypair generation.
*/
+class ConfigDialog;
+class QCloseEvent;
class KeygenDialog : public QDialog {
Q_OBJECT
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 1175a7a6..c158fca8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -7,10 +7,11 @@
#include <QInputDialog>
#include <QLabel>
#include <QMessageBox>
+#include <QMenu>
#include <QQueue>
#include <QShortcut>
+#include <QSystemTrayIcon>
#include <QTextCodec>
-#include <QTimer>
#ifdef Q_OS_WIN
#define WIN32_LEAN_AND_MEAN /*_KILLING_MACHINE*/
#define WIN32_EXTRA_LEAN
@@ -28,6 +29,11 @@
#include "usersdialog.h"
#include "util.h"
#include "filecontent.h"
+#include "trayicon.h"
+
+#if SINGLE_APP
+#include "singleapplication.h"
+#endif
/**
* @brief MainWindow::MainWindow handles all of the main functionality and also
diff --git a/src/mainwindow.h b/src/mainwindow.h
index cdcb2b40..450c6eef 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -1,23 +1,16 @@
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
-#include "passwordconfiguration.h"
-#include "userinfo.h"
-#include "enums.h"
-#include "imitatepass.h"
-#include "pass.h"
-#include "realpass.h"
#include "storemodel.h"
-#include "trayicon.h"
+
#include <QFileSystemModel>
+#include <QItemSelectionModel>
#include <QMainWindow>
#include <QProcess>
-#include <QQueue>
#include <QTimer>
-#include <QTreeView>
#if SINGLE_APP
-#include "singleapplication.h"
+class SingleApplication;
#else
#define SingleApplication QApplication
#endif
@@ -40,6 +33,8 @@ class MainWindow;
This class could really do with an overhaul.
*/
+class Pass;
+class TrayIcon;
class MainWindow : public QMainWindow {
Q_OBJECT
diff --git a/src/pass.h b/src/pass.h
index be6310dd..cc5fc650 100644
--- a/src/pass.h
+++ b/src/pass.h
@@ -4,21 +4,19 @@
#include "userinfo.h"
#include "enums.h"
#include "executor.h"
-#include <QDebug>
-#include <QDir>
-#include <QList>
+
#include <QProcess>
#include <QQueue>
+#include <QString>
+#include <cassert>
+#include <map>
+
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#else
#include <fcntl.h>
#include <unistd.h>
#endif
-#include <QString>
-#include <QTextCodec>
-#include <cassert>
-#include <map>
/*!
\class Pass
diff --git a/src/passworddialog.cpp b/src/passworddialog.cpp
index bcf16405..4e6ac959 100644
--- a/src/passworddialog.cpp
+++ b/src/passworddialog.cpp
@@ -4,7 +4,7 @@
#include "qtpasssettings.h"
#include "filecontent.h"
#include "ui_passworddialog.h"
-#include <QDebug>
+
#include <QLabel>
#include <QLineEdit>
diff --git a/src/passworddialog.h b/src/passworddialog.h
index 01c8a394..9755c8e2 100644
--- a/src/passworddialog.h
+++ b/src/passworddialog.h
@@ -1,9 +1,8 @@
#ifndef PASSWORDDIALOG_H_
#define PASSWORDDIALOG_H_
-#include "pass.h"
+//#include "pass.h"
#include <QDialog>
-#include <QWidget>
namespace Ui {
class PasswordDialog;
@@ -11,6 +10,7 @@ class PasswordDialog;
struct PasswordConfiguration;
class QLineEdit;
+class QWidget;
/*!
\class PasswordDialog
diff --git a/src/qpushbuttonwithclipboard.h b/src/qpushbuttonwithclipboard.h
index ddfd29ea..4dca9201 100644
--- a/src/qpushbuttonwithclipboard.h
+++ b/src/qpushbuttonwithclipboard.h
@@ -2,12 +2,13 @@
#define QPUSHBUTTONWITHCLIPBOARD_H_
#include <QPushButton>
-#include <QWidget>
+//#include <QWidget>
/*!
\class QPushButtonWithClipboard
\brief Stylish widget to allow copying of password and account details
*/
+class QWidget;
class QPushButtonWithClipboard : public QPushButton {
Q_OBJECT
diff --git a/src/qtpasssettings.cpp b/src/qtpasssettings.cpp
index 1507f229..aae4a5ac 100644
--- a/src/qtpasssettings.cpp
+++ b/src/qtpasssettings.cpp
@@ -3,6 +3,8 @@
#include "settingsconstants.h"
#include "util.h"
+#include <QCoreApplication>
+
QtPassSettings::QtPassSettings() {}
bool QtPassSettings::initialized = false;
diff --git a/src/qtpasssettings.h b/src/qtpasssettings.h
index daf10bed..196071c2 100644
--- a/src/qtpasssettings.h
+++ b/src/qtpasssettings.h
@@ -3,15 +3,11 @@
#include "enums.h"
#include "imitatepass.h"
-#include "pass.h"
#include "passwordconfiguration.h"
#include "realpass.h"
+
#include <QByteArray>
-#include <QCoreApplication>
-#include <QDir>
-#include <QFile>
#include <QHash>
-#include <QObject>
#include <QPoint>
#include <QSettings>
#include <QSize>
diff --git a/src/realpass.cpp b/src/realpass.cpp
index 6717193f..5684eccd 100644
--- a/src/realpass.cpp
+++ b/src/realpass.cpp
@@ -1,6 +1,9 @@
#include "realpass.h"
#include "qtpasssettings.h"
+#include <QDir>
+#include <QFileInfo>
+
using namespace Enums;
RealPass::RealPass() {}
diff --git a/src/storemodel.cpp b/src/storemodel.cpp
index ecc26db2..ffc30b60 100644
--- a/src/storemodel.cpp
+++ b/src/storemodel.cpp
@@ -1,8 +1,9 @@
+#include "qtpasssettings.h"
#include "storemodel.h"
+
#include <QDebug>
#include <QMessageBox>
#include <QMimeData>
-#include <QStringListModel>
QDataStream &
operator<<(QDataStream &out,
@@ -160,7 +161,9 @@ QMimeData *StoreModel::mimeData(const QModelIndexList &indexes) const {
bool StoreModel::canDropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column,
const QModelIndex &parent) const {
+#ifdef QT_DEBUG
qDebug() << action << row;
+#endif
QModelIndex useIndex =
this->index(parent.row(), parent.column(), parent.parent());
diff --git a/src/storemodel.h b/src/storemodel.h
index e92b518d..175132b2 100644
--- a/src/storemodel.h
+++ b/src/storemodel.h
@@ -2,17 +2,13 @@
#define STOREMODEL_H_
#include "util.h"
-#include <QDataStream>
-#include <QFileSystemModel>
-#include <QRegExp>
#include <QSortFilterProxyModel>
-#include <QStringListModel>
-#include <qtpasssettings.h>
/*!
\class StoreModel
\brief The QSortFilterProxyModel for handling filesystem searches.
*/
+class QFileSystemModel;
class StoreModel : public QSortFilterProxyModel {
Q_OBJECT
private:
diff --git a/src/trayicon.cpp b/src/trayicon.cpp
index 34f9cb4c..d08af611 100644
--- a/src/trayicon.cpp
+++ b/src/trayicon.cpp
@@ -1,4 +1,8 @@
#include "trayicon.h"
+#include <QAction>
+#include <QApplication>
+#include <QMainWindow>
+#include <QMenu>
/**
* @brief TrayIcon::TrayIcon use a (system) tray icon with a nice QtPass logo on
diff --git a/src/trayicon.h b/src/trayicon.h
index 6d943e35..8662561e 100644
--- a/src/trayicon.h
+++ b/src/trayicon.h
@@ -1,10 +1,6 @@
#ifndef TRAYICON_H_
#define TRAYICON_H_
-#include <QAction>
-#include <QApplication>
-#include <QMainWindow>
-#include <QMenu>
#include <QSystemTrayIcon>
#include <QWidget>
@@ -12,6 +8,9 @@
\class TrayIcon
\brief Handles the systemtray icon and menu.
*/
+class QAction;
+class QMainWindow;
+class QMenu;
class TrayIcon : public QWidget {
Q_OBJECT
diff --git a/src/usersdialog.h b/src/usersdialog.h
index 1efec027..ff79c312 100644
--- a/src/usersdialog.h
+++ b/src/usersdialog.h
@@ -2,16 +2,15 @@
#define USERSDIALOG_H_
#include "userinfo.h"
-#include <QCloseEvent>
-#include <QDateTime>
+
#include <QDialog>
#include <QList>
-#include <QStandardItemModel>
namespace Ui {
class UsersDialog;
}
+class QCloseEvent;
class QListWidgetItem;
/*!
diff --git a/src/util.cpp b/src/util.cpp
index 15a19ca1..36930e9f 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -2,8 +2,8 @@
#include "debughelper.h"
#include <QDir>
#include <QFileInfo>
-#include <QProcessEnvironment>
-#include <QString>
+//#include <QProcessEnvironment>
+//#include <QString>
#ifdef Q_OS_WIN
#include <windows.h>
#else
diff --git a/src/util.h b/src/util.h
index a790782e..b65d7099 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,6 +7,7 @@
#include <QString>
class StoreModel;
+
/*!
\class Util
\brief Some static utilities to be used elsewhere.