Commit f086660b authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov
Browse files

clang-format Applications/DataExplorer

parent 4db612ab
......@@ -14,6 +14,7 @@
// ** INCLUDES **
#include "CheckboxDelegate.h"
#include <QApplication>
#include <QCheckBox>
#include <QEvent>
......@@ -21,15 +22,13 @@
#include <QPainter>
#include <QStyleOptionButton>
CheckboxDelegate::CheckboxDelegate(QObject* parent)
: QItemDelegate(parent)
{
}
CheckboxDelegate::CheckboxDelegate(QObject* parent) : QItemDelegate(parent) {}
void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
void CheckboxDelegate::paint(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
if(index.isValid())
if (index.isValid())
{
bool checked = index.model()->data(index, Qt::DisplayRole).toBool();
......@@ -56,7 +55,8 @@ void CheckboxDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
}
bool CheckboxDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
const QStyleOptionViewItem &option, const QModelIndex &index)
const QStyleOptionViewItem& option,
const QModelIndex& index)
{
Q_UNUSED(option);
......@@ -91,8 +91,8 @@ bool CheckboxDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
return model->setData(index, !checked, Qt::EditRole);
}
QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem & option,
const QModelIndex & index) const
QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
Q_UNUSED(index);
......@@ -100,14 +100,16 @@ QSize CheckboxDelegate::sizeHint(const QStyleOptionViewItem & option,
return QSize(rect.width(), rect.height());
}
QRect CheckboxDelegate::checkboxRect(const QStyleOptionViewItem& viewItemStyleOptions) const
QRect CheckboxDelegate::checkboxRect(
const QStyleOptionViewItem& viewItemStyleOptions) const
{
QStyleOptionButton styleOptionButton;
QRect rect = QApplication::style()->subElementRect(
QStyle::SE_CheckBoxIndicator, &styleOptionButton);
QStyle::SE_CheckBoxIndicator, &styleOptionButton);
QPoint point(viewItemStyleOptions.rect.x() +
viewItemStyleOptions.rect.width() / 2 - rect.width() / 2,
viewItemStyleOptions.rect.y() + viewItemStyleOptions.rect.height() / 2 -
rect.height() / 2);
viewItemStyleOptions.rect.width() / 2 - rect.width() / 2,
viewItemStyleOptions.rect.y() +
viewItemStyleOptions.rect.height() / 2 -
rect.height() / 2);
return QRect(point, rect.size());
}
......@@ -17,7 +17,7 @@
#include <QColorDialog>
ColorPickerPushButton::ColorPickerPushButton( QWidget* parent /*= 0*/ )
ColorPickerPushButton::ColorPickerPushButton(QWidget* parent /*= 0*/)
: QPushButton(parent)
{
setAutoFillBackground(true);
......@@ -38,7 +38,7 @@ void ColorPickerPushButton::mouseReleaseEvent(QMouseEvent* e)
emit colorPicked(_color);
}
QString ColorPickerPushButton::colorToCss( QColor color )
QString ColorPickerPushButton::colorToCss(QColor color)
{
QString colorStr = "rgb";
colorStr.append(colorToString(color));
......@@ -46,7 +46,7 @@ QString ColorPickerPushButton::colorToCss( QColor color )
return colorStr;
}
QString ColorPickerPushButton::colorToString( QColor color )
QString ColorPickerPushButton::colorToString(QColor color)
{
QString colorStr = "(";
colorStr.append(QString::number(color.red()));
......@@ -59,7 +59,7 @@ QString ColorPickerPushButton::colorToString( QColor color )
return colorStr;
}
void ColorPickerPushButton::setColor( QColor color )
void ColorPickerPushButton::setColor(QColor color)
{
_color = color;
......@@ -84,7 +84,7 @@ void ColorPickerPushButton::setColor( QColor color )
this->setText(colorToString(_color));
}
void ColorPickerPushButton::setColor( double* color )
void ColorPickerPushButton::setColor(double* color)
{
setColor(QColor::fromRgbF(color[0], color[1], color[2]));
}
......@@ -20,12 +20,12 @@ OGSError::OGSError() = default;
OGSError::~OGSError() = default;
void OGSError::box(const QString &e)
void OGSError::box(const QString& e)
{
box(e, "OpenGeoSys");
}
void OGSError::box(const QString &e, const QString &t)
void OGSError::box(const QString& e, const QString& t)
{
QMessageBox msgBox;
msgBox.setWindowTitle(t);
......@@ -33,7 +33,7 @@ void OGSError::box(const QString &e, const QString &t)
msgBox.exec();
}
bool OGSError::question(const QString &e, const QString &t)
bool OGSError::question(const QString& e, const QString& t)
{
QMessageBox msgBox;
msgBox.setWindowTitle(t);
......@@ -43,4 +43,3 @@ bool OGSError::question(const QString &e, const QString &t)
return msgBox.exec() == QMessageBox::Ok;
}
......@@ -13,11 +13,13 @@
*/
#include "QNonScalableGraphicsTextItem.h"
#include <QPainter>
/// Constructor using a QGraphicsTextItem.
QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(QGraphicsItem* parent) :
QGraphicsTextItem(parent)
QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(
QGraphicsItem* parent)
: QGraphicsTextItem(parent)
{
setAcceptDrops(true);
setAcceptHoverEvents(true);
......@@ -25,9 +27,9 @@ QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(QGraphicsItem* parent
}
/// Constructor using a QString.
QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(const QString & text,
QGraphicsItem* parent) :
QGraphicsTextItem(parent)
QNonScalableGraphicsTextItem::QNonScalableGraphicsTextItem(
const QString& text, QGraphicsItem* parent)
: QGraphicsTextItem(parent)
{
if (!text.isEmpty())
{
......@@ -45,7 +47,7 @@ void QNonScalableGraphicsTextItem::paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget)
{
//painter->drawRect(boundingRect());
// painter->drawRect(boundingRect());
QRectF rect = boundingRect();
painter->translate(-rect.width() / 2, -rect.height() / 2);
QGraphicsTextItem::paint(painter, option, widget);
......@@ -55,5 +57,6 @@ void QNonScalableGraphicsTextItem::paint(QPainter* painter,
QRectF QNonScalableGraphicsTextItem::boundingRect() const
{
QRectF rect = QGraphicsTextItem::boundingRect();
return rect; //QRectF(rect.x()-rect.width()/2, rect.y()-rect.height()/2,rect.width(), rect.height());
return rect; // QRectF(rect.x()-rect.width()/2,
// rect.y()-rect.height()/2,rect.width(), rect.height());
}
......@@ -19,8 +19,7 @@
#include <QString>
#include <QToolTip>
QValueTooltipSlider::QValueTooltipSlider(QWidget* parent)
: QSlider(parent)
QValueTooltipSlider::QValueTooltipSlider(QWidget* parent) : QSlider(parent)
{
connect(this, SIGNAL(sliderMoved(int)), this, SLOT(setTooltipValue(int)));
}
......
......@@ -43,7 +43,7 @@ QMenu* RecentFiles::menu()
{
return _filesMenu;
}
void RecentFiles::setCurrentFile( const QString& filename )
void RecentFiles::setCurrentFile(const QString& filename)
{
_currentFile = filename;
......@@ -81,7 +81,7 @@ void RecentFiles::updateRecentFileActions()
}
}
QString RecentFiles::strippedName( const QString& fullFileName )
QString RecentFiles::strippedName(const QString& fullFileName)
{
return QFileInfo(fullFileName).fileName();
}
......@@ -12,10 +12,10 @@
*
*/
#include <utility>
#include "TreeItem.h"
#include <utility>
/**
* The constructor is only used to record the item's parent
* and the data associated with each column.
......@@ -99,7 +99,7 @@ QVariant TreeItem::data(int column) const
/**
* Sets the data at a given column.
*/
bool TreeItem::setData( int column, const QVariant &value )
bool TreeItem::setData(int column, const QVariant& value)
{
if (column < 0 || column >= _itemData.size())
{
......@@ -118,7 +118,8 @@ TreeItem* TreeItem::parentItem() const
}
/**
* Removes a number of children of the TreeItem starting from the given position.
* Removes a number of children of the TreeItem starting from the given
* position.
*/
bool TreeItem::removeChildren(int position, int count)
{
......
......@@ -14,23 +14,24 @@
#include "TreeModel.h"
#include "TreeItem.h"
#include <QModelIndex>
#include <QStringList>
#include <QVariant>
#include "TreeItem.h"
/**
* A model for the QTreeView implementing the tree as a double-linked list.
*/
TreeModel::TreeModel( QObject* parent )
: QAbstractItemModel(parent)
TreeModel::TreeModel(QObject* parent) : QAbstractItemModel(parent)
{
//_modelType = TREE_MODEL;
QList<QVariant> rootData;
rootData << "1" << "2" << "3";
rootData << "1"
<< "2"
<< "3";
_rootItem = new TreeItem(rootData, nullptr);
//setupModelData(data, _rootItem);
// setupModelData(data, _rootItem);
}
TreeModel::~TreeModel()
......@@ -40,15 +41,14 @@ TreeModel::~TreeModel()
/**
* Returns the index of a TreeItem given its parent and position.
* It is first checked if the model index is valid. If it is not, it is assumed that a
* top-level item is being referred to; otherwise, the data pointer from the model
* index is obtained with its internalPointer() function and is used to reference a
* TreeItem object
* \param row Row of the tree object
* \param column Column of the tree object
* \param parent Index of the parent object
* It is first checked if the model index is valid. If it is not, it is assumed
* that a top-level item is being referred to; otherwise, the data pointer from
* the model index is obtained with its internalPointer() function and is used
* to reference a TreeItem object \param row Row of the tree object \param
* column Column of the tree object \param parent Index of the parent object
*/
QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) const
QModelIndex TreeModel::index(int row, int column,
const QModelIndex& parent) const
{
if (!hasIndex(row, column, parent))
{
......@@ -78,7 +78,7 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) con
/**
* Returns the model index of a TreeItem based on its index.
*/
QModelIndex TreeModel::parent(const QModelIndex &index) const
QModelIndex TreeModel::parent(const QModelIndex& index) const
{
if (!index.isValid())
{
......@@ -97,10 +97,11 @@ QModelIndex TreeModel::parent(const QModelIndex &index) const
}
/**
* Returns the number of child items for the TreeItem that corresponds to a given
* model index, or the number of top-level items if an invalid index is specified.
* Returns the number of child items for the TreeItem that corresponds to a
* given model index, or the number of top-level items if an invalid index is
* specified.
*/
int TreeModel::rowCount(const QModelIndex &parent) const
int TreeModel::rowCount(const QModelIndex& parent) const
{
TreeItem* parentItem;
if (parent.column() > 0)
......@@ -123,7 +124,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
/**
* Determines how many columns are present for a given model index.
*/
int TreeModel::columnCount(const QModelIndex &parent) const
int TreeModel::columnCount(const QModelIndex& parent) const
{
if (parent.isValid())
{
......@@ -133,14 +134,12 @@ int TreeModel::columnCount(const QModelIndex &parent) const
return _rootItem->columnCount();
}
void TreeModel::updateData()
{
}
void TreeModel::updateData() {}
/**
* Since each item manages its own columns, the column number is used to retrieve
* the data with the TreeItem::data() function
* Since each item manages its own columns, the column number is used to
* retrieve the data with the TreeItem::data() function
*/
QVariant TreeModel::data(const QModelIndex &index, int role) const
QVariant TreeModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
{
......@@ -157,7 +156,8 @@ QVariant TreeModel::data(const QModelIndex &index, int role) const
return QVariant();
}
bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int role /* = Qt::EditRole */ )
bool TreeModel::setData(const QModelIndex& index, const QVariant& value,
int role /* = Qt::EditRole */)
{
if (!index.isValid())
{
......@@ -172,7 +172,7 @@ bool TreeModel::setData( const QModelIndex &index, const QVariant &value, int ro
}
return false;
}
Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
Qt::ItemFlags TreeModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
{
......@@ -185,7 +185,7 @@ Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const
/**
* Returns the Item characterized by the given index.
*/
TreeItem* TreeModel::getItem(const QModelIndex &index) const
TreeItem* TreeModel::getItem(const QModelIndex& index) const
{
if (index.isValid())
{
......@@ -198,7 +198,8 @@ TreeItem* TreeModel::getItem(const QModelIndex &index) const
return _rootItem;
}
QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant TreeModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
......@@ -211,7 +212,7 @@ QVariant TreeModel::headerData(int section, Qt::Orientation orientation, int rol
/**
* Removes item from the model.
*/
bool TreeModel::removeRows(int position, int count, const QModelIndex & parent)
bool TreeModel::removeRows(int position, int count, const QModelIndex& parent)
{
TreeItem* parentItem = getItem(parent);
bool success = true;
......@@ -226,7 +227,7 @@ bool TreeModel::removeRows(int position, int count, const QModelIndex & parent)
/**
* Test method for creating a tree model
*/
void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent)
void TreeModel::setupModelData(const QStringList& lines, TreeItem* parent)
{
QList<TreeItem*> parents;
QList<int> indentations;
......@@ -252,7 +253,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent)
if (!lineData.isEmpty())
{
// Read the column data from the rest of the line.
QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
QStringList columnStrings =
lineData.split("\t", QString::SkipEmptyParts);
QList<QVariant> columnData;
for (int column = 0; column < columnStrings.count(); ++column)
{
......@@ -266,8 +268,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent)
if (parents.last()->childCount() > 0)
{
parents << parents.last()->child(parents.last()->childCount(
) - 1);
parents << parents.last()->child(
parents.last()->childCount() - 1);
indentations << position;
}
}
......@@ -281,7 +283,8 @@ void TreeModel::setupModelData(const QStringList &lines, TreeItem* parent)
}
// Append a new item to the current parent's list of children.
parents.last()->appendChild(new TreeItem(columnData, parents.last()));
parents.last()->appendChild(
new TreeItem(columnData, parents.last()));
}
number++;
......
......@@ -42,7 +42,7 @@ TreeModelIterator& TreeModelIterator::operator++()
return *this;
}
TreeItem* TreeModelIterator::next( const TreeItem* current )
TreeItem* TreeModelIterator::next(const TreeItem* current)
{
if (!current)
{
......@@ -62,7 +62,7 @@ TreeItem* TreeModelIterator::next( const TreeItem* current )
// walk the sibling
TreeItem* parent = current->parentItem();
next = parent ? parent->child(_currentIndex + 1)
: _model->rootItem()->child(_currentIndex + 1);
: _model->rootItem()->child(_currentIndex + 1);
while (!next && parent)
{
// if we had no sibling walk up the parent
......@@ -70,7 +70,7 @@ TreeItem* TreeModelIterator::next( const TreeItem* current )
parent = parent->parentItem();
_currentIndex = _parentIndex.pop();
next = parent ? parent->child(_currentIndex + 1)
: _model->rootItem()->child(_currentIndex + 1);
: _model->rootItem()->child(_currentIndex + 1);
}
if (next)
{
......
......@@ -21,58 +21,60 @@
**
****************************************************************************/
#include <QtGui/QtGui>
#include "modeltest.h"
#include <QtGui/QtGui>
Q_DECLARE_METATYPE(QModelIndex)
/*!
Connect to all of the models signals. Whenever anything happens recheck everything.
Connect to all of the models signals. Whenever anything happens recheck
everything.
*/
ModelTest::ModelTest(QAbstractItemModel* _model,
QObject* parent) : QObject(parent), model(_model), fetchingMore(false)
ModelTest::ModelTest(QAbstractItemModel* _model, QObject* parent)
: QObject(parent), model(_model), fetchingMore(false)
{
Q_ASSERT(model);
connect(model, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(columnsInserted(const QModelIndex &, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(columnsRemoved(const QModelIndex &, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(layoutAboutToBeChanged ()), this, SLOT(runAllTests()));
connect(model, SIGNAL(layoutChanged ()), this, SLOT(runAllTests()));
connect(model, SIGNAL(modelReset ()), this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
connect(model,
SIGNAL(columnsAboutToBeInserted(const QModelIndex&, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
connect(model,
SIGNAL(columnsAboutToBeRemoved(const QModelIndex&, int, int)), this,
SLOT(runAllTests()));
connect(model, SIGNAL(columnsInserted(const QModelIndex&, int, int)), this,
SLOT(runAllTests()));
connect(model, SIGNAL(columnsRemoved(const QModelIndex&, int, int)), this,
SLOT(runAllTests()));
connect(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)), this,
SLOT(runAllTests()));
connect(model, SIGNAL(layoutAboutToBeChanged()), this, SLOT(runAllTests()));
connect(model, SIGNAL(layoutChanged()), this, SLOT(runAllTests()));
connect(model, SIGNAL(modelReset()), this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)),
this, SLOT(runAllTests()));
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this,
SLOT(runAllTests()));
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this,
SLOT(runAllTests()));
// Special checks for inserting/removing
connect(model, SIGNAL(layoutAboutToBeChanged()),
this, SLOT(layoutAboutToBeChanged()));
connect(model, SIGNAL(layoutChanged()),
this, SLOT(layoutChanged()));
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)),
this, SLOT(rowsAboutToBeInserted(const QModelIndex &, int, int)));
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int)));
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(rowsInserted(const QModelIndex &, int, int)));
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
this, SLOT(rowsRemoved(const QModelIndex &, int, int)));
connect(model, SIGNAL(layoutAboutToBeChanged()), this,
SLOT(layoutAboutToBeChanged()));
connect(model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged()));
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)),
this, SLOT(rowsAboutToBeInserted(const QModelIndex&, int, int)));
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)),
this, SLOT(rowsAboutToBeRemoved(const QModelIndex&, int, int)));
connect(model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this,
SLOT(rowsInserted(const QModelIndex&, int, int)));
connect(model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this,
SLOT(rowsRemoved(const QModelIndex&, int, int)));
runAllTests();
}
......@@ -91,8 +93,9 @@ void ModelTest::runAllTests()
}
/*!
nonDestructiveBasicTest tries to call a number of the basic functions (not all)
to make sure the model doesn't outright segfault, testing the functions that makes sense.
nonDestructiveBasicTest tries to call a number of the basic functions (not
all) to make sure the model doesn't outright segfault, testing the functions
that makes sense.
*/
void ModelTest::nonDestructiveBasicTest()
{
......@@ -128,7 +131,8 @@ void ModelTest::nonDestructiveBasicTest()