Make definitions for gui support project specific

This commit is contained in:
Martchus 2017-04-27 22:16:26 +02:00
parent 1954565d63
commit 1c033b4746
7 changed files with 35 additions and 35 deletions

View File

@ -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()

View File

@ -8,9 +8,7 @@
#include <QList>
#include <QVariant>
QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QModelIndex)
namespace Io {
class Entry;

View File

@ -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 <c++utilities/application/failure.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 <QString>
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;

View File

@ -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<int, QVariant> 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));
}

View File

@ -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();

View File

@ -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<int, QVariant> 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));
}

View File

@ -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