Remove the old profile from the main screen of Subsurface

This patch partially removes the code for the old profile from
Subsurface. It removes the use of the old profile on the mainwindow,
but keeping the code in the tree for now.

A bit of code-cleanup also entered this commit because I had to change
every instance of the code that used the old profile.

Now to the real code-cleanup

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-03-07 12:42:13 -03:00 committed by Dirk Hohndel
parent 6dec4b0556
commit ac9a23ef3b
9 changed files with 383 additions and 500 deletions

View file

@ -10,6 +10,7 @@
#include "../dive.h"
#include "../divelist.h"
#include "../planner.h"
#include "display.h"
#include "helpers.h"
#include <QMouseEvent>

View file

@ -15,6 +15,7 @@
#include "diveplanner.h"
#include "divelist.h"
#include "qthelper.h"
#include "display.h"
#include <QLabel>
#include <QCompleter>

View file

@ -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<int>()
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<struct dive *>() << (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<struct dive *>() << (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;

View file

@ -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);

View file

@ -90,10 +90,7 @@
<number>0</number>
</property>
<widget class="QWidget" name="page_5">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -106,426 +103,369 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="profPO2">
<property name="toolTip">
<string>Enable the pO2 Graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_o2</normaloff>:/icon_o2</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Old Profile</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="ProfileGraphicsView" name="ProfileWidget"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>New Profile</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="profPO2">
<property name="toolTip">
<string>Enable the pO2 Graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_o2</normaloff>:/icon_o2</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profPn2">
<property name="toolTip">
<string>Enable the pN2 Graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_n2</normaloff>:/icon_n2</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profPhe">
<property name="toolTip">
<string>Enable the pHe graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_he</normaloff>:/icon_he</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profDcCeiling">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Show the DC Reported Ceiling</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_dc</normaloff>:/icon_ceiling_dc</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profCalcCeiling">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Show the Calculated Ceiling</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_calculated</normaloff>:/icon_ceiling_calculated</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profCalcAllTissues">
<property name="toolTip">
<string>Calculate All Tissues</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_alltissues</normaloff>:/icon_ceiling_alltissues</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profIncrement3m">
<property name="toolTip">
<string>Show Calculated Ceiling with 3m Increments</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_3m</normaloff>:/icon_ceiling_3m</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profMod">
<property name="toolTip">
<string>Enable MOD</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_mod</normaloff>:/icon_mod</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profEad">
<property name="toolTip">
<string>Enable EAD, END, and EADD</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ead</normaloff>:/icon_ead</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profNdl_tts">
<property name="toolTip">
<string>Show NDL / TTS</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_NDLTTS</normaloff>:/icon_NDLTTS</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profSAC">
<property name="toolTip">
<string>Show SAC Rate</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_lung</normaloff>:/icon_lung</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profRuler">
<property name="toolTip">
<string>Enable / Disable the Ruler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/units</normaloff>:/units</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="profScaled">
<property name="toolTip">
<string>Rescale depth axis</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/scale</normaloff>:/scale</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="ProfileWidget2" name="newProfile"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="profPn2">
<property name="toolTip">
<string>Enable the pN2 Graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_n2</normaloff>:/icon_n2</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="profPhe">
<property name="toolTip">
<string>Enable the pHe graph</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_he</normaloff>:/icon_he</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="profDcCeiling">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Show the DC Reported Ceiling</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_dc</normaloff>:/icon_ceiling_dc</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QToolButton" name="profCalcCeiling">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Show the Calculated Ceiling</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_calculated</normaloff>:/icon_ceiling_calculated</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QToolButton" name="profCalcAllTissues">
<property name="toolTip">
<string>Calculate All Tissues</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_alltissues</normaloff>:/icon_ceiling_alltissues</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QToolButton" name="profIncrement3m">
<property name="toolTip">
<string>Show Calculated Ceiling with 3m Increments</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ceiling_3m</normaloff>:/icon_ceiling_3m</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QToolButton" name="profMod">
<property name="toolTip">
<string>Enable MOD</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_mod</normaloff>:/icon_mod</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QToolButton" name="profEad">
<property name="toolTip">
<string>Enable EAD, END, and EADD</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_ead</normaloff>:/icon_ead</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QToolButton" name="profNdl_tts">
<property name="toolTip">
<string>Show NDL / TTS</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_NDLTTS</normaloff>:/icon_NDLTTS</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QToolButton" name="profSAC">
<property name="toolTip">
<string>Show SAC Rate</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/icon_lung</normaloff>:/icon_lung</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QToolButton" name="profRuler">
<property name="toolTip">
<string>Enable / Disable the Ruler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/units</normaloff>:/units</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QToolButton" name="profScaled">
<property name="toolTip">
<string>Rescale depth axis</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/scale</normaloff>:/scale</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="14">
<widget class="ProfileWidget2" name="newProfile"/>
</item>
<item row="13" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_6">
@ -597,7 +537,7 @@
<x>0</x>
<y>0</y>
<width>1418</width>
<height>22</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -983,11 +923,6 @@
<extends>QTreeView</extends>
<header>divelistview.h</header>
</customwidget>
<customwidget>
<class>ProfileGraphicsView</class>
<extends>QGraphicsView</extends>
<header>profilegraphics.h</header>
</customwidget>
<customwidget>
<class>GlobeGPS</class>
<extends>QWidget</extends>

View file

@ -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<QTableView> 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<struct dive*>() << 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 */

View file

@ -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<QGraphicsItem *> itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos())));
Q_FOREACH(QGraphicsItem * i, itemsAtPos) {
EventItem *item = dynamic_cast<EventItem *>(i);
DiveEventItem *item = dynamic_cast<DiveEventItem *>(i);
if (!item)
continue;
action = new QAction(&m);

View file

@ -62,7 +62,7 @@ public:
COLUMNS
};
ProfileWidget2(QWidget *parent);
ProfileWidget2(QWidget *parent = 0);
void plotDives(QList<dive *> dives);
virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);

View file

@ -17,6 +17,7 @@
#include "../dive.h"
#include "../divelist.h"
#include "../display.h"
#ifdef Q_OS_UNIX
#include <unistd.h> // for dup(2)