summaryrefslogtreecommitdiff
path: root/src/modelutils.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2022-05-17 11:47:01 +0200
committerMikaël Capelle <capelle.mikael@gmail.com>2023-07-09 17:20:40 +0200
commitd13f6bb870cdda71257f665367be8ef9fca86255 (patch)
tree52e214718478f1e52856572f5aa1a2ac58537f9f /src/modelutils.cpp
parent86bb01ba9eac879d3685c439ac9da0028bc4bc80 (diff)
Apply clang-format.
Diffstat (limited to 'src/modelutils.cpp')
-rw-r--r--src/modelutils.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/modelutils.cpp b/src/modelutils.cpp
index 83054806..1cdf9657 100644
--- a/src/modelutils.cpp
+++ b/src/modelutils.cpp
@@ -2,10 +2,11 @@
#include <QAbstractProxyModel>
-namespace MOShared {
+namespace MOShared
+{
-QModelIndexList flatIndex(
- const QAbstractItemModel* model, int column, const QModelIndex& parent)
+QModelIndexList flatIndex(const QAbstractItemModel* model, int column,
+ const QModelIndex& parent)
{
QModelIndexList index;
for (std::size_t i = 0; i < model->rowCount(parent); ++i) {
@@ -15,7 +16,8 @@ QModelIndexList flatIndex(
return index;
}
-static QModelIndexList visibleIndexImpl(QTreeView* view, int column, const QModelIndex& parent)
+static QModelIndexList visibleIndexImpl(QTreeView* view, int column,
+ const QModelIndex& parent)
{
if (parent.isValid() && !view->isExpanded(parent)) {
return {};
@@ -59,7 +61,8 @@ QModelIndex indexModelToView(const QModelIndex& index, const QAbstractItemView*
return qindex;
}
-QModelIndexList indexModelToView(const QModelIndexList& index, const QAbstractItemView* view)
+QModelIndexList indexModelToView(const QModelIndexList& index,
+ const QAbstractItemView* view)
{
QModelIndexList result;
for (auto& idx : index) {
@@ -72,16 +75,15 @@ QModelIndex indexViewToModel(const QModelIndex& index, const QAbstractItemModel*
{
if (index.model() == model) {
return index;
- }
- else if (auto* proxy = qobject_cast<const QAbstractProxyModel*>(index.model())) {
+ } else if (auto* proxy = qobject_cast<const QAbstractProxyModel*>(index.model())) {
return indexViewToModel(proxy->mapToSource(index), model);
- }
- else {
+ } else {
return QModelIndex();
}
}
-QModelIndexList indexViewToModel(const QModelIndexList& index, const QAbstractItemModel* model)
+QModelIndexList indexViewToModel(const QModelIndexList& index,
+ const QAbstractItemModel* model)
{
QModelIndexList result;
for (auto& idx : index) {
@@ -90,4 +92,4 @@ QModelIndexList indexViewToModel(const QModelIndexList& index, const QAbstractIt
return result;
}
-}
+} // namespace MOShared