diff --git a/CMakeLists.txt b/CMakeLists.txt index f7975e5..b9bc43d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) # meta data set(META_PROJECT_NAME passwordmanager) +set(META_PROJECT_VARNAME password_manager) set(META_PROJECT_TYPE application) set(META_APP_NAME "Password Manager") set(META_APP_CATEGORIES "Utility;Security;") @@ -126,7 +127,7 @@ include(BasicConfig) # find qtutilities if(WIDGETS_GUI OR QUICK_GUI) - find_package(qtutilities 5.0.0 REQUIRED) + find_package(qtutilities 5.7.0 REQUIRED) use_qt_utilities() endif() diff --git a/gui/undocommands.h b/gui/undocommands.h index 9495211..9684300 100644 --- a/gui/undocommands.h +++ b/gui/undocommands.h @@ -8,9 +8,7 @@ #include #include -QT_BEGIN_NAMESPACE -class QModelIndex; -QT_END_NAMESPACE +QT_FORWARD_DECLARE_CLASS(QModelIndex) namespace Io { class Entry; diff --git a/main.cpp b/main.cpp index 8957d21..17303a5 100644 --- a/main.cpp +++ b/main.cpp @@ -1,8 +1,8 @@ #include "./cli/cli.h" -#ifdef GUI_QTWIDGETS +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS # include "./gui/initiategui.h" #endif -#ifdef GUI_QTQUICK +#ifdef PASSWORD_MANAGER_GUI_QTQUICK # include "./quickgui/initiatequick.h" #endif @@ -14,7 +14,7 @@ #include #include -#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) +#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK) # include # include ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES @@ -65,30 +65,30 @@ int main(int argc, char *argv[]) } } else if(qtConfigArgs.areQtGuiArgsPresent()) { // run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified -#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) +#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK) QString file; if(fileArg.isPresent()) { file = QString::fromLocal8Bit(fileArg.values().front()); } #endif if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) { -#ifdef GUI_QTWIDGETS +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file); #else CMD_UTILS_START_CONSOLE; cout << "The application has not been built with Qt widgets support." << endl; #endif } else if(qtConfigArgs.qtQuickGuiArg().isPresent()) { -#ifdef GUI_QTQUICK +#ifdef PASSWORD_MANAGER_GUI_QTQUICK res = QtGui::runQuickGui(argc, argv, qtConfigArgs); #else CMD_UTILS_START_CONSOLE; cout << "The application has not been built with Qt quick support." << endl; #endif } else { -#if defined(GUI_QTQUICK) +#if defined(PASSWORD_MANAGER_GUI_QTQUICK) res = QtGui::runQuickGui(argc, argv, qtConfigArgs); -#elif defined(GUI_QTWIDGETS) +#elif defined(PASSWORD_MANAGER_GUI_QTWIDGETS) res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file); #else CMD_UTILS_START_CONSOLE; diff --git a/model/entrymodel.cpp b/model/entrymodel.cpp index 5bd8a1a..d29cdba 100644 --- a/model/entrymodel.cpp +++ b/model/entrymodel.cpp @@ -1,6 +1,6 @@ #include "./entrymodel.h" -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS # include "./gui/undocommands.h" #endif @@ -24,7 +24,7 @@ namespace QtGui { * \class EntryModel * \brief The EntryModel class provides a model interface for a hierarchy of Entry instances. * - * If MODEL_UNDO_SUPPORT the model supports Qt's undo framework. + * When building the Qt Widgets GUI, the model also supports Qt Widgets' undo framework. * \sa http://qt-project.org/doc/qt-5/qabstractitemmodel.html * \sa http://qt-project.org/doc/qt-5/qundo.html */ @@ -38,11 +38,11 @@ EntryModel::EntryModel(QObject *parent) : m_insertType(EntryType::Node) {} -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS /*! * \brief Constructs a new entry model with the specified \a undoStack. * - * This constructor is only available when MODEL_UNDO_SUPPORT is defined. + * This constructor is only available when PASSWORD_MANAGER_GUI_QTWIDGETS is defined. */ EntryModel::EntryModel(QUndoStack *undoStack, QObject *parent) : QAbstractItemModel(parent), @@ -258,7 +258,7 @@ QMap EntryModel::itemData(const QModelIndex &index) const bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int role) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new EntryModelSetValueCommand(this, index, value, role)); } @@ -383,7 +383,7 @@ int EntryModel::columnCount(const QModelIndex &) const bool EntryModel::insertRows(int row, int count, const QModelIndex &parent) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new EntryModelInsertRowsCommand(this, row, count, parent)); } @@ -416,7 +416,7 @@ bool EntryModel::insertRows(int row, int count, const QModelIndex &parent) bool EntryModel::removeRows(int row, int count, const QModelIndex &parent) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new EntryModelRemoveRowsCommand(this, row, count, parent)); } @@ -436,7 +436,7 @@ bool EntryModel::removeRows(int row, int count, const QModelIndex &parent) bool EntryModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new EntryModelMoveRowsCommand(this, sourceParent, sourceRow, count, destinationParent, destinationChild)); } diff --git a/model/entrymodel.h b/model/entrymodel.h index 86dd6df..2d2a798 100644 --- a/model/entrymodel.h +++ b/model/entrymodel.h @@ -1,7 +1,7 @@ #ifndef ENTRYMODEL_H #define ENTRYMODEL_H -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS # include "gui/stacksupport.h" #endif @@ -27,14 +27,14 @@ enum EntryModelRoles }; class EntryModel : public QAbstractItemModel -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS , public StackSupport #endif { Q_OBJECT public: explicit EntryModel(QObject *parent = nullptr); -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS explicit EntryModel(QUndoStack *undoStack, QObject *parent = nullptr); #endif @@ -84,12 +84,13 @@ inline Io::NodeEntry *EntryModel::rootEntry() } /*! - * \brief Sets the root entry. Causes a model reset. The undo stack will be cleard if MODEL_UNDO_SUPPORT is defined. + * \brief Sets the root entry. Causes a model reset. The undo stack for the Qt Widgets GUI will be cleared if building + * with Qt Widgets GUI support. */ inline void EntryModel::setRootEntry(Io::NodeEntry *entry) { if(m_rootEntry != entry) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS clearUndoStack(); #endif beginResetModel(); diff --git a/model/fieldmodel.cpp b/model/fieldmodel.cpp index 7d19d48..61b93a6 100644 --- a/model/fieldmodel.cpp +++ b/model/fieldmodel.cpp @@ -1,6 +1,6 @@ #include "./fieldmodel.h" -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS # include "./gui/undocommands.h" #endif @@ -18,7 +18,7 @@ namespace QtGui { * \class FieldModel * \brief The FieldModel class provides a model interface for the fields of an AccountEntry. * - * If MODEL_UNDO_SUPPORT the model supports Qt's undo framework. + * When building the Qt Widgets GUI, the model also supports Qt Widgets' undo framework. * \sa http://qt-project.org/doc/qt-5/qabstracttablemodel.html * \sa http://qt-project.org/doc/qt-5/qundo.html */ @@ -33,11 +33,11 @@ FieldModel::FieldModel(QObject *parent) : m_passwordVisibility(PasswordVisibility::OnlyWhenEditing) {} -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS /*! * \brief Constructs a new field model with the specified \a undoStack. * - * This constructor is only available when MODEL_UNDO_SUPPORT is defined. + * This constructor is only available when PASSWORD_MANAGER_GUI_QTWIDGETS is defined. */ FieldModel::FieldModel(QUndoStack *undoStack, QObject *parent) : QAbstractTableModel(parent), @@ -129,7 +129,7 @@ QMap FieldModel::itemData(const QModelIndex &index) const bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int role) { -#if MODEL_UNDO_SUPPORT +#if PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new FieldModelSetValueCommand(this, index, value, role)); } @@ -262,7 +262,7 @@ int FieldModel::columnCount(const QModelIndex &parent) const bool FieldModel::insertRows(int row, int count, const QModelIndex &parent) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new FieldModelInsertRowsCommand(this, row, count)); } @@ -278,7 +278,7 @@ bool FieldModel::insertRows(int row, int count, const QModelIndex &parent) bool FieldModel::removeRows(int row, int count, const QModelIndex &parent) { -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS if(undoStack()) { return push(new FieldModelRemoveRowsCommand(this, row, count)); } diff --git a/model/fieldmodel.h b/model/fieldmodel.h index 1158742..3d3fc23 100644 --- a/model/fieldmodel.h +++ b/model/fieldmodel.h @@ -1,7 +1,7 @@ #ifndef FIELDMODEL_H #define FIELDMODEL_H -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS # include "gui/stacksupport.h" #endif @@ -36,14 +36,14 @@ enum PasswordVisibility }; class FieldModel : public QAbstractTableModel -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS , public StackSupport #endif { Q_OBJECT public: explicit FieldModel(QObject *parent = nullptr); -#ifdef MODEL_UNDO_SUPPORT +#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS explicit FieldModel(QUndoStack *undoStack, QObject *parent = nullptr); #endif