diff options
-rw-r--r-- | qt-ui/divelistview.cpp | 12 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 3 | ||||
-rw-r--r-- | qt-ui/models.cpp | 7 |
3 files changed, 16 insertions, 6 deletions
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(); diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index c578baa17..36e3e59fc 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -38,7 +38,8 @@ public slots: void removeFromTrip(); void deleteDive(); void testSlot(); - + void fixMessyQtModelBehaviour(); + Q_SIGNALS: void currentDiveChanged(int divenr); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 86773fd52..8575d6539 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -785,11 +785,8 @@ QVariant TripItem::data(int column, int role) const if (role == Qt::DisplayRole) { switch (column) { - case LOCATION: - ret = QString(trip->location); - break; - case DATE: - ret = QString(get_trip_date_string(trip->when, trip->nrdives)); + case NR: + ret = QString(trip->location) + QString(get_trip_date_string(trip->when, trip->nrdives)); break; } } |