diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index a78b84565..740849033 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -15,7 +15,7 @@ #include <QCloseEvent> #include <QApplication> #include <QFontMetrics> -#include <QTextBrowser> +#include <QWebView> #include <QTableView> #include "divelistview.h" #include "starwidget.h" @@ -45,6 +45,7 @@ MainWindow* mainWindow() MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0) { + instance = this; ui->setupUi(this); setWindowIcon(QIcon(":subsurface-icon")); connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); @@ -59,7 +60,6 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0) ui->ListWidget->reloadHeaderActions(); ui->ListWidget->setFocus(); ui->globe->reload(); - instance = this; } // this gets called after we download dives from a divecomputer @@ -117,22 +117,7 @@ void MainWindow::on_actionOpen_triggered() QByteArray fileNamePtr = filename.toLocal8Bit(); on_actionClose_triggered(); - - char *error = NULL; - parse_file(fileNamePtr.data(), &error); - set_filename(fileNamePtr.data(), TRUE); - setTitle(MWTF_FILENAME); - - if (error != NULL) { - showError(error); - free(error); - } - process_dives(FALSE, FALSE); - - ui->InfoWidget->reload(); - ui->globe->reload(); - ui->ListWidget->reload(DiveTripModel::TREE); - ui->ListWidget->setFocus(); + loadFiles( QStringList() << filename ); } void MainWindow::on_actionSave_triggered() @@ -193,23 +178,7 @@ void MainWindow::on_actionImport_triggered() settings.setValue("LastDir", fileInfo.dir().path()); settings.endGroup(); - QByteArray fileNamePtr; - char *error = NULL; - for (int i = 0; i < fileNames.size(); ++i) { - fileNamePtr = fileNames.at(i).toLocal8Bit(); - parse_file(fileNamePtr.data(), &error); - if (error != NULL) { - showError(error); - free(error); - error = NULL; - } - } - process_dives(FALSE, FALSE); - - ui->InfoWidget->reload(); - ui->globe->reload(); - ui->ListWidget->reload(DiveTripModel::TREE); - ui->ListWidget->setFocus(); + importFiles(fileNames); } void MainWindow::on_actionExportUDDF_triggered() @@ -238,12 +207,14 @@ void MainWindow::on_actionDivePlanner_triggered() { disableDcShortcuts(); ui->stackedWidget->setCurrentIndex(1); + ui->infoPane->setCurrentIndex(1); } void MainWindow::showProfile() { enableDcShortcuts(); ui->stackedWidget->setCurrentIndex(0); + ui->infoPane->setCurrentIndex(0); } @@ -324,8 +295,6 @@ void MainWindow::on_mainSplitter_splitterMoved(int pos, int idx) void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx) { - /* always update the floating plus sign icons in the equipment tab */ - ui->InfoWidget->equipmentPlusUpdate(); redrawProfile(); } @@ -411,14 +380,14 @@ void MainWindow::on_actionAboutSubsurface_triggered() void MainWindow::on_actionUserManual_triggered() { if(!helpView){ - helpView = new QTextBrowser(); + helpView = new QWebView(); } QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath != "") { QUrl url(searchPath.append("/user-manual.html")); - helpView->setSource(url); + helpView->setUrl(url); } else { - helpView->setText(tr("Cannot find the Subsurface manual")); + helpView->setHtml(tr("Cannot find the Subsurface manual")); } helpView->show(); } @@ -755,3 +724,53 @@ void MainWindow::setTitle(enum MainWindowTitleFormat format) break; } } + +void MainWindow::importFiles(const QStringList fileNames) +{ + QByteArray fileNamePtr; + char *error = NULL; + for (int i = 0; i < fileNames.size(); ++i) { + fileNamePtr = fileNames.at(i).toLocal8Bit(); + parse_file(fileNamePtr.data(), &error); + if (error != NULL) { + showError(error); + free(error); + error = NULL; + } + } + process_dives(TRUE, FALSE); + + ui->InfoWidget->reload(); + ui->globe->reload(); + ui->ListWidget->reload(DiveTripModel::TREE); + ui->ListWidget->setFocus(); + WSInfoModel *wsim = WSInfoModel::instance(); + wsim->updateInfo(); +} + +void MainWindow::loadFiles(const QStringList fileNames) +{ + char *error = NULL; + QByteArray fileNamePtr; + + for (int i = 0; i < fileNames.size(); ++i) { + fileNamePtr = fileNames.at(i).toLocal8Bit(); + parse_file(fileNamePtr.data(), &error); + set_filename(fileNamePtr.data(), TRUE); + setTitle(MWTF_FILENAME); + + if (error != NULL) { + showError(error); + free(error); + } + } + + process_dives(FALSE, FALSE); + + ui->InfoWidget->reload(); + ui->globe->reload(); + ui->ListWidget->reload(DiveTripModel::TREE); + ui->ListWidget->setFocus(); + WSInfoModel *wsim = WSInfoModel::instance(); + wsim->updateInfo(); +} |