corrections on hinspector
This commit is contained in:
parent
a96df9116e
commit
7ceb8530f2
|
@ -1,3 +1,4 @@
|
|||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QTableView>
|
||||
|
@ -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());
|
||||
|
|
|
@ -8,17 +8,19 @@ using namespace Hurricane;
|
|||
class QSortFilterProxyModel;
|
||||
class QTableView;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
|
||||
class HInspectorWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef map<Record*, QSortFilterProxyModel*> FilterProxyModels;
|
||||
typedef list<QSortFilterProxyModel*> FilterProxyModelsHistory;
|
||||
typedef vector<QSortFilterProxyModel*> 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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue