1
0
Fork 0

GUI: Rewrite SearchListView to remove UI file

This commit is contained in:
Nukem 2016-02-14 18:32:23 -05:00
parent 0d17101ba8
commit a8c6aabfb4
7 changed files with 94 additions and 141 deletions

View File

@ -1,17 +1,22 @@
#include "ReferenceView.h"
#include <QHBoxLayout>
#include <QMessageBox>
#include <QLabel>
#include "ReferenceView.h"
#include "Configuration.h"
#include "Bridge.h"
#include <QLabel>
ReferenceView::ReferenceView()
ReferenceView::ReferenceView() : SearchListView()
{
// Setup SearchListView settings
mSearchStartCol = 1;
mFollowDumpDefault = false;
// Widget container for progress
QWidget* progressWidget = new QWidget();
// Create the layout for the progress bars
QHBoxLayout* layoutProgress = new QHBoxLayout();
progressWidget->setLayout(layoutProgress);
layoutProgress->setContentsMargins(2, 0, 0, 0);
layoutProgress->setSpacing(4);
@ -38,7 +43,7 @@ ReferenceView::ReferenceView()
layoutProgress->addWidget(mCountTotalLabel);
// Add the progress bar and label to the main layout
mMainLayout->addLayout(layoutProgress);
layout()->addWidget(progressWidget);
// Setup signals
connect(Bridge::getBridge(), SIGNAL(referenceAddColumnAt(int, QString)), this, SLOT(addColumnAt(int, QString)));

View File

@ -1,55 +1,90 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSplitter>
#include <QLabel>
#include "SearchListView.h"
#include "ui_SearchListView.h"
#include "FlickerThread.h"
SearchListView::SearchListView(QWidget* parent) :
QWidget(parent),
ui(new Ui::SearchListView)
SearchListView::SearchListView(bool EnableRegex, QWidget* parent) : QWidget(parent)
{
ui->setupUi(this);
setContextMenuPolicy(Qt::CustomContextMenu);
// Create the reference list
mList = new SearchListViewTable();
// Create the main button/bar view with QSplitter
//
// |- Splitter ----------------------------|
// | LISTVIEW |
// | SEARCH: | SEARCH BOX | REGEX CHECKBOX |
// |---------------------------------------|
QSplitter* barSplitter = new QSplitter(Qt::Vertical);
{
// Create list layout (contains both ListViews)
{
// Create reference & search list
mList = new SearchListViewTable();
mSearchList = new SearchListViewTable();
mSearchList->hide();
// Create the search list
mSearchList = new SearchListViewTable();
mSearchList->hide();
// Vertical layout
QVBoxLayout* listLayout = new QVBoxLayout();
listLayout->setContentsMargins(0, 0, 0, 0);
listLayout->setSpacing(0);
listLayout->addWidget(mList);
listLayout->addWidget(mSearchList);
// Add list placeholder
QWidget* listPlaceholder = new QWidget();
listPlaceholder->setLayout(listLayout);
barSplitter->addWidget(listPlaceholder);
}
// Filtering elements
{
// Input box
mSearchBox = new QLineEdit();
mSearchBox->setPlaceholderText("Type here to filter results...");
// Regex parsing checkbox
mRegexCheckbox = new QCheckBox("Regex");
if(!EnableRegex)
mRegexCheckbox->hide();
// Horizontal layout
QHBoxLayout* horzLayout = new QHBoxLayout();
horzLayout->setContentsMargins(4, 0, (EnableRegex) ? 0 : 4, 0);
horzLayout->setSpacing(2);
horzLayout->addWidget(new QLabel("Search: "));
horzLayout->addWidget(mSearchBox);
horzLayout->addWidget(mRegexCheckbox);
// Add searchbar placeholder
QWidget* horzPlaceholder = new QWidget();
horzPlaceholder->setLayout(horzLayout);
barSplitter->addWidget(horzPlaceholder);
}
// Minimum size for the search box
barSplitter->setStretchFactor(0, 1000);
barSplitter->setStretchFactor(0, 1);
// Disable main splitter
for(int i = 0; i < barSplitter->count(); i++)
barSplitter->handle(i)->setEnabled(false);
}
// Set the main layout which holds the splitter
QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(barSplitter);
setLayout(mainLayout);
// Set global variables
mSearchBox = ui->searchBox;
mCurList = mList;
mSearchStartCol = 0;
// Create list layout
mListLayout = new QVBoxLayout();
mListLayout->setContentsMargins(0, 0, 0, 0);
mListLayout->setSpacing(0);
mListLayout->addWidget(mList);
mListLayout->addWidget(mSearchList);
// Create list placeholder
mListPlaceHolder = new QWidget();
mListPlaceHolder->setLayout(mListLayout);
// Insert the placeholder
ui->mainSplitter->insertWidget(0, mListPlaceHolder);
// Set the main layout
mMainLayout = new QVBoxLayout();
mMainLayout->setContentsMargins(0, 0, 0, 0);
mMainLayout->addWidget(ui->mainSplitter);
setLayout(mMainLayout);
// Minimal size for the search box
ui->mainSplitter->setStretchFactor(0, 1000);
ui->mainSplitter->setStretchFactor(0, 1);
// Disable main splitter
for(int i = 0; i < ui->mainSplitter->count(); i++)
ui->mainSplitter->handle(i)->setEnabled(false);
// Install event filter
// Install input event filter
mSearchBox->installEventFilter(this);
// Setup search menu action
@ -70,7 +105,6 @@ SearchListView::SearchListView(QWidget* parent) :
SearchListView::~SearchListView()
{
delete ui;
}
bool SearchListView::findTextInList(SearchListViewTable* list, QString text, int row, int startcol, bool startswith)
@ -88,7 +122,7 @@ bool SearchListView::findTextInList(SearchListViewTable* list, QString text, int
{
for(int i = startcol; i < count; i++)
{
if(ui->checkBoxRegex->checkState() == Qt::Checked)
if(mRegexCheckbox->checkState() == Qt::Checked)
{
if(list->getCellContent(row, i).contains(QRegExp(text)))
return true;
@ -153,7 +187,7 @@ void SearchListView::searchTextChanged(const QString & arg1)
emit emptySearchResult();
// Do not highlight with regex
if(ui->checkBoxRegex->checkState() != Qt::Checked)
if(mRegexCheckbox->checkState() != Qt::Checked)
mSearchList->highlightText = arg1;
else
mSearchList->highlightText = "";
@ -182,7 +216,7 @@ void SearchListView::doubleClickedSlot()
void SearchListView::on_checkBoxRegex_toggled(bool checked)
{
Q_UNUSED(checked);
searchTextChanged(ui->searchBox->text());
searchTextChanged(mSearchBox->text());
}
bool SearchListView::eventFilter(QObject* obj, QEvent* event)
@ -226,7 +260,7 @@ bool SearchListView::eventFilter(QObject* obj, QEvent* event)
void SearchListView::searchSlot()
{
FlickerThread* thread = new FlickerThread(ui->searchBox, this);
connect(thread, SIGNAL(setStyleSheet(QString)), ui->searchBox, SLOT(setStyleSheet(QString)));
FlickerThread* thread = new FlickerThread(mSearchBox, this);
connect(thread, SIGNAL(setStyleSheet(QString)), mSearchBox, SLOT(setStyleSheet(QString)));
thread->start();
}

View File

@ -2,9 +2,8 @@
#define SEARCHLISTVIEW_H
#include <QWidget>
#include <QMenu>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QCheckBox>
#include "SearchListViewTable.h"
namespace Ui
@ -17,10 +16,9 @@ class SearchListView : public QWidget
Q_OBJECT
public:
explicit SearchListView(QWidget* parent = 0);
explicit SearchListView(bool EnableRegex = true, QWidget* parent = 0);
~SearchListView();
QVBoxLayout* mMainLayout;
SearchListViewTable* mList;
SearchListViewTable* mSearchList;
SearchListViewTable* mCurList;
@ -45,8 +43,7 @@ protected:
bool eventFilter(QObject* obj, QEvent* event);
private:
Ui::SearchListView* ui;
QVBoxLayout* mListLayout;
QCheckBox* mRegexCheckbox;
QWidget* mListPlaceHolder;
QAction* mSearchAction;
};

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SearchListView</class>
<widget class="QWidget" name="SearchListView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>45</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<widget class="QSplitter" name="mainSplitter">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>174</width>
<height>22</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="opaqueResize">
<bool>true</bool>
</property>
<property name="handleWidth">
<number>2</number>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="searchLabel">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchBox">
<property name="placeholderText">
<string>Type here to filter results...</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxRegex">
<property name="text">
<string>Re&amp;gEx</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -3,6 +3,7 @@
#include <QWidget>
#include <QTabWidget>
#include <QVBoxLayout>
#include "CPUSideBar.h"
#include "CPUDisassembly.h"
#include "CPUMultiDump.h"

View File

@ -2,6 +2,7 @@
#define SYMBOLVIEW_H
#include <QWidget>
#include <QVBoxLayout>
#include "Bridge.h"
namespace Ui

View File

@ -234,7 +234,6 @@ FORMS += \
Src/Gui/WordEditDialog.ui \
Src/Gui/LineEditDialog.ui \
Src/Gui/SymbolView.ui \
Src/BasicView/SearchListView.ui \
Src/Gui/SettingsDialog.ui \
Src/Gui/ExceptionRangeDialog.ui \
Src/Gui/CommandHelpView.ui \