diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 155 | ||||
-rw-r--r-- | qt-ui/diveplanner.cpp | 6 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 31 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 5 | ||||
-rw-r--r-- | qt-ui/plannerSettings.ui | 3 | ||||
-rw-r--r-- | qt-ui/printdialog.cpp | 20 | ||||
-rw-r--r-- | qt-ui/printoptions.cpp | 63 | ||||
-rw-r--r-- | qt-ui/printoptions.h | 1 | ||||
-rw-r--r-- | qt-ui/templateedit.cpp | 7 |
9 files changed, 202 insertions, 89 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 3a3402371..39bcc3423 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -614,31 +614,64 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) resultModel->setData(resultModel->index(0, i),headers.at(i),Qt::EditRole); } +char *intdup(int index) +{ + char tmpbuf[21]; + + snprintf(tmpbuf, sizeof(tmpbuf) - 2, "%d", index); + tmpbuf[20] = 0; + return strdup(tmpbuf); +} + void DiveLogImportDialog::on_buttonBox_accepted() { QStringList r = resultModel->result(); if (ui->knownImports->currentText() != "Manual import") { for (int i = 0; i < fileNames.size(); ++i) { if (ui->knownImports->currentText() == "Seabear CSV") { + char *params[40]; + int pnr = 0; + + params[pnr++] = strdup("timeField"); + params[pnr++] = intdup(r.indexOf(tr("Sample time"))); + params[pnr++] = strdup("depthField"); + params[pnr++] = intdup(r.indexOf(tr("Sample depth"))); + params[pnr++] = strdup("tempField"); + params[pnr++] = intdup(r.indexOf(tr("Sample temperature"))); + params[pnr++] = strdup("po2Field"); + params[pnr++] = intdup(r.indexOf(tr("Sample pO₂"))); + params[pnr++] = strdup("o2sensor1Field"); + params[pnr++] = intdup(r.indexOf(tr("Sample sensor1 pO₂"))); + params[pnr++] = strdup("o2sensor2Field"); + params[pnr++] = intdup(r.indexOf(tr("Sample sensor2 pO₂"))); + params[pnr++] = strdup("o2sensor3Field"); + params[pnr++] = intdup(r.indexOf(tr("Sample sensor3 pO₂"))); + params[pnr++] = strdup("cnsField"); + params[pnr++] = intdup(r.indexOf(tr("Sample CNS"))); + params[pnr++] = strdup("ndlField"); + params[pnr++] = intdup(r.indexOf(tr("Sample NDL"))); + params[pnr++] = strdup("ttsField"); + params[pnr++] = intdup(r.indexOf(tr("Sample TTS"))); + params[pnr++] = strdup("stopdepthField"); + params[pnr++] = intdup(r.indexOf(tr("Sample stopdepth"))); + params[pnr++] = strdup("pressureField"); + params[pnr++] = intdup(r.indexOf(tr("Sample pressure"))); + params[pnr++] = strdup("setpointFiend"); + params[pnr++] = intdup(-1); + params[pnr++] = strdup("separatorIndex"); + params[pnr++] = intdup(ui->CSVSeparator->currentIndex()); + params[pnr++] = strdup("units"); + params[pnr++] = intdup(ui->CSVUnits->currentIndex()); + params[pnr++] = strdup("delta"); + params[pnr++] = strdup(delta.toUtf8().data()); + if (hw.length()) { + params[pnr++] = strdup("hw"); + params[pnr++] = strdup(hw.toUtf8().data()); + } + params[pnr++] = NULL; + if (parse_seabear_csv_file(fileNames[i].toUtf8().data(), - r.indexOf(tr("Sample time")), - r.indexOf(tr("Sample depth")), - r.indexOf(tr("Sample temperature")), - r.indexOf(tr("Sample pO₂")), - r.indexOf(tr("Sample sensor1 pO₂")), - r.indexOf(tr("Sample sensor2 pO₂")), - r.indexOf(tr("Sample sensor3 pO₂")), - r.indexOf(tr("Sample CNS")), - r.indexOf(tr("Sample NDL")), - r.indexOf(tr("Sample TTS")), - r.indexOf(tr("Sample stopdepth")), - r.indexOf(tr("Sample pressure")), - ui->CSVSeparator->currentIndex(), - "csv", - ui->CSVUnits->currentIndex(), - delta.toUtf8().data(), - hw.toUtf8().data() - ) < 0) { + params, pnr - 1, "csv") < 0) { return; } // Seabear CSV stores NDL and TTS in Minutes, not seconds @@ -672,35 +705,63 @@ void DiveLogImportDialog::on_buttonBox_accepted() } } else { for (int i = 0; i < fileNames.size(); ++i) { - if (r.indexOf(tr("Sample time")) < 0) - parse_manual_file(fileNames[i].toUtf8().data(), - ui->CSVSeparator->currentIndex(), - ui->CSVUnits->currentIndex(), - ui->DateFormat->currentIndex(), - ui->DurationFormat->currentIndex(), - r.indexOf(tr("Dive #")), - r.indexOf(tr("Date")), - r.indexOf(tr("Time")), - r.indexOf(tr("Duration")), - r.indexOf(tr("Location")), - r.indexOf(tr("GPS")), - r.indexOf(tr("Max. depth")), - r.indexOf(tr("Avg. depth")), - r.indexOf(tr("Divemaster")), - r.indexOf(tr("Buddy")), - r.indexOf(tr("Suit")), - r.indexOf(tr("Notes")), - r.indexOf(tr("Weight")), - r.indexOf(tr("Tags")), - r.indexOf(tr("Cyl. size")), - r.indexOf(tr("Start pressure")), - r.indexOf(tr("End pressure")), - r.indexOf(tr("O₂")), - r.indexOf(tr("He")), - r.indexOf(tr("Air temp.")), - r.indexOf(tr("Water temp.")) - ); - else + if (r.indexOf(tr("Sample time")) < 0) { + char *params[55]; + int pnr = 0; + params[pnr++] = strdup("numberField"); + params[pnr++] = intdup(r.indexOf(tr("Dive #"))); + params[pnr++] = strdup("dateField"); + params[pnr++] = intdup(r.indexOf(tr("Date"))); + params[pnr++] = strdup("timeField"); + params[pnr++] = intdup(r.indexOf(tr("Time"))); + params[pnr++] = strdup("durationField"); + params[pnr++] = intdup(r.indexOf(tr("Duration"))); + params[pnr++] = strdup("locationField"); + params[pnr++] = intdup(r.indexOf(tr("Location"))); + params[pnr++] = strdup("gpsField"); + params[pnr++] = intdup(r.indexOf(tr("GPS"))); + params[pnr++] = strdup("maxDepthField"); + params[pnr++] = intdup(r.indexOf(tr("Max. depth"))); + params[pnr++] = strdup("meanDepthField"); + params[pnr++] = intdup(r.indexOf(tr("Avg. depth"))); + params[pnr++] = strdup("divemasterField"); + params[pnr++] = intdup(r.indexOf(tr("Divemaster"))); + params[pnr++] = strdup("buddyField"); + params[pnr++] = intdup(r.indexOf(tr("Buddy"))); + params[pnr++] = strdup("suitField"); + params[pnr++] = intdup(r.indexOf(tr("Suit"))); + params[pnr++] = strdup("notesField"); + params[pnr++] = intdup(r.indexOf(tr("Notes"))); + params[pnr++] = strdup("weightField"); + params[pnr++] = intdup(r.indexOf(tr("Weight"))); + params[pnr++] = strdup("tagsField"); + params[pnr++] = intdup(r.indexOf(tr("Tags"))); + params[pnr++] = strdup("separatorIndex"); + params[pnr++] = intdup(ui->CSVSeparator->currentIndex()); + params[pnr++] = strdup("units"); + params[pnr++] = intdup(ui->CSVUnits->currentIndex()); + params[pnr++] = strdup("datefmt"); + params[pnr++] = intdup(ui->DateFormat->currentIndex()); + params[pnr++] = strdup("durationfmt"); + params[pnr++] = intdup(ui->DurationFormat->currentIndex()); + params[pnr++] = strdup("cylindersizeField"); + params[pnr++] = intdup(r.indexOf(tr("Cyl. size"))); + params[pnr++] = strdup("startpressureField"); + params[pnr++] = intdup(r.indexOf(tr("Start pressure"))); + params[pnr++] = strdup("endpressureField"); + params[pnr++] = intdup(r.indexOf(tr("End pressure"))); + params[pnr++] = strdup("o2Field"); + params[pnr++] = intdup(r.indexOf(tr("O₂"))); + params[pnr++] = strdup("heField"); + params[pnr++] = intdup(r.indexOf(tr("He"))); + params[pnr++] = strdup("airtempField"); + params[pnr++] = intdup(r.indexOf(tr("Air temp."))); + params[pnr++] = strdup("watertempField"); + params[pnr++] = intdup(r.indexOf(tr("Water temp."))); + params[pnr++] = NULL; + + parse_manual_file(fileNames[i].toUtf8().data(), params, pnr - 1); + } else parse_csv_file(fileNames[i].toUtf8().data(), r.indexOf(tr("Sample time")), r.indexOf(tr("Sample depth")), diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 82ecb05dc..7f0d129a2 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -228,6 +228,8 @@ void PlannerSettingsWidget::disableDecoElements(int mode) ui.decopo2->setDisabled(true); ui.reserve_gas->setDisabled(false); ui.conservatism_lvl->setDisabled(true); + ui.switch_at_req_stop->setDisabled(true); + ui.min_switch_duration->setDisabled(true); } else if (mode == VPMB) { ui.gflow->setDisabled(true); @@ -238,6 +240,8 @@ void PlannerSettingsWidget::disableDecoElements(int mode) ui.decopo2->setDisabled(false); ui.reserve_gas->setDisabled(true); ui.conservatism_lvl->setDisabled(false); + ui.switch_at_req_stop->setDisabled(false); + ui.min_switch_duration->setDisabled(false); } else if (mode == BUEHLMANN) { ui.gflow->setDisabled(false); @@ -248,6 +252,8 @@ void PlannerSettingsWidget::disableDecoElements(int mode) ui.decopo2->setDisabled(false); ui.reserve_gas->setDisabled(true); ui.conservatism_lvl->setDisabled(true); + ui.switch_at_req_stop->setDisabled(false); + ui.min_switch_duration->setDisabled(false); } } diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 4d416d2be..7593caf47 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -58,7 +58,8 @@ MainWindow::MainWindow() : QMainWindow(), actionPreviousDive(0), helpView(0), state(VIEWALL), - survey(0) + survey(0), + spinner(0) { Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!"); m_Instance = this; @@ -374,6 +375,7 @@ void MainWindow::on_actionCloudstorageopen_triggered() int error; + startSpinner(); QByteArray fileNamePtr = QFile::encodeName(filename); error = parse_file(fileNamePtr.data()); if (!error) { @@ -382,6 +384,7 @@ void MainWindow::on_actionCloudstorageopen_triggered() } getNotificationWidget()->hideNotification(); process_dives(false, false); + stopSpinner(); refreshDisplay(); ui.actionAutoGroup->setChecked(autogroup); } @@ -397,10 +400,15 @@ void MainWindow::on_actionCloudstoragesave_triggered() if (information()->isEditing()) information()->acceptChanges(); + startSpinner(); + if (save_dives(filename.toUtf8().data())) { getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error); return; } + + stopSpinner(); + getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error); set_filename(filename.toUtf8().data(), true); setTitle(MWTF_FILENAME); @@ -1762,3 +1770,24 @@ void MainWindow::setApplicationState(const QByteArray& state) { } #undef SET_CURRENT_INDEX } + +void MainWindow::startSpinner() +{ + if (!spinner) { + spinner = new QtWaitingSpinner(Qt::WindowModal, this, true); + spinner->setRevolutionsPerSecond(1); + spinner->setColor(WHITE1); + spinner->setLineWidth(7); + spinner->setRoundness(40.0); + spinner->setMinimumTrailOpacity(0.25); + } + int shorterEdge = MIN(this->geometry().height(), this->geometry().width()); + spinner->setInnerRadius(shorterEdge / 12); + spinner->setLineLength(shorterEdge / 8); + spinner->start(); +} + +void MainWindow::stopSpinner() +{ + spinner->stop(); +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 226e9b6ee..759132146 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -15,6 +15,7 @@ #include "ui_mainwindow.h" #include "notificationwidget.h" #include "windowtitleupdate.h" +#include "qtwaitingspinner.h" struct DiveList; class QSortFilterProxyModel; @@ -189,7 +190,8 @@ slots: void planCreated(); void setEnabledToolbar(bool arg1); void setPlanNotes(); - + void startSpinner(); + void stopSpinner(); private: Ui::MainWindow ui; @@ -244,6 +246,7 @@ private: QHash<QByteArray, PropertiesForQuadrant> stateProperties; WindowTitleUpdate *wtu; + QtWaitingSpinner *spinner; }; #endif // MAINWINDOW_H diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui index 4ebc868af..54ea5762c 100644 --- a/qt-ui/plannerSettings.ui +++ b/qt-ui/plannerSettings.ui @@ -491,6 +491,9 @@ <property name="text"> <string>Conservatism level</string> </property> + <property name="indent"> + <number>25</number> + </property> </widget> </item> <item row="12" column="2"> diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp index 002f9b9f4..cf08062d2 100644 --- a/qt-ui/printdialog.cpp +++ b/qt-ui/printdialog.cpp @@ -178,15 +178,8 @@ void PrintDialog::printClicked(void) { QPrintDialog printDialog(&qprinter, this); if (printDialog.exec() == QDialog::Accepted) { - switch (printOptions.type) { - case print_options::DIVELIST: - connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); - printer->print(); - break; - case print_options::STATISTICS: - printer->print_statistics(); - break; - } + connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); + printer->print(); close(); } } @@ -194,14 +187,7 @@ void PrintDialog::printClicked(void) void PrintDialog::onPaintRequested(QPrinter *printerPtr) { connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); - switch (printOptions.type) { - case print_options::DIVELIST: - printer->print(); - break; - case print_options::STATISTICS: - printer->print_statistics(); - break; - } + printer->print(); progressBar->setValue(0); disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int))); } diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp index 419098cf8..cb944f9d7 100644 --- a/qt-ui/printoptions.cpp +++ b/qt-ui/printoptions.cpp @@ -31,21 +31,7 @@ void PrintOptions::setup() break; } - // insert existing templates in the UI and select the current template - qSort(grantlee_templates); - int current_index = 0, index = 0; - for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { - if ((*i).compare(printOptions->p_template) == 0) { - current_index = index; - break; - } - index++; - } - ui.printTemplate->clear(); - for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { - ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); - } - ui.printTemplate->setCurrentIndex(current_index); + setupTemplates(); // general print option checkboxes if (printOptions->color_selected) @@ -63,6 +49,43 @@ void PrintOptions::setup() hasSetupSlots = true; } +void PrintOptions::setupTemplates() +{ + if (printOptions->type == print_options::DIVELIST) { + // insert dive list templates in the UI and select the current template + qSort(grantlee_templates); + int current_index = 0, index = 0; + for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + if ((*i).compare(printOptions->p_template) == 0) { + current_index = index; + break; + } + index++; + } + ui.printTemplate->clear(); + for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) { + ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); + } + ui.printTemplate->setCurrentIndex(current_index); + } else if (printOptions->type == print_options::STATISTICS) { + // insert statistics templates in the UI and select the current template + qSort(grantlee_statistics_templates); + int current_index = 0, index = 0; + for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) { + if ((*i).compare(printOptions->p_template) == 0) { + current_index = index; + break; + } + index++; + } + ui.printTemplate->clear(); + for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) { + ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i)); + } + ui.printTemplate->setCurrentIndex(current_index); + } +} + // print type radio buttons void PrintOptions::on_radioDiveListPrint_toggled(bool check) { @@ -70,15 +93,14 @@ void PrintOptions::on_radioDiveListPrint_toggled(bool check) printOptions->type = print_options::DIVELIST; // print options - ui.printInColor->setEnabled(true); ui.printSelected->setEnabled(true); // print template ui.deleteButton->setEnabled(true); - ui.editButton->setEnabled(true); ui.exportButton->setEnabled(true); ui.importButton->setEnabled(true); - ui.printTemplate->setEnabled(true); + + setupTemplates(); } } @@ -88,15 +110,14 @@ void PrintOptions::on_radioStatisticsPrint_toggled(bool check) printOptions->type = print_options::STATISTICS; // print options - ui.printInColor->setEnabled(false); ui.printSelected->setEnabled(false); // print template ui.deleteButton->setEnabled(false); - ui.editButton->setEnabled(false); ui.exportButton->setEnabled(false); ui.importButton->setEnabled(false); - ui.printTemplate->setEnabled(false); + + setupTemplates(); } } diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h index 6d7ffffee..9c50b10f3 100644 --- a/qt-ui/printoptions.h +++ b/qt-ui/printoptions.h @@ -70,6 +70,7 @@ private: struct print_options *printOptions; struct template_options *templateOptions; bool hasSetupSlots; + void setupTemplates(); private slots: diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp index e4e6453ac..b50338090 100644 --- a/qt-ui/templateedit.cpp +++ b/qt-ui/templateedit.cpp @@ -35,6 +35,9 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions, ui->plainTextEdit->setPlainText(grantlee_template); editingCustomColors = false; + if (printOptions->type == print_options::STATISTICS) { + ui->plainTextEdit->setEnabled(false); + } updatePreview(); } @@ -125,8 +128,8 @@ void TemplateEdit::saveSettings() if (msgBox.exec() == QMessageBox::Save) { memcpy(templateOptions, &newTemplateOptions, sizeof(struct template_options)); if (grantlee_template.compare(ui->plainTextEdit->toPlainText())) { - printOptions->p_template = "custom.html"; - TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText()); + printOptions->p_template = "Custom.html"; + TemplateLayout::writeTemplate("Custom.html", ui->plainTextEdit->toPlainText()); } if (templateOptions->color_palette_index == CUSTOM) { custom_colors = templateOptions->color_palette; |