diff --git a/hurricane/src/hinspector/HInspectorWidget.cpp b/hurricane/src/hinspector/HInspectorWidget.cpp index 59140a38..574915b5 100644 --- a/hurricane/src/hinspector/HInspectorWidget.cpp +++ b/hurricane/src/hinspector/HInspectorWidget.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -13,22 +14,26 @@ HInspectorWidget::HInspectorWidget(QWidget* parent): QWidget(parent), filterProxyModels(), filterProxyModelsHistory(), + recordsHistoryComboBox(NULL), slotsView(NULL) { + //recordsHistoryComboBox = new QComboBox(this); + slotsView = new QTableView(this); slotsView->setAlternatingRowColors(true); slotsView->setSelectionBehavior(QAbstractItemView::SelectRows); slotsView->setSortingEnabled(true); QGridLayout* inspectorLayout = new QGridLayout(); - inspectorLayout->addWidget(slotsView, 0, 0, 1, 2); + //inspectorLayout->addWidget(recordsHistoryComboBox, 0, 0, 1, 2); + inspectorLayout->addWidget(slotsView, 1, 0, 1, 2); filterPatternLineEdit = new QLineEdit(this); QLabel* filterPatternLabel = new QLabel(tr("&Filter pattern:"), this); filterPatternLabel->setBuddy(filterPatternLineEdit); - inspectorLayout->addWidget(filterPatternLabel, 1, 0); - inspectorLayout->addWidget(filterPatternLineEdit, 1, 1); + inspectorLayout->addWidget(filterPatternLabel, 2, 0); + inspectorLayout->addWidget(filterPatternLineEdit, 2, 1); QGroupBox* inspectorGroupBox = new QGroupBox(tr("Hurricane inspector"), this); inspectorGroupBox->setLayout(inspectorLayout); @@ -37,6 +42,9 @@ HInspectorWidget::HInspectorWidget(QWidget* parent): mainLayout->addWidget(inspectorGroupBox); setLayout(mainLayout); + //connect(recordsHistoryComboBox, SIGNAL(currentIndexChanged(int)), + // this, SLOT(recordChanged(int))); + connect(filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textFilterChanged())); @@ -46,6 +54,7 @@ HInspectorWidget::HInspectorWidget(QWidget* parent): void HInspectorWidget::setRecord(Record* record) { filterProxyModelsHistory.clear(); + //recordsHistoryComboBox->clear(); internalSetRecord(record); } @@ -66,6 +75,8 @@ void HInspectorWidget::internalSetRecord(Record* record) { slotsView->setModel(sortModel); slotsView->resizeColumnsToContents(); filterProxyModelsHistory.push_back(sortModel); + //recordsHistoryComboBox->addItem(QString(record->getName().c_str())); + //recordsHistoryComboBox->setCurrentIndex(recordsHistoryComboBox->count()-1); } void HInspectorWidget::keyPressEvent(QKeyEvent *event) { @@ -86,19 +97,34 @@ void HInspectorWidget::keyPressEvent(QKeyEvent *event) { } } } - //} else if (event->matches(QKeySequence::MoveToPreviousChar)) { - // if (!recordModelsHistory.empty()) { - // recordModelsHistory.pop_back(); - // if (!recordModelsHistory.empty()) { - // QSortFilterProxyModel* proxyModel = recordModelsHistory.back(); - // slotsView->setModel(proxyModel); - // } - // } + } else if (event->matches(QKeySequence::MoveToPreviousChar)) { + if (!filterProxyModelsHistory.empty()) { + filterProxyModelsHistory.pop_back(); + if (!filterProxyModelsHistory.empty()) { + QSortFilterProxyModel* proxyModel = filterProxyModelsHistory.back(); + slotsView->setModel(proxyModel); + } + //unsigned count = recordsHistoryComboBox->count(); + //if (count > 0) { + // recordsHistoryComboBox->removeItem(count-1); + //} + } } else { event->ignore(); } } +void HInspectorWidget::recordChanged(int index) { + if (index >= 0 && index < filterProxyModelsHistory.size()) { + QSortFilterProxyModel* proxyModel = filterProxyModelsHistory[index]; + slotsView->setModel(proxyModel); + //if (recordsHistoryComboBox->count() > index) { + // for (int i = recordsHistoryComboBox->count() - 1; i <= index; i--) { + // recordsHistoryComboBox->removeItem(i); + // } + //} + } +} void HInspectorWidget::textFilterChanged() { QRegExp regExp(filterPatternLineEdit->text()); diff --git a/hurricane/src/hinspector/HInspectorWidget.h b/hurricane/src/hinspector/HInspectorWidget.h index 8c05b06f..d0189602 100644 --- a/hurricane/src/hinspector/HInspectorWidget.h +++ b/hurricane/src/hinspector/HInspectorWidget.h @@ -8,17 +8,19 @@ using namespace Hurricane; class QSortFilterProxyModel; class QTableView; class QLineEdit; +class QComboBox; class HInspectorWidget : public QWidget { Q_OBJECT public: typedef map FilterProxyModels; - typedef list FilterProxyModelsHistory; + typedef vector FilterProxyModelsHistory; HInspectorWidget(QWidget* parent=0); void setRecord(Record* record); private slots: + void recordChanged(int index); void textFilterChanged(); protected: @@ -28,6 +30,7 @@ class HInspectorWidget : public QWidget { void internalSetRecord(Record* record); FilterProxyModels filterProxyModels; FilterProxyModelsHistory filterProxyModelsHistory; + QComboBox* recordsHistoryComboBox; QTableView* slotsView; QLineEdit* filterPatternLineEdit; };