Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning #includes #364

Merged
merged 2 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions main/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "mainwindow.h"
#if SINGLE_APP
#include "singleapplication.h"
#endif

#include <QApplication>
#include <QTranslator>

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ui_configdialog.h"
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#ifdef Q_OS_WIN
#include <windows.h>
Expand Down
13 changes: 7 additions & 6 deletions src/configdialog.h
Original file line number Diff line number Diff line change
@@ -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

/*!
Expand All @@ -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

Expand Down
9 changes: 6 additions & 3 deletions src/deselectabletreeview.h
Original file line number Diff line number Diff line change
@@ -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>

/**
Expand Down
49 changes: 25 additions & 24 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
88 changes: 44 additions & 44 deletions src/filecontent.h
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
#ifndef FILECONTENT_H
#define FILECONTENT_H

#include <utility>
//#include <utility>
#include <QList>
#include <QString>

struct NamedValue {
QString name;
QString value;
QString name;
QString value;
};

/**
* @brief The NamedValues class is mostly a list of \link 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
1 change: 1 addition & 0 deletions src/keygendialog.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "configdialog.h"
#include "keygendialog.h"
#include "debughelper.h"
#include "qprogressindicator.h"
Expand Down
6 changes: 3 additions & 3 deletions src/keygendialog.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 5 additions & 10 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -40,6 +33,8 @@ class MainWindow;

This class could really do with an overhaul.
*/
class Pass;
class TrayIcon;
class MainWindow : public QMainWindow {
Q_OBJECT

Expand Down
12 changes: 5 additions & 7 deletions src/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/passworddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "qtpasssettings.h"
#include "filecontent.h"
#include "ui_passworddialog.h"
#include <QDebug>

#include <QLabel>
#include <QLineEdit>

Expand Down
4 changes: 2 additions & 2 deletions src/passworddialog.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef PASSWORDDIALOG_H_
#define PASSWORDDIALOG_H_

#include "pass.h"
//#include "pass.h"
#include <QDialog>
#include <QWidget>

namespace Ui {
class PasswordDialog;
}

struct PasswordConfiguration;
class QLineEdit;
class QWidget;

/*!
\class PasswordDialog
Expand Down
Loading