Add sort for "AsInt" "AsHex". Make selected line in search don't change when text changed in filter. #1340

Merged
merged 13 commits into from Dec 11, 2016

Projects

None yet

2 participants

@lynnux
lynnux commented Dec 2, 2016 edited

Add sort for "AsInt" "AsHex".

Make selected line in search result don't change when text changed in filter.
Use the value of first column as key to locate line, just OK for most SearchListView.


This change is Reviewable

@mrexodia
Member
mrexodia commented Dec 2, 2016

I need to extensively test this before I can merge it. There has been an exorbitant amount of issues with the symbol search so that's why.

@lynnux
lynnux commented Dec 3, 2016 edited

@mrexodia , a little improvement is here:
let QString mLastFirstColValue as a variable in SearchListView class .

void SearchListView::searchTextChanged(const QString & arg1)
{
    if(mSearchList->isHidden())
    {
        auto selList = mList->getSelection();
        if(!selList.empty() && mList->isValidIndex(selList[0], 0))
            mLastFirstColValue = mList->getCellContent(selList[0], 0);
    }
    else
    {
        auto selList = mSearchList->getSelection();
        if(!selList.empty() && mSearchList->isValidIndex(selList[0], 0))
            mLastFirstColValue = mSearchList->getCellContent(selList[0], 0);
    }

    if(arg1.length())
    {
        mList->hide();
        mSearchList->show();
        mCurList = mSearchList;
    }
    else
    {
        mSearchList->hide();
        mList->show();
        mCurList = mList;
    }
    mCurList->setSingleSelection(0);
    mSearchList->setRowCount(0);
    int rows = mList->getRowCount();
    int columns = mList->getColumnCount();
    for(int i = 0, j = 0; i < rows; i++)
    {
        if(findTextInList(mList, arg1, i, mSearchStartCol, false))
        {
            mSearchList->setRowCount(j + 1);
            for(int k = 0; k < columns; k++)
                mSearchList->setCellContent(j, k, mList->getCellContent(i, k));
            j++;
        }
    }

    if(!mLastFirstColValue.isEmpty())
    {
        rows = mCurList->getRowCount();
        mCurList->setTableOffset(0);
        for(int i = 0; i < rows; i++)
        {
            if(mCurList->getCellContent(i, 0) == mLastFirstColValue)
            {
                if(rows > mCurList->getViewableRowsCount())
                {
                    int cur = i - mCurList->getViewableRowsCount() / 2;
                    if(!mCurList->isValidIndex(cur, 0))
                        cur = i;
                    mCurList->setTableOffset(cur);
                }
                mCurList->setSingleSelection(i);
                break;
            }
        }
    }

    if(rows == 0)
        emit emptySearchResult();

    // Do not highlight with regex
    if(mRegexCheckbox->checkState() != Qt::Checked)
        mSearchList->highlightText = arg1;
    else
        mSearchList->highlightText = "";

    mSearchList->reloadData();
}

StdTable::getSelection has a bug that still return a list if mSearchList is empty, so this use isValidIndex to check. This new code has thie effect: when filter empty, del char can get back to previous selected line.

lynnux added some commits Dec 3, 2016
lynnux better 727c065
lynnux better 5ec5a17
@mrexodia
Member
mrexodia commented Dec 4, 2016

Currently I'm a bit busy and I will merge this somewhere next week when I'm home again.

@lynnux
lynnux commented Dec 6, 2016 edited

@mrexodia , I found a bug,
in symbols view default:
default
if sort by Type:
sort by type
This will not function well, after some debug, I think the reason is the last line:
mSearchList->reloadData();
mCurList->setSingleSelection(i) cause to select a line, but reloadData cause a new sort, which can change the view.
btw : This only affect sorting by Type, sort by Address or Sybmol are just OK
Solution: could we reloadData before setSingleSelection?

@mrexodia
Member
mrexodia commented Dec 7, 2016

The correct solution is to use std::stable_sort and remove the pointer hacks.

@mrexodia mrexodia merged commit aa6582b into x64dbg:development Dec 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment