-void BufferView::setModel(QAbstractItemModel *model) {
- delete selectionModel();
-
- QTreeView::setModel(model);
- init();
- // remove old Actions
- QList<QAction *> oldactions = header()->actions();
- foreach(QAction *action, oldactions) {
- header()->removeAction(action);
- action->deleteLater();
- }
-
- if(!model)
- return;
-
- QString sectionName;
- QAction *showSection;
- for(int i = 1; i < model->columnCount(); i++) {
- sectionName = (model->headerData(i, Qt::Horizontal, Qt::DisplayRole)).toString();
- showSection = new QAction(sectionName, header());
- showSection->setCheckable(true);
- showSection->setChecked(!isColumnHidden(i));
- showSection->setProperty("column", i);
- connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
- header()->addAction(showSection);
- }
-
- connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged()));
-}
-
-void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config) {
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
- if(filter) {
- filter->setConfig(config);
+
+void BufferView::setModel(QAbstractItemModel *model)
+{
+ delete selectionModel();
+
+ TreeViewTouch::setModel(model);
+ init();
+ // remove old Actions
+ QList<QAction *> oldactions = header()->actions();
+ foreach(QAction *action, oldactions) {
+ header()->removeAction(action);
+ action->deleteLater();
+ }
+
+ if (!model)
+ return;
+
+ QString sectionName;
+ QAction *showSection;
+ for (int i = 1; i < model->columnCount(); i++) {
+ sectionName = (model->headerData(i, Qt::Horizontal, Qt::DisplayRole)).toString();
+ showSection = new QAction(sectionName, header());
+ showSection->setCheckable(true);
+ showSection->setChecked(!isColumnHidden(i));
+ showSection->setProperty("column", i);
+ connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
+ header()->addAction(showSection);
+ }
+
+ connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged()));
+}
+
+
+void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config)
+{
+ BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+ if (filter) {
+ filter->setConfig(config);
+ setConfig(config);
+ return;
+ }
+
+ if (model()) {
+ disconnect(this, 0, model(), 0);
+ disconnect(model(), 0, this, 0);
+ }
+
+ if (!model_) {
+ setModel(model_);
+ }
+ else {
+ BufferViewFilter *filter = new BufferViewFilter(model_, config);
+ setModel(filter);
+ connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
+ }