From dcdd154a64d763a90cd9b77a1ae6fd328391dba5 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 2 Oct 2020 19:42:25 +0200 Subject: [PATCH] AStyle --- .../Src/BasicView/StdIconSearchListView.cpp | 46 ++--- src/gui/Src/BasicView/StdIconSearchListView.h | 50 +++--- src/gui/Src/BasicView/StdIconTable.cpp | 160 +++++++++--------- src/gui/Src/BasicView/StdIconTable.h | 54 +++--- 4 files changed, 155 insertions(+), 155 deletions(-) diff --git a/src/gui/Src/BasicView/StdIconSearchListView.cpp b/src/gui/Src/BasicView/StdIconSearchListView.cpp index 472a9820..3da6989d 100644 --- a/src/gui/Src/BasicView/StdIconSearchListView.cpp +++ b/src/gui/Src/BasicView/StdIconSearchListView.cpp @@ -1,23 +1,23 @@ -#include "StdIconSearchListView.h" - -StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock) - : StdIconSearchListView(parent, enableRegex, enableLock, new StdTableSearchList(new StdIconTable(), new StdIconTable())) -{ -} - -StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList) - : StdSearchListView(parent, enableRegex, enableLock, tableSearchList) -{ -} - -void StdIconSearchListView::setIconColumn(int c) -{ - qobject_cast(stdList())->setIconColumn(c); - qobject_cast(stdSearchList())->setIconColumn(c); -} - -void StdIconSearchListView::setRowIcon(int r, const QIcon & icon) -{ - clearFilter(); - qobject_cast(stdList())->setRowIcon(r, icon); -} +#include "StdIconSearchListView.h" + +StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock) + : StdIconSearchListView(parent, enableRegex, enableLock, new StdTableSearchList(new StdIconTable(), new StdIconTable())) +{ +} + +StdIconSearchListView::StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList) + : StdSearchListView(parent, enableRegex, enableLock, tableSearchList) +{ +} + +void StdIconSearchListView::setIconColumn(int c) +{ + qobject_cast(stdList())->setIconColumn(c); + qobject_cast(stdSearchList())->setIconColumn(c); +} + +void StdIconSearchListView::setRowIcon(int r, const QIcon & icon) +{ + clearFilter(); + qobject_cast(stdList())->setRowIcon(r, icon); +} diff --git a/src/gui/Src/BasicView/StdIconSearchListView.h b/src/gui/Src/BasicView/StdIconSearchListView.h index a091a928..f2e47dbd 100644 --- a/src/gui/Src/BasicView/StdIconSearchListView.h +++ b/src/gui/Src/BasicView/StdIconSearchListView.h @@ -1,25 +1,25 @@ -#ifndef STDICONSEARCHLISTVIEW_H -#define STDICONSEARCHLISTVIEW_H - -#include "StdSearchListView.h" -#include "StdIconTable.h" - -class StdIconSearchListView : public StdSearchListView -{ - Q_OBJECT -public: - StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock); - StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList); - -public slots: - void setIconColumn(int c); - void setRowIcon(int r, const QIcon & icon); - -private: - StdTableSearchList* mSearchListData; - -protected: - friend class SymbolView; - friend class Bridge; -}; -#endif // STDICONSEARCHLISTVIEW_H +#ifndef STDICONSEARCHLISTVIEW_H +#define STDICONSEARCHLISTVIEW_H + +#include "StdSearchListView.h" +#include "StdIconTable.h" + +class StdIconSearchListView : public StdSearchListView +{ + Q_OBJECT +public: + StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock); + StdIconSearchListView(QWidget* parent, bool enableRegex, bool enableLock, StdTableSearchList* tableSearchList); + +public slots: + void setIconColumn(int c); + void setRowIcon(int r, const QIcon & icon); + +private: + StdTableSearchList* mSearchListData; + +protected: + friend class SymbolView; + friend class Bridge; +}; +#endif // STDICONSEARCHLISTVIEW_H diff --git a/src/gui/Src/BasicView/StdIconTable.cpp b/src/gui/Src/BasicView/StdIconTable.cpp index c8b820c0..d185eeaa 100644 --- a/src/gui/Src/BasicView/StdIconTable.cpp +++ b/src/gui/Src/BasicView/StdIconTable.cpp @@ -1,80 +1,80 @@ -#include "StdIconTable.h" - -/************************************************************************************ - Data Management -************************************************************************************/ - -void StdIconTable::setRowIcon(int r, const QIcon & icon) -{ - mIcon.at(r) = icon; -} - -QIcon StdIconTable::getRowIcon(int r) const -{ - return mIcon.at(r); -} - -void StdIconTable::setIconColumn(int c) -{ - mIconColumn = c; -} - -int StdIconTable::getIconColumn() const -{ - return mIconColumn; -} - -void StdIconTable::setRowCount(dsint count) -{ - int wRowToAddOrRemove = count - int(mIcon.size()); - for(int i = 0; i < qAbs(wRowToAddOrRemove); i++) - { - if(wRowToAddOrRemove > 0) - mIcon.push_back(QIcon()); - else - mIcon.pop_back(); - } - StdTable::setRowCount(count); -} - -void StdIconTable::sortRows(int column, bool ascending) -{ - auto sortFn = mColumnSortFunctions.at(column); - std::vector index; - index.resize(mData.size()); - size_t i; - for(i = 0; i < mData.size(); i++) - { - index[i] = i; - } - std::stable_sort(index.begin(), index.end(), [column, ascending, this, &sortFn](const size_t & a, const size_t & b) - { - auto less = sortFn(mData.at(a).at(column).text, mData.at(b).at(column).text); - return ascending ? less : !less; - }); - auto copy1 = mData; - auto copy2 = mIcon; - for(i = 0; i < mData.size(); i++) - { - mData[i] = std::move(copy1[index[i]]); - mIcon[i] = std::move(copy2[index[i]]); - } -} - -QString StdIconTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) -{ - if(col == mIconColumn) - { - mIcon.at(rowBase + rowOffset).paint(painter, x, y, h, h); - QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x + h, y, w, h); - - if(wStr.length()) - { - painter->setPen(getCellColor(rowBase + rowOffset, col)); - painter->drawText(QRect(x + 4 + h, y, w - 4 - h, h), Qt::AlignVCenter | Qt::AlignLeft, wStr); - } - return QString(); - } - else - return StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h); -} +#include "StdIconTable.h" + +/************************************************************************************ + Data Management +************************************************************************************/ + +void StdIconTable::setRowIcon(int r, const QIcon & icon) +{ + mIcon.at(r) = icon; +} + +QIcon StdIconTable::getRowIcon(int r) const +{ + return mIcon.at(r); +} + +void StdIconTable::setIconColumn(int c) +{ + mIconColumn = c; +} + +int StdIconTable::getIconColumn() const +{ + return mIconColumn; +} + +void StdIconTable::setRowCount(dsint count) +{ + int wRowToAddOrRemove = count - int(mIcon.size()); + for(int i = 0; i < qAbs(wRowToAddOrRemove); i++) + { + if(wRowToAddOrRemove > 0) + mIcon.push_back(QIcon()); + else + mIcon.pop_back(); + } + StdTable::setRowCount(count); +} + +void StdIconTable::sortRows(int column, bool ascending) +{ + auto sortFn = mColumnSortFunctions.at(column); + std::vector index; + index.resize(mData.size()); + size_t i; + for(i = 0; i < mData.size(); i++) + { + index[i] = i; + } + std::stable_sort(index.begin(), index.end(), [column, ascending, this, &sortFn](const size_t & a, const size_t & b) + { + auto less = sortFn(mData.at(a).at(column).text, mData.at(b).at(column).text); + return ascending ? less : !less; + }); + auto copy1 = mData; + auto copy2 = mIcon; + for(i = 0; i < mData.size(); i++) + { + mData[i] = std::move(copy1[index[i]]); + mIcon[i] = std::move(copy2[index[i]]); + } +} + +QString StdIconTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) +{ + if(col == mIconColumn) + { + mIcon.at(rowBase + rowOffset).paint(painter, x, y, h, h); + QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x + h, y, w, h); + + if(wStr.length()) + { + painter->setPen(getCellColor(rowBase + rowOffset, col)); + painter->drawText(QRect(x + 4 + h, y, w - 4 - h, h), Qt::AlignVCenter | Qt::AlignLeft, wStr); + } + return QString(); + } + else + return StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h); +} diff --git a/src/gui/Src/BasicView/StdIconTable.h b/src/gui/Src/BasicView/StdIconTable.h index baa7908a..6bee1f28 100644 --- a/src/gui/Src/BasicView/StdIconTable.h +++ b/src/gui/Src/BasicView/StdIconTable.h @@ -1,27 +1,27 @@ -#ifndef STDICONTABLE_H -#define STDICONTABLE_H - -#include "StdTable.h" - -class StdIconTable : public StdTable -{ - Q_OBJECT -public: - explicit StdIconTable(QWidget* parent = 0) : StdTable(parent), mIconColumn(0) {}; - - // Data Management - void setRowIcon(int r, const QIcon & icon); - QIcon getRowIcon(int r) const; - void setIconColumn(int c); - int getIconColumn() const; - void setRowCount(dsint count) override; - void sortRows(int column, bool ascending) override; - - QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override; - -protected: - std::vector mIcon; //listof(row) where row = (listof(col) where col = CellData) - int mIconColumn; -}; - -#endif // STDICONTABLE_H +#ifndef STDICONTABLE_H +#define STDICONTABLE_H + +#include "StdTable.h" + +class StdIconTable : public StdTable +{ + Q_OBJECT +public: + explicit StdIconTable(QWidget* parent = 0) : StdTable(parent), mIconColumn(0) {}; + + // Data Management + void setRowIcon(int r, const QIcon & icon); + QIcon getRowIcon(int r) const; + void setIconColumn(int c); + int getIconColumn() const; + void setRowCount(dsint count) override; + void sortRows(int column, bool ascending) override; + + QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) override; + +protected: + std::vector mIcon; //listof(row) where row = (listof(col) where col = CellData) + int mIconColumn; +}; + +#endif // STDICONTABLE_H