summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-02-09 19:19:10 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-10 10:45:45 -0800
commit2992d78f83ce121b5a34a566026c6068416c2557 (patch)
tree932719db93b8765c7f662441c959f3f79e73738c /qt-ui
parent238c0573da906bec51d10dce59665c7442641fd8 (diff)
downloadsubsurface-2992d78f83ce121b5a34a566026c6068416c2557.tar.gz
Remove the PlannerWidget from mainwindow.ui
Now it uses the states on the mainwindow.cpp and it's finally starting to be worth the hassle of reworking the UI. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp37
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/mainwindow.ui32
3 files changed, 21 insertions, 50 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 48cc23e4a..22d7fd386 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -63,7 +63,9 @@ MainWindow::MainWindow() : QMainWindow(),
registerApplicationState("Default", mainTab, diveListView, profileWidget, globeGps );
registerApplicationState("AddDive", mainTab, diveListView, profileWidget, globeGps );
+ registerApplicationState("EditDive", mainTab, diveListView, profileWidget, globeGps );
registerApplicationState("PlanDive", plannerWidget, plannerSettings, profileWidget, plannerDetails );
+ registerApplicationState("EditPlannedDive", plannerWidget, diveListView, profileWidget, globeGps );
ui.multiFilter->hide();
// what is a sane order for those icons? we should have the ones the user is
@@ -87,7 +89,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged()));
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.plannerSettingsWidget, SLOT(settingsChanged()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
@@ -97,7 +99,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState()));
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
- connect(ui.printPlan, SIGNAL(pressed()), ui.divePlannerWidget, SLOT(printDecoPlan()));
+ connect(ui.printPlan, SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
connect(ui.menu_Edit, SIGNAL(aboutToShow()), this, SLOT(checkForUndoAndRedo()));
#ifdef NO_PRINTING
ui.printPlan->hide();
@@ -114,7 +116,7 @@ MainWindow::MainWindow() : QMainWindow(),
globe()->reload();
diveListView->expand(dive_list()->model()->index(0, 0));
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
- ui.divePlannerWidget->settingsChanged();
+ divePlannerWidget()->settingsChanged();
ui.plannerSettingsWidget->settingsChanged();
#ifdef NO_MARBLE
ui.globePane->hide();
@@ -385,7 +387,7 @@ void MainWindow::showProfile()
{
enableShortcuts();
ui.newProfile->setProfileState();
- ui.infoPane->setCurrentIndex(MAINTAB);
+ setApplicationState("Default");
}
void MainWindow::on_actionPreferences_triggered()
@@ -527,8 +529,8 @@ void MainWindow::on_actionReplanDive_triggered()
ui.newProfile->setPlanState();
ui.newProfile->clearHandlers();
- ui.infoPane->setCurrentIndex(PLANNERWIDGET);
- ui.divePlannerWidget->setReplanButton(true);
+ setApplicationState("PlanDive");
+ divePlannerWidget()->setReplanButton(true);
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
reset_cylinders(&displayed_dive, true);
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
@@ -545,16 +547,16 @@ void MainWindow::on_actionDivePlanner_triggered()
// put us in PLAN mode
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
+ setApplicationState("PlanDive");
ui.newProfile->setPlanState();
- ui.infoPane->setCurrentIndex(PLANNERWIDGET);
// create a simple starting dive, using the first gas from the just copied cylidners
setupForAddAndPlan("planned dive"); // don't translate, stored in XML file
DivePlannerPointsModel::instance()->setupStartTime();
DivePlannerPointsModel::instance()->createSimpleDive();
DivePictureModel::instance()->updateDivePictures();
- ui.divePlannerWidget->setReplanButton(false);
+ divePlannerWidget()->setReplanButton(false);
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
ui.globePane->setCurrentIndex(1);
@@ -563,6 +565,10 @@ void MainWindow::on_actionDivePlanner_triggered()
#endif
}
+DivePlannerWidget* MainWindow::divePlannerWidget() {
+ return qobject_cast<DivePlannerWidget*>(applicationState["PlanDive"].topLeft);
+}
+
void MainWindow::on_actionAddDive_triggered()
{
if (!plannerStateClean())
@@ -573,6 +579,7 @@ void MainWindow::on_actionAddDive_triggered()
dive_list()->clearSelection();
}
+ setApplicationState("AddDive");
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
// setup things so we can later create our starting dive
@@ -585,7 +592,6 @@ void MainWindow::on_actionAddDive_triggered()
information()->setCurrentIndex(0);
information()->addDiveStarted();
- ui.infoPane->setCurrentIndex(MAINTAB);
ui.newProfile->setAddState();
DivePlannerPointsModel::instance()->createSimpleDive();
@@ -1391,17 +1397,13 @@ void MainWindow::editCurrentDive()
disableShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
ui.newProfile->setAddState();
- ui.infoPane->setCurrentIndex(MAINTAB);
+ setApplicationState("EditDive");
DivePlannerPointsModel::instance()->loadFromDive(d);
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
} else if (defaultDC == "planned dive") {
disableShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
- //TODO: I BROKE THIS BY COMMENTING THE LINE BELOW
- // and I'm sleepy now, so I think I should not try to fix right away.
- // we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView.
- //ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
- ui.infoPane->setCurrentIndex(PLANNERWIDGET);
+ setApplicationState("EditPlannedDive");
DivePlannerPointsModel::instance()->loadFromDive(d);
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
}
@@ -1515,16 +1517,15 @@ void MainWindow::setApplicationState(const QByteArray& state) {
return;
// yes, index is zero both times. please don't change it.
- if (ui.topSplitter->count()) {
+ if (ui.topSplitter->count() >= 2) {
ui.topSplitter->widget(0)->setParent(NULL);
ui.topSplitter->widget(0)->setParent(NULL);
}
- if (ui.bottomSplitter->count()) {
+ if (ui.bottomSplitter->count() >= 2) {
ui.bottomSplitter->widget(0)->setParent(NULL);
ui.bottomSplitter->widget(0)->setParent(NULL);
}
-
WidgetForBorder curr = applicationState[state];
ui.topSplitter->addWidget(curr.topLeft);
ui.topSplitter->addWidget(curr.topRight);
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 6179a9732..c3eb18a29 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -30,6 +30,7 @@ class QWebView;
class QSettings;
class UpdateManager;
class UserManual;
+class DivePlannerWidget;
class UndoBuffer;
enum MainWindowTitleFormat {
@@ -65,6 +66,7 @@ public:
void removeRecentFile(QStringList failedFiles);
DiveListView *dive_list();
GlobeGPS *globe();
+ DivePlannerWidget *divePlannerWidget();
void showError(QString message);
void setTitle(enum MainWindowTitleFormat format);
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index dfb58129b..aa9ca314c 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -27,32 +27,6 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <widget class="QStackedWidget" name="infoPane">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="page">
- <layout class="QHBoxLayout" name="mainTabOuterLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- </layout>
- </widget>
- <widget class="QWidget" name="page_2">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <layout class="QHBoxLayout" name="divePlannerLayout">
- <item>
- <widget class="DivePlannerWidget" name="divePlannerWidget" native="true">
- <property name="enabled">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
<widget class="QWidget" name="ProfileWidget">
<layout class="QGridLayout" name="profileInnerLayout">
<item row="0" column="0" rowspan="3">
@@ -831,12 +805,6 @@ p, li { white-space: pre-wrap; }
<container>1</container>
</customwidget>
<customwidget>
- <class>DivePlannerWidget</class>
- <extends>QWidget</extends>
- <header>diveplanner.h</header>
- <container>1</container>
- </customwidget>
- <customwidget>
<class>ProfileWidget2</class>
<extends>QGraphicsView</extends>
<header>qt-ui/profile/profilewidget2.h</header>