1
0
Fork 0

Add 'Lock' checkbox right after 'mSearchBox' (and before 'Regex' checkbox) in 'SearchListView' class. At interface point of view, it's just a simple checkbox, which locks search textbox if checked. So, the main apply of this option is lay down at implementation POV. At that time it's used only in 'SymbolView' UI, for purpose - now you can search for, for exmaple, 'Nt' functions in one module, check 'Lock' checkbox, and then go through another modules without tedious retyping of the same search query again and again. Simple, but useful. (#1003)

This commit is contained in:
Elijah 2016-08-25 10:49:23 +03:00 committed by Duncan Ogilvie
parent ff2baa5a03
commit d8328965fd
3 changed files with 34 additions and 9 deletions

View File

@ -5,16 +5,16 @@
#include "SearchListView.h"
#include "FlickerThread.h"
SearchListView::SearchListView(bool EnableRegex, QWidget* parent) : QWidget(parent)
SearchListView::SearchListView(bool EnableRegex, QWidget* parent, bool EnableLock) : QWidget(parent)
{
setContextMenuPolicy(Qt::CustomContextMenu);
// Create the main button/bar view with QSplitter
//
// |- Splitter ----------------------------|
// | LISTVIEW |
// | SEARCH: | SEARCH BOX | REGEX CHECKBOX |
// |---------------------------------------|
// |- Splitter --------------------------------------------|
// | LISTVIEW |
// | SEARCH: | SEARCH BOX | LOCK CHECKBOX | REGEX CHECKBOX |
// |-------------------------------------------------------|
QSplitter* barSplitter = new QSplitter(Qt::Vertical);
{
// Create list layout (contains both ListViews)
@ -47,15 +47,22 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent) : QWidget(pare
// Regex parsing checkbox
mRegexCheckbox = new QCheckBox(tr("Regex"));
// Lock checkbox
mLockCheckbox = new QCheckBox(tr("Lock"));
if(!EnableRegex)
mRegexCheckbox->hide();
if(!EnableLock)
mLockCheckbox->hide();
// Horizontal layout
QHBoxLayout* horzLayout = new QHBoxLayout();
horzLayout->setContentsMargins(4, 0, (EnableRegex) ? 0 : 4, 0);
horzLayout->setContentsMargins(4, 0, (EnableRegex || EnableLock) ? 0 : 4, 0);
horzLayout->setSpacing(2);
horzLayout->addWidget(new QLabel(tr("Search: ")));
horzLayout->addWidget(mSearchBox);
horzLayout->addWidget(mLockCheckbox);
horzLayout->addWidget(mRegexCheckbox);
// Add searchbar placeholder
@ -98,6 +105,7 @@ SearchListView::SearchListView(bool EnableRegex, QWidget* parent) : QWidget(pare
connect(mSearchList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
connect(mSearchBox, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString)));
connect(mRegexCheckbox, SIGNAL(toggled(bool)), this, SLOT(on_checkBoxRegex_toggled(bool)));
connect(mLockCheckbox, SIGNAL(toggled(bool)), this, SLOT(on_checkBoxLock_toggled(bool)));
// List input should always be forwarded to the filter edit
mSearchList->setFocusProxy(mSearchBox);
@ -225,6 +233,16 @@ void SearchListView::on_checkBoxRegex_toggled(bool checked)
refreshSearchList();
}
void SearchListView::on_checkBoxLock_toggled(bool checked)
{
mSearchBox->setDisabled(checked);
}
bool SearchListView::isSearchBoxLocked()
{
return mLockCheckbox->isChecked();
}
bool SearchListView::eventFilter(QObject* obj, QEvent* event)
{
// Keyboard button press being sent to the QLineEdit

View File

@ -16,7 +16,7 @@ class SearchListView : public QWidget
Q_OBJECT
public:
explicit SearchListView(bool EnableRegex = true, QWidget* parent = 0);
explicit SearchListView(bool EnableRegex = true, QWidget* parent = 0, bool EnableLock = false);
~SearchListView();
SearchListViewTable* mList;
@ -28,12 +28,15 @@ public:
bool findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith);
void refreshSearchList();
bool isSearchBoxLocked();
private slots:
void searchTextChanged(const QString & arg1);
void listContextMenu(const QPoint & pos);
void doubleClickedSlot();
void searchSlot();
void on_checkBoxRegex_toggled(bool checked);
void on_checkBoxLock_toggled(bool checked);
signals:
void enterPressedSignal();
@ -45,6 +48,7 @@ protected:
private:
QCheckBox* mRegexCheckbox;
QCheckBox* mLockCheckbox;
QAction* mSearchAction;
};

View File

@ -20,7 +20,7 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
setLayout(mMainLayout);
// Create reference view
mSearchListView = new SearchListView();
mSearchListView = new SearchListView(true, 0, true);
mSearchListView->mSearchStartCol = 1;
// Create module list
@ -245,7 +245,10 @@ void SymbolView::moduleSelectionChanged(int index)
mSearchListView->mList->reloadData();
mSearchListView->mList->setSingleSelection(0);
mSearchListView->mList->setTableOffset(0);
mSearchListView->mSearchBox->setText("");
if(!mSearchListView->isSearchBoxLocked())
mSearchListView->mSearchBox->setText("");
else
mSearchListView->refreshSearchList();
setUpdatesEnabled(true);
}