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 ++++++++++++ qt-ui/divelistview.h | 3 ++- 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; } } -- cgit v1.2.3-70-g09d2 From 9993d4996659b2d6c07f283895acb6409012ea9c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 12 Jun 2013 14:28:44 -0300 Subject: Do not plot on showEvent if dive is already plotted. We do a force-plot on showEvent because the user can have asked to open a dive file via command line, so the app needs to open already with a profile plotted. if the user opens the program, loads a map, hides the profile by hitting ctrl + 1, then shows the profile again by hitting ctrl + 2, we do not want to do all the math to show the profile again, because we already have it in memory. this also fixes dirk's strange behavior of funky profile. Signed-off-by: Tomaz Canabrava --- qt-ui/profilegraphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 164de13ff..be2f5f039 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -212,7 +212,7 @@ void ProfileGraphicsView::showEvent(QShowEvent* event) // but the dive was not ploted. // force a replot by modifying the dive // hold by the view, and issuing a plot. - if (dive) { + if (dive && !scene()->items().count()) { dive = 0; plot(get_dive(selected_dive)); } -- cgit v1.2.3-70-g09d2 From 7e9d6e28297432d4a15721a49a9dd0c0d067ce7e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 12 Jun 2013 15:54:55 -0300 Subject: Fixed the show / hide dialog shortcuts to take the splitter into consideration Fixed the show / hide dialog shortcuts to take the splitter into consideration, So, here's the deal. We have a few QSplitters that takes care of helping us with the size of a few widgets, they are ok, and we should continue using them to manage the visibility of them too. But the way that we did before was to widget->hide(); something, and if you hided something using the splitter, by holding it's handle and collapsing the widget, then you used the 'ctrl+number' shortcut to show it, it whould only show a gray panel. This patch makes everything behave using the splitters. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 48 ++++++++++++++++++++++++++++++++++++------------ qt-ui/mainwindow.h | 6 +++++- qt-ui/mainwindow.ui | 18 ++++++++++++++---- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index ce9aadc62..eb7febed7 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -232,32 +232,54 @@ void MainWindow::on_actionYearlyStatistics_triggered() qDebug("actionYearlyStatistics"); } +/** + * So, here's the deal. + * We have a few QSplitters that takes care of helping us with the + * size of a few widgets, they are ok, and we should continue using them + * to manage the visibility of them too. But the way that we did before was to + * widget->hide(); something, and if you hided something using the splitter, + * by holding it's handle and collapsing the widget, then you used the 'ctrl+number' + * shortcut to show it, it whould only show a gray panel. + * + * This patch makes everything behave using the splitters. + */ + +#define BEHAVIOR QList() void MainWindow::on_actionViewList_triggered() { - ui->InfoWidget->setVisible(false); - ui->ListWidget->setVisible(true); - ui->ProfileWidget->setVisible(false); + ui->listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); + ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); } void MainWindow::on_actionViewProfile_triggered() { - ui->InfoWidget->setVisible(false); - ui->ListWidget->setVisible(false); - ui->ProfileWidget->setVisible(true); + ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); } void MainWindow::on_actionViewInfo_triggered() { - ui->InfoWidget->setVisible(true); - ui->ListWidget->setVisible(false); - ui->ProfileWidget->setVisible(false); + ui->infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); + ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); +} + +void MainWindow::on_actionViewGlobe_triggered() +{ + ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); + ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); } +#undef BEHAVIOR void MainWindow::on_actionViewAll_triggered() { - ui->InfoWidget->setVisible(true); - ui->ListWidget->setVisible(true); - ui->ProfileWidget->setVisible(true); + // big number squash the info profile to it's minimum. + ui->infoProfileSplitter->setSizes(QList() << 1 << 20000); + + // big number squash the globe view. + ui->listGlobeSplitter->setSizes(QList() << 2000 << 1 ); + + // half and half? + ui->mainSplitter->setSizes( QList() << 1 << 1); } void MainWindow::on_actionPreviousDC_triggered() @@ -397,6 +419,7 @@ void MainWindow::initialUiSetup() resize(sz); ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); + ui->listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); settings.endGroup(); settings.beginGroup("ListWidget"); @@ -488,6 +511,7 @@ void MainWindow::writeSettings() settings.setValue("size",size()); settings.setValue("mainSplitter", ui->mainSplitter->saveState()); settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState()); + settings.setValue("listGlobeSplitter", ui->listGlobeSplitter->saveState()); settings.endGroup(); settings.beginGroup("ListWidget"); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index f3024ef8d..0b3812469 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -8,13 +8,13 @@ #define MAINWINDOW_H #include -#include #include struct DiveList; class QSortFilterProxyModel; class DiveTripModel; + namespace Ui { class MainWindow; @@ -35,6 +35,8 @@ class MainWindow : public QMainWindow { Q_OBJECT public: + enum {COLLAPSED, EXPANDED}; + MainWindow(); ProfileGraphicsView *graphics(); MainTab *information(); @@ -71,6 +73,7 @@ private Q_SLOTS: void on_actionViewList_triggered(); void on_actionViewProfile_triggered(); void on_actionViewInfo_triggered(); + void on_actionViewGlobe_triggered(); void on_actionViewAll_triggered(); void on_actionPreviousDC_triggered(); void on_actionNextDC_triggered(); @@ -102,6 +105,7 @@ private: void redrawProfile(); void file_save(); void file_save_as(); + void setupSplitters(); }; MainWindow *mainWindow(); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index fbf10cdf8..598068e3d 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -14,8 +14,8 @@ MainWindow - - + + Qt::Vertical @@ -92,7 +92,7 @@ - + @@ -147,7 +147,9 @@ + + @@ -323,7 +325,7 @@ View All - Ctrl+4 + Ctrl+5 @@ -365,6 +367,14 @@ F1 + + + View Globe + + + Ctrl+4 + + -- cgit v1.2.3-70-g09d2