mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
238c0573da
commit
2992d78f83
3 changed files with 21 additions and 50 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
@ -830,12 +804,6 @@ p, li { white-space: pre-wrap; }
|
|||
<header>kmessagewidget.h</header>
|
||||
<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>
|
||||
|
|
Loading…
Add table
Reference in a new issue