From ab0213f28ecfb1b49ca0c5c7c1d6900ab1fb8d71 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 12 Jun 2013 14:14:25 -0300 Subject: Implements the DiveList to behave like Linus Explained. Implements the divelist to behave like linus explained, essentially, it filters the layoutChanges of the model, greps for trips, and for each trip that it finds, it set the 'firstColumnSpanned' property, to make the column to have the size of the whole table. e Signed-off-by: Tomaz Canabrava --- qt-ui/divelistview.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'qt-ui/divelistview.cpp') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index fd189e926..744f3d911 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -28,6 +28,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec model->setSortRole(TreeItemDT::SORT_ROLE); model->setFilterKeyColumn(-1); // filter all columns setModel(model); + connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour())); + setSortingEnabled(false); setContextMenuPolicy(Qt::DefaultContextMenu); header()->setContextMenuPolicy(Qt::ActionsContextMenu); @@ -42,6 +44,16 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); } +void DiveListView::fixMessyQtModelBehaviour() +{ + QAbstractItemModel *m = model(); + for(int i = 0; i < model()->rowCount(); i++){ + if (m->rowCount( m->index(i, 0) ) != 0){ + setFirstColumnSpanned(i, QModelIndex(), true); + } + } +} + void DiveListView::unselectDives() { selectionModel()->clearSelection(); -- cgit v1.2.3-70-g09d2