Apply clang format on all GUI files
This commit is contained in:
parent
836e6bbcb2
commit
575d0cabdb
|
@ -432,15 +432,15 @@ bool MainWindow::openFile(const QString &path, bool readOnly)
|
|||
}
|
||||
|
||||
// show error message
|
||||
const QString errmsg
|
||||
= tr("An IO error occured when opening the specified file \"%1\".\n\n(%2)").arg(path, QString::fromLocal8Bit(ioError));
|
||||
const QString errmsg = tr("An IO error occured when opening the specified file \"%1\".\n\n(%2)").arg(path, QString::fromLocal8Bit(ioError));
|
||||
m_ui->statusBar->showMessage(errmsg, 5000);
|
||||
QMessageBox::critical(this, QApplication::applicationName(), errmsg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// warn before loading a very big file
|
||||
if (m_file.size() > 10485760 && QMessageBox::warning(this, QApplication::applicationName(),
|
||||
if (m_file.size() > 10485760
|
||||
&& QMessageBox::warning(this, QApplication::applicationName(),
|
||||
tr("The file you want to load seems to be very big. Do you really want to open it?"), QMessageBox::Yes, QMessageBox::No)
|
||||
== QMessageBox::No) {
|
||||
m_file.clear();
|
||||
|
@ -942,8 +942,8 @@ void MainWindow::addEntry(EntryType type)
|
|||
return;
|
||||
}
|
||||
bool result;
|
||||
const QString text = QInputDialog::getText(this, type == EntryType::Account ? tr("Add account") : tr("Add category"),
|
||||
tr("Enter the entry name"), QLineEdit::Normal, tr("new entry"), &result);
|
||||
const QString text = QInputDialog::getText(this, type == EntryType::Account ? tr("Add account") : tr("Add category"), tr("Enter the entry name"),
|
||||
QLineEdit::Normal, tr("new entry"), &result);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@ namespace QtGui {
|
|||
/*!
|
||||
* \brief Constructs a new filter entry model.
|
||||
*/
|
||||
EntryFilterModel::EntryFilterModel(QObject *parent) :
|
||||
QSortFilterProxyModel(parent)
|
||||
{}
|
||||
EntryFilterModel::EntryFilterModel(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool EntryFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
|
@ -43,4 +44,4 @@ bool EntryFilterModel::hasAcceptedChildren(const QModelIndex &index) const
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include <c++utilities/io/catchiofailure.h>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QBuffer>
|
||||
#include <QMimeData>
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -32,11 +32,12 @@ namespace QtGui {
|
|||
/*!
|
||||
* \brief Constructs a new entry model.
|
||||
*/
|
||||
EntryModel::EntryModel(QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
m_rootEntry(nullptr),
|
||||
m_insertType(EntryType::Node)
|
||||
{}
|
||||
EntryModel::EntryModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_rootEntry(nullptr)
|
||||
, m_insertType(EntryType::Node)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||
/*!
|
||||
|
@ -44,12 +45,13 @@ EntryModel::EntryModel(QObject *parent) :
|
|||
*
|
||||
* This constructor is only available when PASSWORD_MANAGER_GUI_QTWIDGETS is defined.
|
||||
*/
|
||||
EntryModel::EntryModel(QUndoStack *undoStack, QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
StackSupport(undoStack),
|
||||
m_rootEntry(nullptr),
|
||||
m_insertType(EntryType::Node)
|
||||
{}
|
||||
EntryModel::EntryModel(QUndoStack *undoStack, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, StackSupport(undoStack)
|
||||
, m_rootEntry(nullptr)
|
||||
, m_insertType(EntryType::Node)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
@ -144,8 +146,8 @@ QModelIndex EntryModel::index(int row, int column, const QModelIndex &parent) co
|
|||
return createIndex(row, column, children[static_cast<size_t>(row)]);
|
||||
}
|
||||
break;
|
||||
} case EntryType::Account:
|
||||
;
|
||||
}
|
||||
case EntryType::Account:;
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
@ -216,8 +218,7 @@ QVariant EntryModel::data(const QModelIndex &index, int role) const
|
|||
switch (index.column()) {
|
||||
case 0:
|
||||
return QString::fromStdString(entry->label());
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
|
@ -237,12 +238,10 @@ QVariant EntryModel::data(const QModelIndex &index, int role) const
|
|||
IoUtilities::catchIoFailure();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case DefaultExpandedRole:
|
||||
return entry->type() == EntryType::Node && static_cast<const NodeEntry *>(entry)->isExpandedByDefault();
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -277,8 +276,7 @@ bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
entry->setLabel(value.toString().toStdString());
|
||||
emit dataChanged(index, index, QVector<int>() << role);
|
||||
return true;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
case SerializedRole: {
|
||||
|
@ -307,8 +305,7 @@ bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
} catch (...) {
|
||||
IoUtilities::catchIoFailure();
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case DefaultExpandedRole:
|
||||
switch (entry->type()) {
|
||||
case EntryType::Account:
|
||||
|
@ -319,8 +316,7 @@ bool EntryModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -335,8 +331,7 @@ bool EntryModel::setItemData(const QModelIndex &index, const QMap<int, QVariant>
|
|||
|
||||
Qt::ItemFlags EntryModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return isNode(index)
|
||||
? QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled
|
||||
return isNode(index) ? QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled
|
||||
: QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
|
||||
|
@ -349,16 +344,13 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
switch (section) {
|
||||
case 0:
|
||||
return tr("Name");
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -370,8 +362,7 @@ int EntryModel::rowCount(const QModelIndex &parent) const
|
|||
switch (parentEntry->type()) {
|
||||
case EntryType::Node:
|
||||
return static_cast<NodeEntry *>(parentEntry)->children().size();
|
||||
case EntryType::Account:
|
||||
;
|
||||
case EntryType::Account:;
|
||||
}
|
||||
}
|
||||
} else if (m_rootEntry) {
|
||||
|
@ -446,8 +437,7 @@ bool EntryModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int co
|
|||
}
|
||||
#endif
|
||||
// check validation of specified arguments
|
||||
if(!sourceParent.isValid() || !destinationParent.isValid()
|
||||
|| sourceRow < 0 || count <= 0
|
||||
if (!sourceParent.isValid() || !destinationParent.isValid() || sourceRow < 0 || count <= 0
|
||||
|| entry(sourceParent)->type() != EntryType::Node // source and destination parent entries
|
||||
|| entry(destinationParent)->type() != EntryType::Node) { // need to be node entries
|
||||
return false;
|
||||
|
@ -568,4 +558,4 @@ Qt::DropActions EntryModel::supportedDropActions() const
|
|||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -26,12 +26,13 @@ namespace QtGui {
|
|||
/*!
|
||||
* \brief Constructs a new field model.
|
||||
*/
|
||||
FieldModel::FieldModel(QObject *parent) :
|
||||
QAbstractTableModel(parent),
|
||||
m_accountEntry(nullptr),
|
||||
m_fields(nullptr),
|
||||
m_passwordVisibility(PasswordVisibility::OnlyWhenEditing)
|
||||
{}
|
||||
FieldModel::FieldModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_accountEntry(nullptr)
|
||||
, m_fields(nullptr)
|
||||
, m_passwordVisibility(PasswordVisibility::OnlyWhenEditing)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||
/*!
|
||||
|
@ -39,12 +40,13 @@ FieldModel::FieldModel(QObject *parent) :
|
|||
*
|
||||
* This constructor is only available when PASSWORD_MANAGER_GUI_QTWIDGETS is defined.
|
||||
*/
|
||||
FieldModel::FieldModel(QUndoStack *undoStack, QObject *parent) :
|
||||
QAbstractTableModel(parent),
|
||||
StackSupport(undoStack),
|
||||
m_accountEntry(nullptr),
|
||||
m_fields(nullptr)
|
||||
{}
|
||||
FieldModel::FieldModel(QUndoStack *undoStack, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, StackSupport(undoStack)
|
||||
, m_accountEntry(nullptr)
|
||||
, m_fields(nullptr)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
|
@ -81,19 +83,16 @@ QVariant FieldModel::data(const QModelIndex &index, int role) const
|
|||
case 0:
|
||||
return QString::fromStdString((*m_fields)[static_cast<size_t>(index.row())].name());
|
||||
case 1:
|
||||
return (m_passwordVisibility == PasswordVisibility::Always
|
||||
|| role == Qt::EditRole
|
||||
return (m_passwordVisibility == PasswordVisibility::Always || role == Qt::EditRole
|
||||
|| (*m_fields)[static_cast<size_t>(index.row())].type() != FieldType::Password)
|
||||
? QString::fromStdString((*m_fields)[static_cast<size_t>(index.row())].value())
|
||||
: QString((*m_fields)[static_cast<size_t>(index.row())].value().size(), QChar(0x2022));
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
case FieldTypeRole:
|
||||
return static_cast<int>((*m_fields)[static_cast<size_t>(index.row())].type());
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
// return data for empty field at the end which enables the user to append fields
|
||||
} else if (static_cast<size_t>(index.row()) == m_fields->size()) {
|
||||
|
@ -105,12 +104,10 @@ QVariant FieldModel::data(const QModelIndex &index, int role) const
|
|||
return QString();
|
||||
case 1:
|
||||
return QString();
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
|
@ -155,8 +152,7 @@ bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
m_fields->at(index.row()).setValue(value.toString().toStdString());
|
||||
roles << role;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
case FieldTypeRole: {
|
||||
|
@ -167,8 +163,8 @@ bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
m_fields->at(index.row()).setType(static_cast<FieldType>(fieldType));
|
||||
}
|
||||
break;
|
||||
} default:
|
||||
;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
// remove last field if empty, showing an empty field at the end to enabled appending new rows is provided by the data method
|
||||
if (!roles.isEmpty() && static_cast<size_t>(index.row()) == m_fields->size() - 1 && m_fields->at(index.row()).isEmpty()) {
|
||||
|
@ -196,12 +192,10 @@ bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
endInsertRows();
|
||||
roles << role;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
// return false if nothing could be changed
|
||||
|
@ -216,8 +210,7 @@ bool FieldModel::setData(const QModelIndex &index, const QVariant &value, int ro
|
|||
case FieldTypeRole:
|
||||
roles << Qt::DisplayRole << Qt::EditRole;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
// emit data changed signal on sucess
|
||||
emit dataChanged(index, index, roles);
|
||||
|
@ -240,16 +233,13 @@ QVariant FieldModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
return tr("Name");
|
||||
case 1:
|
||||
return tr("Value");
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
default:;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -335,6 +325,4 @@ const Field *FieldModel::field(size_t row) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace QtGui
|
||||
|
|
Loading…
Reference in New Issue