From 4867ee8ad87399f34a399f30def700b2fc045309 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 9 Feb 2015 20:14:08 -0200 Subject: Move the Profile out of the mainwindow.ui And place it in mainwindow.cpp Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.h | 3 ++ qt-ui/mainwindow.cpp | 25 +++++++------- qt-ui/mainwindow.h | 1 + qt-ui/mainwindow.ui | 92 ---------------------------------------------------- 4 files changed, 17 insertions(+), 104 deletions(-) diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 49fd43ff6..196e17546 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -192,6 +192,9 @@ class PlannerDetails : public QWidget { Q_OBJECT public: explicit PlannerDetails(QWidget *parent = 0); + QPushButton *printPlan() const { return ui.printPlan; } + QTextEdit *divePlanOutput() const { return ui.divePlanOutput; } + private: Ui::plannerDetails ui; }; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9caa5d3c3..a6a8cdeca 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -67,6 +67,7 @@ MainWindow::MainWindow() : QMainWindow(), registerApplicationState("EditDive", mainTab, diveListView, profileWidget, globeGps ); registerApplicationState("PlanDive", plannerWidget, plannerSettings, profileWidget, plannerDetails ); registerApplicationState("EditPlannedDive", plannerWidget, diveListView, profileWidget, globeGps ); + setApplicationState("Default"); ui.multiFilter->hide(); // what is a sane order for those icons? we should have the ones the user is @@ -100,7 +101,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(information(), SIGNAL(addDiveFinished()), graphics(), SLOT(setProfileState())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); - connect(ui.printPlan, SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); + connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(ui.menu_Edit, SIGNAL(aboutToShow()), this, SLOT(checkForUndoAndRedo())); #ifdef NO_PRINTING ui.printPlan->hide(); @@ -176,7 +177,6 @@ MainWindow::MainWindow() : QMainWindow(), updateManager = new UpdateManager(this); undoBuffer = new UndoBuffer(this); - setApplicationState("Default"); } MainWindow::~MainWindow() @@ -184,6 +184,10 @@ MainWindow::~MainWindow() m_Instance = NULL; } +PlannerDetails *MainWindow::plannerDetails() const { + return qobject_cast(applicationState["PlanDive"].bottomRight); +} + void MainWindow::setLoadedWithFiles(bool f) { filesAsArguments = f; @@ -212,7 +216,8 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList) #ifdef NO_MARBLE ui.globePane->hide(); #endif - ui.globePane->setCurrentIndex(0); + + setApplicationState("Default"); dive_list()->setEnabled(true); dive_list()->setFocus(); WSInfoModel::instance()->updateInfo(); @@ -483,13 +488,13 @@ void MainWindow::planCreated() void MainWindow::setPlanNotes(const char *notes) { - ui.divePlanOutput->setHtml(notes); + plannerDetails()->divePlanOutput()->setHtml(notes); } void MainWindow::printPlan() { #ifndef NO_PRINTING - QString diveplan = ui.divePlanOutput->toHtml(); + QString diveplan = plannerDetails()->divePlanOutput()->toHtml(); QString withDisclaimer = QString(" ") + diveplan + QString(disclaimer); QPrinter printer; @@ -498,9 +503,9 @@ void MainWindow::printPlan() if (dialog->exec() != QDialog::Accepted) return; - ui.divePlanOutput->setHtml(withDisclaimer); - ui.divePlanOutput->print(&printer); - ui.divePlanOutput->setHtml(diveplan); + plannerDetails()->divePlanOutput()->setHtml(withDisclaimer); + plannerDetails()->divePlanOutput()->print(&printer); + plannerDetails()->divePlanOutput()->setHtml(diveplan); #endif } @@ -534,8 +539,6 @@ void MainWindow::on_actionReplanDive_triggered() divePlannerWidget()->setReplanButton(true); DivePlannerPointsModel::instance()->loadFromDive(current_dive); reset_cylinders(&displayed_dive, true); - ui.diveListPane->setCurrentIndex(1); // switch to the plan output - ui.globePane->setCurrentIndex(1); #ifdef NO_MARBLE ui.globePane->show(); #endif @@ -559,8 +562,6 @@ void MainWindow::on_actionDivePlanner_triggered() DivePictureModel::instance()->updateDivePictures(); divePlannerWidget()->setReplanButton(false); - ui.diveListPane->setCurrentIndex(1); // switch to the plan output - ui.globePane->setCurrentIndex(1); #ifdef NO_MARBLE ui.globePane->show(); #endif diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 0bb024079..2af7f9c9b 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -81,6 +81,7 @@ public: void cleanUpEmpty(); void setToolButtonsEnabled(bool enabled); ProfileWidget2 *graphics() const; + PlannerDetails *plannerDetails() const; void setLoadedWithFiles(bool filesFromCommandLine); bool filesFromCommandLine() const; void setPlanNotes(const char *notes); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 4bc74f20c..b4be5b7d9 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -41,98 +41,6 @@ - - - 0 - - - - - 0 - 0 - - - - - - - - 0 - 0 - - - - - - - - - - 16777215 - 20 - - - - <html><head/><body><p><span style=" font-weight:600;">Dive plan details</span></p></body></html> - - - Qt::RichText - - - - - - - - 0 - 0 - - - - Print - - - false - - - false - - - false - - - - - - - - - true - - - - 0 - 0 - - - - font: 13pt "Courier"; - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Courier'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'.Curier New';"><br /></p></body></html> - - - - - - -- cgit v1.2.3-70-g09d2