diff --git a/hurricane/src/hinspector/HInspectorWidget.cpp b/hurricane/src/hinspector/HInspectorWidget.cpp index 29244de9..59140a38 100644 --- a/hurricane/src/hinspector/HInspectorWidget.cpp +++ b/hurricane/src/hinspector/HInspectorWidget.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -19,14 +20,15 @@ HInspectorWidget::HInspectorWidget(QWidget* parent): slotsView->setSelectionBehavior(QAbstractItemView::SelectRows); slotsView->setSortingEnabled(true); - QVBoxLayout* inspectorLayout = new QVBoxLayout(); - inspectorLayout->addWidget(slotsView); + QGridLayout* inspectorLayout = new QGridLayout(); + inspectorLayout->addWidget(slotsView, 0, 0, 1, 2); filterPatternLineEdit = new QLineEdit(this); - inspectorLayout->addWidget(filterPatternLineEdit); - - + QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this); + filterPatternLabel->setBuddy(filterPatternLineEdit); + inspectorLayout->addWidget(filterPatternLabel, 1, 0); + inspectorLayout->addWidget(filterPatternLineEdit, 1, 1); QGroupBox* inspectorGroupBox = new QGroupBox(tr("Hurricane inspector"), this); inspectorGroupBox->setLayout(inspectorLayout); @@ -35,6 +37,9 @@ HInspectorWidget::HInspectorWidget(QWidget* parent): mainLayout->addWidget(inspectorGroupBox); setLayout(mainLayout); + connect(filterPatternLineEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(textFilterChanged())); + setWindowTitle(tr("Inspector")); resize(1000, 500); } @@ -53,7 +58,9 @@ void HInspectorWidget::internalSetRecord(Record* record) { } else { RecordModel* recordModel = new RecordModel(record, this); sortModel = new QSortFilterProxyModel(this); + sortModel->setDynamicSortFilter(true); sortModel->setSourceModel(recordModel); + sortModel->setFilterKeyColumn(1); filterProxyModels[record] = sortModel; } slotsView->setModel(sortModel); @@ -91,3 +98,11 @@ void HInspectorWidget::keyPressEvent(QKeyEvent *event) { event->ignore(); } } + + +void HInspectorWidget::textFilterChanged() { + QRegExp regExp(filterPatternLineEdit->text()); + QSortFilterProxyModel* sortModel = + static_cast(slotsView->model()); + sortModel->setFilterRegExp(regExp); +} diff --git a/hurricane/src/hinspector/HInspectorWidget.h b/hurricane/src/hinspector/HInspectorWidget.h index 1da968df..8c05b06f 100644 --- a/hurricane/src/hinspector/HInspectorWidget.h +++ b/hurricane/src/hinspector/HInspectorWidget.h @@ -18,6 +18,9 @@ class HInspectorWidget : public QWidget { HInspectorWidget(QWidget* parent=0); void setRecord(Record* record); + private slots: + void textFilterChanged(); + protected: void keyPressEvent(QKeyEvent * event);