summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-12 14:14:25 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-12 14:14:25 -0300
commitab0213f28ecfb1b49ca0c5c7c1d6900ab1fb8d71 (patch)
tree047ddf336fb5e15f013a51623e7a833bc6d18911 /qt-ui
parentbd8470ebcfe07a347c3c47d2a72e0b8cdd316630 (diff)
downloadsubsurface-ab0213f28ecfb1b49ca0c5c7c1d6900ab1fb8d71.tar.gz
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 <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp12
-rw-r--r--qt-ui/divelistview.h3
-rw-r--r--qt-ui/models.cpp7
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;
}
}