AStyle
This commit is contained in:
parent
ce2d9f1b67
commit
dcdd154a64
|
|
@ -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<StdIconTable*>(stdList())->setIconColumn(c);
|
||||
qobject_cast<StdIconTable*>(stdSearchList())->setIconColumn(c);
|
||||
}
|
||||
|
||||
void StdIconSearchListView::setRowIcon(int r, const QIcon & icon)
|
||||
{
|
||||
clearFilter();
|
||||
qobject_cast<StdIconTable*>(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<StdIconTable*>(stdList())->setIconColumn(c);
|
||||
qobject_cast<StdIconTable*>(stdSearchList())->setIconColumn(c);
|
||||
}
|
||||
|
||||
void StdIconSearchListView::setRowIcon(int r, const QIcon & icon)
|
||||
{
|
||||
clearFilter();
|
||||
qobject_cast<StdIconTable*>(stdList())->setRowIcon(r, icon);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<size_t> 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<size_t> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<QIcon> 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<QIcon> mIcon; //listof(row) where row = (listof(col) where col = CellData)
|
||||
int mIconColumn;
|
||||
};
|
||||
|
||||
#endif // STDICONTABLE_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue