Fixed #503 sorting on thread id, number
This commit is contained in:
parent
e2b4aa1927
commit
abc082ca3e
|
@ -952,10 +952,10 @@ int AbstractTableView::getLineToPrintcount()
|
|||
*
|
||||
* @param[in] width Width of the column in pixel
|
||||
* @param[in] isClickable Boolean that tells whether the header is clickable or not
|
||||
*
|
||||
* @param[in] sortFn The sort function to use for this column. Defaults to case insensitve text search
|
||||
* @return Nothing.
|
||||
*/
|
||||
void AbstractTableView::addColumnAt(int width, const QString & title, bool isClickable)
|
||||
void AbstractTableView::addColumnAt(int width, const QString & title, bool isClickable, SortBy::t sortFn)
|
||||
{
|
||||
HeaderButton_t wHeaderButton;
|
||||
Column_t wColumn;
|
||||
|
@ -969,6 +969,7 @@ void AbstractTableView::addColumnAt(int width, const QString & title, bool isCli
|
|||
wColumn.width = width;
|
||||
wColumn.hidden = false;
|
||||
wColumn.title = title;
|
||||
wColumn.sortFunction = sortFn;
|
||||
wCurrentCount = mColumnList.length();
|
||||
mColumnList.append(wColumn);
|
||||
mColumnOrder.append(wCurrentCount);
|
||||
|
@ -1006,12 +1007,12 @@ QString AbstractTableView::getColTitle(int index)
|
|||
/************************************************************************************
|
||||
Getter & Setter
|
||||
************************************************************************************/
|
||||
dsint AbstractTableView::getRowCount()
|
||||
dsint AbstractTableView::getRowCount() const
|
||||
{
|
||||
return mRowCount;
|
||||
}
|
||||
|
||||
int AbstractTableView::getColumnCount()
|
||||
int AbstractTableView::getColumnCount() const
|
||||
{
|
||||
return mColumnList.size();
|
||||
}
|
||||
|
@ -1042,7 +1043,12 @@ bool AbstractTableView::getColumnHidden(int col)
|
|||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
AbstractTableView::SortBy::t AbstractTableView::getColumnSortBy(int col) const
|
||||
{
|
||||
if(col < getColumnCount() && col >= 0)
|
||||
return mColumnList[col].sortFunction;
|
||||
return SortBy::AsText;
|
||||
}
|
||||
void AbstractTableView::setColumnHidden(int col, bool hidden)
|
||||
{
|
||||
if(col < getColumnCount() && col >= 0)
|
||||
|
@ -1166,7 +1172,6 @@ void AbstractTableView::updateViewport()
|
|||
this->viewport()->update();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This method is called when data have to be reloaded (e.g. When table offset changes).
|
||||
*
|
||||
|
@ -1178,3 +1183,18 @@ void AbstractTableView::prepareData()
|
|||
dsint wRemainingRowsCount = getRowCount() - mTableOffset;
|
||||
mNbrOfLineToPrint = (dsint)wRemainingRowsCount > (dsint)wViewableRowsCount ? (int)wViewableRowsCount : (int)wRemainingRowsCount;
|
||||
}
|
||||
|
||||
bool AbstractTableView::SortBy::AsText(const QString & a, const QString & b)
|
||||
{
|
||||
return QString::compare(a, b, Qt::CaseInsensitive) < 0;
|
||||
}
|
||||
|
||||
bool AbstractTableView::SortBy::AsInt(const QString & a, const QString & b)
|
||||
{
|
||||
return a.toLongLong() < b.toLongLong();
|
||||
}
|
||||
|
||||
bool AbstractTableView::SortBy::AsHex(const QString & a, const QString & b)
|
||||
{
|
||||
return a.toLongLong(0, 16) < b.toLongLong(0, 16);
|
||||
}
|
||||
|
|
|
@ -86,16 +86,24 @@ public:
|
|||
int getViewableRowsCount();
|
||||
virtual int getLineToPrintcount();
|
||||
|
||||
struct SortBy
|
||||
{
|
||||
typedef std::function<bool(const QString &, const QString &)> t;
|
||||
static bool AsText(const QString & a, const QString & b);
|
||||
static bool AsInt(const QString & a, const QString & b);
|
||||
static bool AsHex(const QString & a, const QString & b);
|
||||
};
|
||||
|
||||
// New Columns/New Size
|
||||
virtual void addColumnAt(int width, const QString & title, bool isClickable);
|
||||
virtual void addColumnAt(int width, const QString & title, bool isClickable, SortBy::t sortFn = SortBy::AsText);
|
||||
virtual void setRowCount(dsint count);
|
||||
virtual void deleteAllColumns();
|
||||
void setColTitle(int index, const QString & title);
|
||||
QString getColTitle(int index);
|
||||
|
||||
// Getter & Setter
|
||||
dsint getRowCount();
|
||||
int getColumnCount();
|
||||
dsint getRowCount() const;
|
||||
int getColumnCount() const;
|
||||
int getRowHeight();
|
||||
int getColumnWidth(int index);
|
||||
void setColumnWidth(int index, int width);
|
||||
|
@ -108,6 +116,7 @@ public:
|
|||
int getCharWidth();
|
||||
bool getColumnHidden(int col);
|
||||
void setColumnHidden(int col, bool hidden);
|
||||
SortBy::t getColumnSortBy(int idx) const;
|
||||
|
||||
// UI customization
|
||||
void loadColumnFromConfig(const QString & viewName);
|
||||
|
@ -167,6 +176,7 @@ private:
|
|||
bool hidden;
|
||||
HeaderButton_t header;
|
||||
QString title;
|
||||
SortBy::t sortFunction;
|
||||
} Column_t;
|
||||
|
||||
typedef struct _Header_t
|
||||
|
|
|
@ -232,9 +232,9 @@ bool StdTable::isSelected(int base, int offset)
|
|||
/************************************************************************************
|
||||
Data Management
|
||||
************************************************************************************/
|
||||
void StdTable::addColumnAt(int width, QString title, bool isClickable, QString copyTitle)
|
||||
void StdTable::addColumnAt(int width, QString title, bool isClickable, QString copyTitle, SortBy::t sortFn)
|
||||
{
|
||||
AbstractTableView::addColumnAt(width, title, isClickable);
|
||||
AbstractTableView::addColumnAt(width, title, isClickable, sortFn);
|
||||
|
||||
//append empty column to list of rows
|
||||
for(int i = 0; i < mData.size(); i++)
|
||||
|
@ -474,6 +474,6 @@ void StdTable::headerButtonPressedSlot(int col)
|
|||
void StdTable::reloadData()
|
||||
{
|
||||
if(mSort.first != -1) //re-sort if the user wants to sort
|
||||
qSort(mData.begin(), mData.end(), ColumnCompare(mSort.first, mSort.second));
|
||||
qSort(mData.begin(), mData.end(), ColumnCompare(mSort.first, mSort.second, getColumnSortBy(mSort.first)));
|
||||
AbstractTableView::reloadData();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
bool isSelected(int base, int offset);
|
||||
|
||||
// Data Management
|
||||
void addColumnAt(int width, QString title, bool isClickable, QString copyTitle = "");
|
||||
void addColumnAt(int width, QString title, bool isClickable, QString copyTitle = "", SortBy::t sortFn = SortBy::AsText);
|
||||
void setRowCount(int count);
|
||||
void deleteAllColumns();
|
||||
void setCellContent(int r, int c, QString s);
|
||||
|
@ -60,15 +60,16 @@ private:
|
|||
class ColumnCompare
|
||||
{
|
||||
public:
|
||||
ColumnCompare(int col, bool greater)
|
||||
ColumnCompare(int col, bool greater, SortBy::t fn)
|
||||
{
|
||||
mCol = col;
|
||||
mGreater = greater;
|
||||
mSortFn = fn;
|
||||
}
|
||||
|
||||
inline bool operator()(const QList<QString> & a, const QList<QString> & b) const
|
||||
{
|
||||
bool less = QString::compare(a.at(mCol), b.at(mCol), Qt::CaseInsensitive) < 0;
|
||||
bool less = mSortFn(a.at(mCol), b.at(mCol));
|
||||
if(mGreater)
|
||||
return !less;
|
||||
return less;
|
||||
|
@ -76,6 +77,7 @@ private:
|
|||
private:
|
||||
int mCol;
|
||||
int mGreater;
|
||||
SortBy::t mSortFn;
|
||||
};
|
||||
|
||||
enum GuiState_t {NoState, MultiRowsSelectionState};
|
||||
|
|
|
@ -189,16 +189,16 @@ void ThreadView::setupContextMenu()
|
|||
ThreadView::ThreadView(StdTable* parent) : StdTable(parent)
|
||||
{
|
||||
int charwidth = getCharWidth();
|
||||
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("Number"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("ID"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("Entry"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("TEB"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("Number"), false, "", SortBy::AsInt);
|
||||
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("ID"), false, "", SortBy::AsHex);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("Entry"), false, "", SortBy::AsHex);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("TEB"), false, "", SortBy::AsHex);
|
||||
#ifdef _WIN64
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("RIP"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("RIP"), false, "", SortBy::AsHex);
|
||||
#else
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("EIP"), false);
|
||||
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("EIP"), false, "", SortBy::AsHex);
|
||||
#endif //_WIN64
|
||||
addColumnAt(8 + charwidth * 14, tr("Suspend Count"), false);
|
||||
addColumnAt(8 + charwidth * 14, tr("Suspend Count"), false, "", SortBy::AsInt);
|
||||
addColumnAt(8 + charwidth * 12, tr("Priority"), false);
|
||||
addColumnAt(8 + charwidth * 12, tr("Wait Reason"), false);
|
||||
addColumnAt(8 + charwidth * 11, tr("Last Error"), false);
|
||||
|
|
Loading…
Reference in New Issue