Make definitions for gui support project specific
This commit is contained in:
parent
1954565d63
commit
1c033b4746
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
||||||
|
|
||||||
# meta data
|
# meta data
|
||||||
set(META_PROJECT_NAME passwordmanager)
|
set(META_PROJECT_NAME passwordmanager)
|
||||||
|
set(META_PROJECT_VARNAME password_manager)
|
||||||
set(META_PROJECT_TYPE application)
|
set(META_PROJECT_TYPE application)
|
||||||
set(META_APP_NAME "Password Manager")
|
set(META_APP_NAME "Password Manager")
|
||||||
set(META_APP_CATEGORIES "Utility;Security;")
|
set(META_APP_CATEGORIES "Utility;Security;")
|
||||||
|
@ -126,7 +127,7 @@ include(BasicConfig)
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
if(WIDGETS_GUI OR QUICK_GUI)
|
if(WIDGETS_GUI OR QUICK_GUI)
|
||||||
find_package(qtutilities 5.0.0 REQUIRED)
|
find_package(qtutilities 5.7.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_FORWARD_DECLARE_CLASS(QModelIndex)
|
||||||
class QModelIndex;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Io {
|
namespace Io {
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
16
main.cpp
16
main.cpp
|
@ -1,8 +1,8 @@
|
||||||
#include "./cli/cli.h"
|
#include "./cli/cli.h"
|
||||||
#ifdef GUI_QTWIDGETS
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
# include "./gui/initiategui.h"
|
# include "./gui/initiategui.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef GUI_QTQUICK
|
#ifdef PASSWORD_MANAGER_GUI_QTQUICK
|
||||||
# include "./quickgui/initiatequick.h"
|
# include "./quickgui/initiatequick.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
#include <c++utilities/application/failure.h>
|
#include <c++utilities/application/failure.h>
|
||||||
#include <c++utilities/application/commandlineutils.h>
|
#include <c++utilities/application/commandlineutils.h>
|
||||||
|
|
||||||
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
|
#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK)
|
||||||
# include <qtutilities/resources/qtconfigarguments.h>
|
# include <qtutilities/resources/qtconfigarguments.h>
|
||||||
# include <QString>
|
# include <QString>
|
||||||
ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
|
ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
|
||||||
|
@ -65,30 +65,30 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
} else if(qtConfigArgs.areQtGuiArgsPresent()) {
|
} else if(qtConfigArgs.areQtGuiArgsPresent()) {
|
||||||
// run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified
|
// 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;
|
QString file;
|
||||||
if(fileArg.isPresent()) {
|
if(fileArg.isPresent()) {
|
||||||
file = QString::fromLocal8Bit(fileArg.values().front());
|
file = QString::fromLocal8Bit(fileArg.values().front());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
|
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
|
||||||
#ifdef GUI_QTWIDGETS
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
||||||
#else
|
#else
|
||||||
CMD_UTILS_START_CONSOLE;
|
CMD_UTILS_START_CONSOLE;
|
||||||
cout << "The application has not been built with Qt widgets support." << endl;
|
cout << "The application has not been built with Qt widgets support." << endl;
|
||||||
#endif
|
#endif
|
||||||
} else if(qtConfigArgs.qtQuickGuiArg().isPresent()) {
|
} else if(qtConfigArgs.qtQuickGuiArg().isPresent()) {
|
||||||
#ifdef GUI_QTQUICK
|
#ifdef PASSWORD_MANAGER_GUI_QTQUICK
|
||||||
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
||||||
#else
|
#else
|
||||||
CMD_UTILS_START_CONSOLE;
|
CMD_UTILS_START_CONSOLE;
|
||||||
cout << "The application has not been built with Qt quick support." << endl;
|
cout << "The application has not been built with Qt quick support." << endl;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if defined(GUI_QTQUICK)
|
#if defined(PASSWORD_MANAGER_GUI_QTQUICK)
|
||||||
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
|
||||||
#elif defined(GUI_QTWIDGETS)
|
#elif defined(PASSWORD_MANAGER_GUI_QTWIDGETS)
|
||||||
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
|
||||||
#else
|
#else
|
||||||
CMD_UTILS_START_CONSOLE;
|
CMD_UTILS_START_CONSOLE;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "./entrymodel.h"
|
#include "./entrymodel.h"
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
# include "./gui/undocommands.h"
|
# include "./gui/undocommands.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace QtGui {
|
||||||
* \class EntryModel
|
* \class EntryModel
|
||||||
* \brief The EntryModel class provides a model interface for a hierarchy of Entry instances.
|
* \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/qabstractitemmodel.html
|
||||||
* \sa http://qt-project.org/doc/qt-5/qundo.html
|
* \sa http://qt-project.org/doc/qt-5/qundo.html
|
||||||
*/
|
*/
|
||||||
|
@ -38,11 +38,11 @@ EntryModel::EntryModel(QObject *parent) :
|
||||||
m_insertType(EntryType::Node)
|
m_insertType(EntryType::Node)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructs a new entry model with the specified \a undoStack.
|
* \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) :
|
EntryModel::EntryModel(QUndoStack *undoStack, QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
|
@ -258,7 +258,7 @@ QMap<int, QVariant> EntryModel::itemData(const QModelIndex &index) const
|
||||||
|
|
||||||
bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new EntryModelSetValueCommand(this, index, value, role));
|
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)
|
bool EntryModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new EntryModelInsertRowsCommand(this, row, count, parent));
|
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)
|
bool EntryModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new EntryModelRemoveRowsCommand(this, row, count, parent));
|
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)
|
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()) {
|
if(undoStack()) {
|
||||||
return push(new EntryModelMoveRowsCommand(this, sourceParent, sourceRow, count, destinationParent, destinationChild));
|
return push(new EntryModelMoveRowsCommand(this, sourceParent, sourceRow, count, destinationParent, destinationChild));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef ENTRYMODEL_H
|
#ifndef ENTRYMODEL_H
|
||||||
#define ENTRYMODEL_H
|
#define ENTRYMODEL_H
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
# include "gui/stacksupport.h"
|
# include "gui/stacksupport.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ enum EntryModelRoles
|
||||||
};
|
};
|
||||||
|
|
||||||
class EntryModel : public QAbstractItemModel
|
class EntryModel : public QAbstractItemModel
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
, public StackSupport
|
, public StackSupport
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EntryModel(QObject *parent = nullptr);
|
explicit EntryModel(QObject *parent = nullptr);
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
explicit EntryModel(QUndoStack *undoStack, QObject *parent = nullptr);
|
explicit EntryModel(QUndoStack *undoStack, QObject *parent = nullptr);
|
||||||
#endif
|
#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)
|
inline void EntryModel::setRootEntry(Io::NodeEntry *entry)
|
||||||
{
|
{
|
||||||
if(m_rootEntry != entry) {
|
if(m_rootEntry != entry) {
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
clearUndoStack();
|
clearUndoStack();
|
||||||
#endif
|
#endif
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "./fieldmodel.h"
|
#include "./fieldmodel.h"
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
# include "./gui/undocommands.h"
|
# include "./gui/undocommands.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace QtGui {
|
||||||
* \class FieldModel
|
* \class FieldModel
|
||||||
* \brief The FieldModel class provides a model interface for the fields of an AccountEntry.
|
* \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/qabstracttablemodel.html
|
||||||
* \sa http://qt-project.org/doc/qt-5/qundo.html
|
* \sa http://qt-project.org/doc/qt-5/qundo.html
|
||||||
*/
|
*/
|
||||||
|
@ -33,11 +33,11 @@ FieldModel::FieldModel(QObject *parent) :
|
||||||
m_passwordVisibility(PasswordVisibility::OnlyWhenEditing)
|
m_passwordVisibility(PasswordVisibility::OnlyWhenEditing)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructs a new field model with the specified \a undoStack.
|
* \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) :
|
FieldModel::FieldModel(QUndoStack *undoStack, QObject *parent) :
|
||||||
QAbstractTableModel(parent),
|
QAbstractTableModel(parent),
|
||||||
|
@ -129,7 +129,7 @@ QMap<int, QVariant> FieldModel::itemData(const QModelIndex &index) const
|
||||||
|
|
||||||
bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
#if MODEL_UNDO_SUPPORT
|
#if PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new FieldModelSetValueCommand(this, index, value, role));
|
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)
|
bool FieldModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new FieldModelInsertRowsCommand(this, row, count));
|
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)
|
bool FieldModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
if(undoStack()) {
|
if(undoStack()) {
|
||||||
return push(new FieldModelRemoveRowsCommand(this, row, count));
|
return push(new FieldModelRemoveRowsCommand(this, row, count));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef FIELDMODEL_H
|
#ifndef FIELDMODEL_H
|
||||||
#define FIELDMODEL_H
|
#define FIELDMODEL_H
|
||||||
|
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
# include "gui/stacksupport.h"
|
# include "gui/stacksupport.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ enum PasswordVisibility
|
||||||
};
|
};
|
||||||
|
|
||||||
class FieldModel : public QAbstractTableModel
|
class FieldModel : public QAbstractTableModel
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
, public StackSupport
|
, public StackSupport
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FieldModel(QObject *parent = nullptr);
|
explicit FieldModel(QObject *parent = nullptr);
|
||||||
#ifdef MODEL_UNDO_SUPPORT
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
explicit FieldModel(QUndoStack *undoStack, QObject *parent = nullptr);
|
explicit FieldModel(QUndoStack *undoStack, QObject *parent = nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue