diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index b4ca5ba89..6a26e00f9 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -10,6 +10,7 @@ #include "../dive.h" #include "../divelist.h" #include "../planner.h" +#include "display.h" #include "helpers.h" #include diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7305ee422..c2acaa700 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -15,6 +15,7 @@ #include "diveplanner.h" #include "divelist.h" #include "qthelper.h" +#include "display.h" #include #include diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4e8f46325..20f463cf0 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -54,7 +54,6 @@ MainWindow::MainWindow() : QMainWindow(), connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlanner, SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged())); @@ -96,7 +95,6 @@ void MainWindow::refreshDisplay(bool recreateDiveList) { ui.InfoWidget->reload(); TankInfoModel::instance()->update(); - ui.ProfileWidget->refresh(); ui.globe->reload(); if (recreateDiveList) ui.ListWidget->reload(DiveTripModel::CURRENT); @@ -110,7 +108,6 @@ void MainWindow::current_dive_changed(int divenr) select_dive(divenr); ui.globe->centerOn(get_dive(selected_dive)); } - redrawProfile(); /* It looks like it's a bit too cumberstone to send *one* dive using a QList, * but this is just futureproofness, it's the best way in the future to show more than @@ -121,11 +118,6 @@ void MainWindow::current_dive_changed(int divenr) ui.InfoWidget->updateDiveInfo(divenr); } -void MainWindow::redrawProfile() -{ - ui.ProfileWidget->refresh(); -} - void MainWindow::on_actionNew_triggered() { on_actionClose_triggered(); @@ -146,10 +138,6 @@ void MainWindow::on_actionOpen_triggered() loadFiles(QStringList() << filename); } -QTabWidget *MainWindow::tabWidget() -{ - return ui.tabWidget; -} void MainWindow::on_actionSave_triggered() { file_save(); @@ -160,13 +148,18 @@ void MainWindow::on_actionSaveAs_triggered() file_save_as(); } +ProfileWidget2* MainWindow::graphics() const +{ + return ui.newProfile; +} + void MainWindow::cleanUpEmpty() { ui.InfoWidget->clearStats(); ui.InfoWidget->clearInfo(); ui.InfoWidget->clearEquipment(); ui.InfoWidget->updateDiveInfo(-1); - ui.ProfileWidget->clear(); + ui.newProfile->setEmptyState(); ui.ListWidget->reload(DiveTripModel::TREE); ui.globe->reload(); if (!existing_filename) @@ -377,28 +370,6 @@ void MainWindow::on_actionYearlyStatistics_triggered() view->show(); } -void MainWindow::on_mainSplitter_splitterMoved(int pos, int idx) -{ - redrawProfile(); -} - -void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx) -{ - redrawProfile(); -} - -/** - * 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() { @@ -412,7 +383,6 @@ void MainWindow::on_actionViewProfile_triggered() beginChangeState(PROFILE_MAXIMIZED); ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); - redrawProfile(); } void MainWindow::on_actionViewInfo_triggered() @@ -470,7 +440,6 @@ void MainWindow::on_actionViewAll_triggered() ui.infoProfileSplitter->setSizes(infoProfileSizes); ui.listGlobeSplitter->setSizes(listGlobeSizes); } - redrawProfile(); } void MainWindow::beginChangeState(CurrentState s) @@ -495,7 +464,6 @@ void MainWindow::on_actionPreviousDC_triggered() dc_number--; ui.InfoWidget->updateDiveInfo(selected_dive); ui.newProfile->plotDives(QList() << (current_dive)); - redrawProfile(); } void MainWindow::on_actionNextDC_triggered() @@ -503,7 +471,6 @@ void MainWindow::on_actionNextDC_triggered() dc_number++; ui.InfoWidget->updateDiveInfo(selected_dive); ui.newProfile->plotDives(QList() << (current_dive)); - redrawProfile(); } void MainWindow::on_actionFullScreen_triggered(bool checked) @@ -696,11 +663,6 @@ GlobeGPS *MainWindow::globe() return ui.globe; } -ProfileGraphicsView *MainWindow::graphics() -{ - return ui.ProfileWidget; -} - MainTab *MainWindow::information() { return ui.InfoWidget; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 79aeeecf2..40f22dd61 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -60,7 +60,6 @@ public: MainWindow(); virtual ~MainWindow(); static MainWindow *instance(); - ProfileGraphicsView *graphics(); MainTab *information(); void loadRecentFiles(QSettings *s); void addRecentFile(const QStringList &newFiles); @@ -77,7 +76,7 @@ public: void loadFiles(const QStringList files); void importFiles(const QStringList importFiles); void cleanUpEmpty(); - QTabWidget *tabWidget(); + ProfileWidget2 *graphics() const; private slots: /* file menu action */ @@ -119,10 +118,6 @@ slots: void on_actionUserManual_triggered(); void on_actionDivePlanner_triggered(); - /* monitor resize of the info-profile splitter */ - void on_mainSplitter_splitterMoved(int pos, int idx); - void on_infoProfileSplitter_splitterMoved(int pos, int idx); - void current_dive_changed(int divenr); void initialUiSetup(); @@ -163,7 +158,6 @@ private: static MainWindow *m_Instance; bool askSaveChanges(); void writeSettings(); - void redrawProfile(); void file_save(); void file_save_as(); void beginChangeState(CurrentState s); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 26c727efb..a933a2de9 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -90,10 +90,7 @@ 0 - - - 0 - + 0 @@ -106,426 +103,369 @@ 0 - - - - 1 + + 0 + + + + + Enable the pO2 Graph + + + ... + + + + :/icon_o2:/icon_o2 + + + + 24 + 24 + + + + true + + + true - - - Old Profile - - - - - - - - - - New Profile - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Enable the pO2 Graph - - - ... - - - - :/icon_o2:/icon_o2 - - - - 24 - 24 - - - - true - - - true - - - - - - - Enable the pN2 Graph - - - ... - - - - :/icon_n2:/icon_n2 - - - - 24 - 24 - - - - true - - - true - - - - - - - Enable the pHe graph - - - ... - - - - :/icon_he:/icon_he - - - - 24 - 24 - - - - true - - - true - - - - - - - true - - - Show the DC Reported Ceiling - - - ... - - - - :/icon_ceiling_dc:/icon_ceiling_dc - - - - 24 - 24 - - - - true - - - true - - - - - - - true - - - Show the Calculated Ceiling - - - ... - - - - :/icon_ceiling_calculated:/icon_ceiling_calculated - - - - 24 - 24 - - - - true - - - true - - - - - - - Calculate All Tissues - - - ... - - - - :/icon_ceiling_alltissues:/icon_ceiling_alltissues - - - - 24 - 24 - - - - true - - - true - - - - - - - Show Calculated Ceiling with 3m Increments - - - ... - - - - :/icon_ceiling_3m:/icon_ceiling_3m - - - - 24 - 24 - - - - true - - - true - - - - - - - Enable MOD - - - ... - - - - :/icon_mod:/icon_mod - - - - 24 - 24 - - - - true - - - true - - - - - - - Enable EAD, END, and EADD - - - ... - - - - :/icon_ead:/icon_ead - - - - 24 - 24 - - - - true - - - true - - - - - - - Show NDL / TTS - - - ... - - - - :/icon_NDLTTS:/icon_NDLTTS - - - - 24 - 24 - - - - true - - - true - - - - - - - Show SAC Rate - - - ... - - - - :/icon_lung:/icon_lung - - - - 24 - 24 - - - - true - - - true - - - - - - - Enable / Disable the Ruler - - - ... - - - - :/units:/units - - - - 24 - 24 - - - - true - - - true - - - - - - - Rescale depth axis - - - ... - - - - :/scale:/scale - - - - 24 - 24 - - - - true - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - + + + + Enable the pN2 Graph + + + ... + + + + :/icon_n2:/icon_n2 + + + + 24 + 24 + + + + true + + + true + + + + + + + Enable the pHe graph + + + ... + + + + :/icon_he:/icon_he + + + + 24 + 24 + + + + true + + + true + + + + + + + true + + + Show the DC Reported Ceiling + + + ... + + + + :/icon_ceiling_dc:/icon_ceiling_dc + + + + 24 + 24 + + + + true + + + true + + + + + + + true + + + Show the Calculated Ceiling + + + ... + + + + :/icon_ceiling_calculated:/icon_ceiling_calculated + + + + 24 + 24 + + + + true + + + true + + + + + + + Calculate All Tissues + + + ... + + + + :/icon_ceiling_alltissues:/icon_ceiling_alltissues + + + + 24 + 24 + + + + true + + + true + + + + + + + Show Calculated Ceiling with 3m Increments + + + ... + + + + :/icon_ceiling_3m:/icon_ceiling_3m + + + + 24 + 24 + + + + true + + + true + + + + + + + Enable MOD + + + ... + + + + :/icon_mod:/icon_mod + + + + 24 + 24 + + + + true + + + true + + + + + + + Enable EAD, END, and EADD + + + ... + + + + :/icon_ead:/icon_ead + + + + 24 + 24 + + + + true + + + true + + + + + + + Show NDL / TTS + + + ... + + + + :/icon_NDLTTS:/icon_NDLTTS + + + + 24 + 24 + + + + true + + + true + + + + + + + Show SAC Rate + + + ... + + + + :/icon_lung:/icon_lung + + + + 24 + 24 + + + + true + + + true + + + + + + + Enable / Disable the Ruler + + + ... + + + + :/units:/units + + + + 24 + 24 + + + + true + + + true + + + + + + + Rescale depth axis + + + ... + + + + :/scale:/scale + + + + 24 + 24 + + + + true + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -597,7 +537,7 @@ 0 0 1418 - 22 + 25 @@ -983,11 +923,6 @@ QTreeView
divelistview.h
- - ProfileGraphicsView - QGraphicsView -
profilegraphics.h
-
GlobeGPS QWidget diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index e06bedaa2..b84f2ecea 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -131,18 +131,16 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) painter.scale(scaleX, scaleY); // setup the profile widget - ProfileGraphicsView *profile = MainWindow::instance()->graphics(); - const int profileFrameStyle = profile->frameStyle(); - profile->setFrameStyle(QFrame::NoFrame); - profile->clear(); - profile->setPrintMode(true, !printOptions->color_selected); - QSize originalSize = profile->size(); + ProfileWidget2 profile; + profile.setFrameStyle(QFrame::NoFrame); +// profile->setPrintMode(true, !printOptions->color_selected); // swap rows/col for landscape if (printer->orientation() == QPrinter::Landscape) { int swap = divesPerColumn; divesPerColumn = divesPerRow; divesPerRow = swap; } + // padding in pixels between two dives. no padding if only one dive per page. const int padDef = 20; const int padW = (divesPerColumn < 2) ? 0 : padDef; @@ -154,11 +152,11 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) const int padPT = 5; // create a model and table ProfilePrintModel model; - QTableView *table = createProfileTable(&model, scaledW); + QPointer table(createProfileTable(&model, scaledW)); // profilePrintTableMaxH updates after the table is created const int tableH = profilePrintTableMaxH; // resize the profile widget - profile->resize(scaledW, scaledH - tableH - padPT); + profile.resize(scaledW, scaledH - tableH - padPT); // offset table or profile on top int yOffsetProfile = 0, yOffsetTable = 0; if (printOptions->notes_up) @@ -182,8 +180,8 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) // draw a profile painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetProfile); - profile->plot(dive, true); - profile->render(&painter, QRect(0, 0, scaledW, scaledH - tableH - padPT)); + profile.plotDives( QList() << dive); + profile.render(&painter, QRect(0, 0, scaledW, scaledH - tableH - padPT)); painter.setTransform(origTransform); // draw a table @@ -195,15 +193,6 @@ void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn) printed++; emit signalProgress((printed * 100) / total); } - - // cleanup - painter.end(); - delete table; - profile->setFrameStyle(profileFrameStyle); - profile->setPrintMode(false); - profile->resize(originalSize); - profile->clear(); - profile->plot(current_dive, true); } /* we create a table that has a fixed height, but can stretch to fit certain width */ diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 67d857ce2..3b8a3d18a 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -94,7 +94,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), #ifndef QT_NO_DEBUG QTableView *diveDepthTableView = new QTableView(); diveDepthTableView->setModel(dataModel); - MainWindow::instance()->tabWidget()->addTab(diveDepthTableView, "Depth Model"); + diveDepthTableView->show(); #endif } @@ -634,7 +634,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) action->setData(event->globalPos()); QList itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos()))); Q_FOREACH(QGraphicsItem * i, itemsAtPos) { - EventItem *item = dynamic_cast(i); + DiveEventItem *item = dynamic_cast(i); if (!item) continue; action = new QAction(&m); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 9393f4f03..c22d2b151 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -62,7 +62,7 @@ public: COLUMNS }; - ProfileWidget2(QWidget *parent); + ProfileWidget2(QWidget *parent = 0); void plotDives(QList dives); virtual bool eventFilter(QObject *, QEvent *); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 1d8f88591..93b452475 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -17,6 +17,7 @@ #include "../dive.h" #include "../divelist.h" +#include "../display.h" #ifdef Q_OS_UNIX #include // for dup(2)