aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-10-03 11:54:25 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-03 12:13:48 -0700
commit8e81d3f10087fa7ac600dcb18cfebf27716c4209 (patch)
tree3f6fc136134fe7d4f14937617c29e380e7c6e124
parentf0f76056ac3982783ab3dfe94d77ba5d25e19957 (diff)
downloadsubsurface-8e81d3f10087fa7ac600dcb18cfebf27716c4209.tar.gz
Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of overhead. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/about.cpp9
-rw-r--r--qt-ui/about.h2
-rw-r--r--qt-ui/divecomputermanagementdialog.cpp11
-rw-r--r--qt-ui/divecomputermanagementdialog.h2
-rw-r--r--qt-ui/diveplanner.cpp48
-rw-r--r--qt-ui/diveplanner.h2
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp92
-rw-r--r--qt-ui/downloadfromdivecomputer.h2
-rw-r--r--qt-ui/maintab.cpp469
-rw-r--r--qt-ui/maintab.h2
-rw-r--r--qt-ui/mainwindow.cpp158
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/preferences.cpp191
-rw-r--r--qt-ui/preferences.h2
-rw-r--r--qt-ui/printoptions.cpp49
-rw-r--r--qt-ui/printoptions.h2
-rw-r--r--qt-ui/simplewidgets.cpp10
-rw-r--r--qt-ui/simplewidgets.h6
-rw-r--r--qt-ui/subsurfacewebservices.cpp46
-rw-r--r--qt-ui/subsurfacewebservices.h9
-rw-r--r--qt-ui/tableview.cpp37
-rw-r--r--qt-ui/tableview.h2
22 files changed, 572 insertions, 581 deletions
diff --git a/qt-ui/about.cpp b/qt-ui/about.cpp
index 56fae4b03..835c22c94 100644
--- a/qt-ui/about.cpp
+++ b/qt-ui/about.cpp
@@ -13,17 +13,16 @@ SubsurfaceAbout *SubsurfaceAbout::instance()
}
SubsurfaceAbout::SubsurfaceAbout(QWidget* parent, Qt::WindowFlags f)
-: ui( new Ui::SubsurfaceAbout())
{
- ui->setupUi(this);
- ui->aboutLabel->setText(tr("<span style='font-size: 18pt; font-weight: bold;'>" \
+ ui.setupUi(this);
+ ui.aboutLabel->setText(tr("<span style='font-size: 18pt; font-weight: bold;'>" \
"Subsurface " VERSION_STRING "</span><br><br>" \
"Multi-platform divelog software in C<br>" \
"<span style='font-size: 8pt'>Linus Torvalds, Dirk Hohndel, and others, 2011, 2012, 2013</span>"));
licenseButton = new QPushButton(tr("&License"));
websiteButton = new QPushButton(tr("&Website"));
- ui->buttonBox->addButton(licenseButton, QDialogButtonBox::ActionRole);
- ui->buttonBox->addButton(websiteButton, QDialogButtonBox::ActionRole);
+ ui.buttonBox->addButton(licenseButton, QDialogButtonBox::ActionRole);
+ ui.buttonBox->addButton(websiteButton, QDialogButtonBox::ActionRole);
connect(licenseButton, SIGNAL(clicked(bool)), this, SLOT(licenseClicked()));
connect(websiteButton, SIGNAL(clicked(bool)), this, SLOT(websiteClicked()));
}
diff --git a/qt-ui/about.h b/qt-ui/about.h
index 2e6db600d..06dc30c87 100644
--- a/qt-ui/about.h
+++ b/qt-ui/about.h
@@ -17,7 +17,7 @@ private:
explicit SubsurfaceAbout(QWidget* parent = 0, Qt::WindowFlags f = 0);
QPushButton *licenseButton;
QPushButton *websiteButton;
- Ui::SubsurfaceAbout *ui;
+ Ui::SubsurfaceAbout ui;
};
#endif
diff --git a/qt-ui/divecomputermanagementdialog.cpp b/qt-ui/divecomputermanagementdialog.cpp
index 946481087..77a046d1a 100644
--- a/qt-ui/divecomputermanagementdialog.cpp
+++ b/qt-ui/divecomputermanagementdialog.cpp
@@ -6,12 +6,11 @@
#include "../helpers.h"
DiveComputerManagementDialog::DiveComputerManagementDialog(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f),
- ui( new Ui::DiveComputerManagementDialog()),
model(0)
{
- ui->setupUi(this);
+ ui.setupUi(this);
init();
- connect(ui->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(tryRemove(QModelIndex)));
+ connect(ui.tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(tryRemove(QModelIndex)));
}
void DiveComputerManagementDialog::init()
@@ -19,7 +18,7 @@ void DiveComputerManagementDialog::init()
if (model)
delete model;
model = new DiveComputerModel(dcList.dcMap);
- ui->tableView->setModel(model);
+ ui.tableView->setModel(model);
}
DiveComputerManagementDialog* DiveComputerManagementDialog::instance()
@@ -32,8 +31,8 @@ DiveComputerManagementDialog* DiveComputerManagementDialog::instance()
void DiveComputerManagementDialog::update()
{
model->update();
- ui->tableView->resizeColumnsToContents();
- ui->tableView->setColumnWidth(DiveComputerModel::REMOVE, 22);
+ ui.tableView->resizeColumnsToContents();
+ ui.tableView->setColumnWidth(DiveComputerModel::REMOVE, 22);
layout()->activate();
}
diff --git a/qt-ui/divecomputermanagementdialog.h b/qt-ui/divecomputermanagementdialog.h
index 85b9cb713..628c62ba2 100644
--- a/qt-ui/divecomputermanagementdialog.h
+++ b/qt-ui/divecomputermanagementdialog.h
@@ -21,7 +21,7 @@ public slots:
private:
explicit DiveComputerManagementDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
- Ui::DiveComputerManagementDialog *ui;
+ Ui::DiveComputerManagementDialog ui;
DiveComputerModel *model;
};
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 12b2d54e9..917863968 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -855,37 +855,37 @@ void Button::mousePressEvent(QGraphicsSceneMouseEvent* event)
emit clicked();
}
-DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f), ui(new Ui::DivePlanner())
-{
- ui->setupUi(this);
- ui->tableWidget->setTitle(tr("Dive Planner Points"));
- ui->tableWidget->setModel(DivePlannerPointsModel::instance());
- ui->tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
-
- connect(ui->tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
- connect(ui->startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
- connect(ui->ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
- connect(ui->bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString)));
- connect(ui->decoStopSAC, SIGNAL(textChanged(QString)), this, SLOT(decoSacChanged(QString)));
- connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
- connect(ui->lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
- connect(ui->highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
- connect(ui->lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
+DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
+{
+ ui.setupUi(this);
+ ui.tableWidget->setTitle(tr("Dive Planner Points"));
+ ui.tableWidget->setModel(DivePlannerPointsModel::instance());
+ ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
+
+ connect(ui.tableWidget, SIGNAL(addButtonClicked()), DivePlannerPointsModel::instance(), SLOT(addStop()));
+ connect(ui.startTime, SIGNAL(timeChanged(QTime)), this, SLOT(startTimeChanged(QTime)));
+ connect(ui.ATMPressure, SIGNAL(textChanged(QString)), this, SLOT(atmPressureChanged(QString)));
+ connect(ui.bottomSAC, SIGNAL(textChanged(QString)), this, SLOT(bottomSacChanged(QString)));
+ connect(ui.decoStopSAC, SIGNAL(textChanged(QString)), this, SLOT(decoSacChanged(QString)));
+ connect(ui.highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
+ connect(ui.lowGF, SIGNAL(textChanged(QString)), this, SLOT(gflowChanged(QString)));
+ connect(ui.highGF, SIGNAL(textChanged(QString)), this, SLOT(gfhighChanged(QString)));
+ connect(ui.lastStop, SIGNAL(toggled(bool)), this, SLOT(lastStopChanged(bool)));
// Creating the plan
- connect(ui->buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
- connect(ui->buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
+ connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan()));
+ connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
connect(plannerModel, SIGNAL(planCreated()), mainWindow(), SLOT(showProfile()));
connect(plannerModel, SIGNAL(planCreated()), mainWindow(), SLOT(refreshDisplay()));
connect(plannerModel, SIGNAL(planCanceled()), mainWindow(), SLOT(showProfile()));
/* set defaults. */
- ui->startTime->setTime( QTime(1, 0) );
- ui->ATMPressure->setText( "1013" );
- ui->bottomSAC->setText("20");
- ui->decoStopSAC->setText("17");
- ui->lowGF->setText("30");
- ui->highGF->setText("75");
+ ui.startTime->setTime( QTime(1, 0) );
+ ui.ATMPressure->setText( "1013" );
+ ui.bottomSAC->setText("20");
+ ui.decoStopSAC->setText("17");
+ ui.lowGF->setText("30");
+ ui.highGF->setText("75");
setMinimumWidth(0);
setMinimumHeight(0);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 7d9bb9188..ee81c6996 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -216,7 +216,7 @@ public slots:
void gfhighChanged(const QString& gfhigh);
void lastStopChanged(bool checked);
private:
- Ui::DivePlanner *ui;
+ Ui::DivePlanner ui;
};
#endif
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index c10ec90be..a481b56c1 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -43,28 +43,28 @@ DownloadFromDCWidget *DownloadFromDCWidget::instance()
}
DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
- QDialog(parent, f), ui(new Ui::DownloadFromDiveComputer), thread(0), timer(new QTimer(this)),
+ QDialog(parent, f), thread(0), timer(new QTimer(this)),
currentState(INITIAL)
{
- ui->setupUi(this);
- ui->progressBar->hide();
- ui->progressBar->setMinimum(0);
- ui->progressBar->setMaximum(100);
+ ui.setupUi(this);
+ ui.progressBar->hide();
+ ui.progressBar->setMinimum(0);
+ ui.progressBar->setMaximum(100);
fill_device_list();
fill_computer_list();
vendorModel = new QStringListModel(vendorList);
- ui->vendor->setModel(vendorModel);
+ ui.vendor->setModel(vendorModel);
if (default_dive_computer_vendor) {
- ui->vendor->setCurrentIndex(ui->vendor->findText(default_dive_computer_vendor));
+ ui.vendor->setCurrentIndex(ui.vendor->findText(default_dive_computer_vendor));
productModel = new QStringListModel(productList[default_dive_computer_vendor]);
- ui->product->setModel(productModel);
+ ui.product->setModel(productModel);
if (default_dive_computer_product)
- ui->product->setCurrentIndex(ui->product->findText(default_dive_computer_product));
+ ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product));
}
if (default_dive_computer_device)
- ui->device->setEditText(default_dive_computer_device);
+ ui.device->setEditText(default_dive_computer_device);
timer->setInterval(200);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar()));
@@ -81,7 +81,7 @@ void DownloadFromDCWidget::runDialog()
void DownloadFromDCWidget::updateProgressBar()
{
- ui->progressBar->setValue(progress_bar_fraction *100);
+ ui.progressBar->setValue(progress_bar_fraction *100);
}
void DownloadFromDCWidget::updateState(states state)
@@ -91,7 +91,7 @@ void DownloadFromDCWidget::updateState(states state)
if (state == INITIAL) {
fill_device_list();
- ui->progressBar->hide();
+ ui.progressBar->hide();
markChildrenAsEnabled();
timer->stop();
}
@@ -99,7 +99,7 @@ void DownloadFromDCWidget::updateState(states state)
// tries to cancel an on going download
else if (currentState == DOWNLOADING && state == CANCELLING) {
import_thread_cancelled = true;
- ui->cancel->setEnabled(false);
+ ui.cancel->setEnabled(false);
}
// user pressed cancel but the application isn't doing anything.
@@ -114,15 +114,15 @@ void DownloadFromDCWidget::updateState(states state)
else if (currentState == CANCELLING && (state == DONE || state == CANCELLED)) {
timer->stop();
state = CANCELLED;
- ui->progressBar->setValue(0);
- ui->progressBar->hide();
+ ui.progressBar->setValue(0);
+ ui.progressBar->hide();
markChildrenAsEnabled();
}
// DOWNLOAD is finally done, close the dialog and go back to the main window
else if (currentState == DOWNLOADING && state == DONE) {
timer->stop();
- ui->progressBar->setValue(100);
+ ui.progressBar->setValue(100);
markChildrenAsEnabled();
accept();
}
@@ -130,8 +130,8 @@ void DownloadFromDCWidget::updateState(states state)
// DOWNLOAD is started.
else if (state == DOWNLOADING) {
timer->start();
- ui->progressBar->setValue(0);
- ui->progressBar->show();
+ ui.progressBar->setValue(0);
+ ui.progressBar->show();
markChildrenAsDisabled();
}
@@ -140,8 +140,8 @@ void DownloadFromDCWidget::updateState(states state)
QMessageBox::critical(this, tr("Error"), this->thread->error, QMessageBox::Ok);
markChildrenAsEnabled();
- ui->progressBar->hide();
- ui->ok->setText(tr("retry"));
+ ui.progressBar->hide();
+ ui.ok->setText(tr("retry"));
}
// properly updating the widget state
@@ -150,12 +150,12 @@ void DownloadFromDCWidget::updateState(states state)
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
{
- QAbstractItemModel *currentModel = ui->product->model();
+ QAbstractItemModel *currentModel = ui.product->model();
if (!currentModel)
return;
productModel = new QStringListModel(productList[vendor]);
- ui->product->setModel(productModel);
+ ui.product->setModel(productModel);
// Memleak - but deleting gives me a crash.
//currentModel->deleteLater();
@@ -219,12 +219,12 @@ void DownloadFromDCWidget::on_ok_clicked()
thread->deleteLater();
}
- data.devname = strdup(ui->device->currentText().toUtf8().data());
- data.vendor = strdup(ui->vendor->currentText().toUtf8().data());
- data.product = strdup(ui->product->currentText().toUtf8().data());
+ data.devname = strdup(ui.device->currentText().toUtf8().data());
+ data.vendor = strdup(ui.vendor->currentText().toUtf8().data());
+ data.product = strdup(ui.product->currentText().toUtf8().data());
- data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()];
- data.force_download = ui->forceDownload->isChecked();
+ data.descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
+ data.force_download = ui.forceDownload->isChecked();
data.deviceid = data.diveid = 0;
set_default_dive_computer(data.vendor, data.product);
set_default_dive_computer_device(data.devname);
@@ -242,7 +242,7 @@ void DownloadFromDCWidget::on_ok_clicked()
bool DownloadFromDCWidget::preferDownloaded()
{
- return ui->preferDownloaded->isChecked();
+ return ui.preferDownloaded->isChecked();
}
void DownloadFromDCWidget::reject()
@@ -270,25 +270,25 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
void DownloadFromDCWidget::markChildrenAsDisabled()
{
- ui->device->setDisabled(true);
- ui->vendor->setDisabled(true);
- ui->product->setDisabled(true);
- ui->forceDownload->setDisabled(true);
- ui->preferDownloaded->setDisabled(true);
- ui->ok->setDisabled(true);
- ui->search->setDisabled(true);
+ ui.device->setDisabled(true);
+ ui.vendor->setDisabled(true);
+ ui.product->setDisabled(true);
+ ui.forceDownload->setDisabled(true);
+ ui.preferDownloaded->setDisabled(true);
+ ui.ok->setDisabled(true);
+ ui.search->setDisabled(true);
}
void DownloadFromDCWidget::markChildrenAsEnabled()
{
- ui->device->setDisabled(false);
- ui->vendor->setDisabled(false);
- ui->product->setDisabled(false);
- ui->forceDownload->setDisabled(false);
- ui->preferDownloaded->setDisabled(false);
- ui->ok->setDisabled(false);
- ui->cancel->setDisabled(false);
- ui->search->setDisabled(false);
+ ui.device->setDisabled(false);
+ ui.vendor->setDisabled(false);
+ ui.product->setDisabled(false);
+ ui.forceDownload->setDisabled(false);
+ ui.preferDownloaded->setDisabled(false);
+ ui.ok->setDisabled(false);
+ ui.cancel->setDisabled(false);
+ ui.search->setDisabled(false);
}
static void fillDeviceList(const char *name, void *data)
@@ -300,10 +300,10 @@ static void fillDeviceList(const char *name, void *data)
void DownloadFromDCWidget::fill_device_list()
{
int deviceIndex;
- ui->device->clear();
- deviceIndex = enumerate_devices(fillDeviceList, ui->device);
+ ui.device->clear();
+ deviceIndex = enumerate_devices(fillDeviceList, ui.device);
if (deviceIndex >= 0)
- ui->device->setCurrentIndex(deviceIndex);
+ ui.device->setCurrentIndex(deviceIndex);
}
DownloadThread::DownloadThread(QObject* parent, device_data_t* data): QThread(parent),
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index 2cd2975b3..2e6165635 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -51,7 +51,7 @@ private:
void markChildrenAsDisabled();
void markChildrenAsEnabled();
- Ui::DownloadFromDiveComputer *ui;
+ Ui::DownloadFromDiveComputer ui;
DownloadThread *thread;
bool downloading;
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e9fc2aea7..ae0de914f 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -24,20 +24,19 @@
#include <QPalette>
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
- ui(new Ui::MainTab()),
weightModel(new WeightModel()),
cylindersModel(new CylindersModel()),
editMode(NONE)
{
- ui->setupUi(this);
- ui->cylinders->setModel(cylindersModel);
- ui->weights->setModel(weightModel);
- ui->diveNotesMessage->hide();
- ui->diveEquipmentMessage->hide();
- ui->notesButtonBox->hide();
- ui->equipmentButtonBox->hide();
- ui->diveNotesMessage->setCloseButtonVisible(false);
- ui->diveEquipmentMessage->setCloseButtonVisible(false);
+ ui.setupUi(this);
+ ui.cylinders->setModel(cylindersModel);
+ ui.weights->setModel(weightModel);
+ ui.diveNotesMessage->hide();
+ ui.diveEquipmentMessage->hide();
+ ui.notesButtonBox->hide();
+ ui.equipmentButtonBox->hide();
+ ui.diveNotesMessage->setCloseButtonVisible(false);
+ ui.diveEquipmentMessage->setCloseButtonVisible(false);
if (qApp->style()->objectName() == "oxygen")
setDocumentMode(true);
@@ -48,50 +47,50 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
// filled from a dive, they are made writeable
setEnabled(false);
- ui->location->installEventFilter(this);
- ui->coordinates->installEventFilter(this);
- ui->divemaster->installEventFilter(this);
- ui->buddy->installEventFilter(this);
- ui->suit->installEventFilter(this);
- ui->notes->viewport()->installEventFilter(this);
- ui->rating->installEventFilter(this);
- ui->visibility->installEventFilter(this);
- ui->airtemp->installEventFilter(this);
- ui->watertemp->installEventFilter(this);
- ui->dateTimeEdit->installEventFilter(this);
-
- QList<QObject *> statisticsTabWidgets = ui->statisticsTab->children();
+ ui.location->installEventFilter(this);
+ ui.coordinates->installEventFilter(this);
+ ui.divemaster->installEventFilter(this);
+ ui.buddy->installEventFilter(this);
+ ui.suit->installEventFilter(this);
+ ui.notes->viewport()->installEventFilter(this);
+ ui.rating->installEventFilter(this);
+ ui.visibility->installEventFilter(this);
+ ui.airtemp->installEventFilter(this);
+ ui.watertemp->installEventFilter(this);
+ ui.dateTimeEdit->installEventFilter(this);
+
+ QList<QObject *> statisticsTabWidgets = ui.statisticsTab->children();
Q_FOREACH(QObject* obj, statisticsTabWidgets) {
QLabel* label = qobject_cast<QLabel *>(obj);
if (label)
label->setAlignment(Qt::AlignHCenter);
}
- ui->cylinders->setTitle(tr("Cylinders"));
- ui->cylinders->setBtnToolTip(tr("Add Cylinder"));
- connect(ui->cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked()));
-
- ui->weights->setTitle(tr("Weights"));
- ui->weights->setBtnToolTip(tr("Add Weight System"));
- connect(ui->weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked()));
-
- connect(ui->cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
- connect(ui->weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex)));
- connect(ui->notesButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
- connect(ui->notesButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
- connect(ui->equipmentButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
- connect(ui->equipmentButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
-
- ui->cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
- ui->weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
-
- completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui->buddy);
- completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui->divemaster);
- completers.location = new QCompleter(LocationCompletionModel::instance(), ui->location);
- completers.suit = new QCompleter(SuitCompletionModel::instance(), ui->suit);
- ui->buddy->setCompleter(completers.buddy);
- ui->divemaster->setCompleter(completers.divemaster);
- ui->location->setCompleter(completers.location);
- ui->suit->setCompleter(completers.suit);
+ ui.cylinders->setTitle(tr("Cylinders"));
+ ui.cylinders->setBtnToolTip(tr("Add Cylinder"));
+ connect(ui.cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked()));
+
+ ui.weights->setTitle(tr("Weights"));
+ ui.weights->setBtnToolTip(tr("Add Weight System"));
+ connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked()));
+
+ connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
+ connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex)));
+ connect(ui.notesButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
+ connect(ui.notesButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
+ connect(ui.equipmentButtonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
+ connect(ui.equipmentButtonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
+
+ ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate());
+ ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate());
+
+ completers.buddy = new QCompleter(BuddyCompletionModel::instance(), ui.buddy);
+ completers.divemaster = new QCompleter(DiveMasterCompletionModel::instance(), ui.divemaster);
+ completers.location = new QCompleter(LocationCompletionModel::instance(), ui.location);
+ completers.suit = new QCompleter(SuitCompletionModel::instance(), ui.suit);
+ ui.buddy->setCompleter(completers.buddy);
+ ui.divemaster->setCompleter(completers.divemaster);
+ ui.location->setCompleter(completers.location);
+ ui.suit->setCompleter(completers.suit);
setMinimumHeight(0);
setMinimumWidth(0);
@@ -101,10 +100,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
if (isGnome3Session()) {
QPalette p;
p.setColor(QPalette::Window, QColor(Qt::white));
- ui->scrollArea->viewport()->setPalette(p);
- ui->scrollArea_2->viewport()->setPalette(p);
- ui->scrollArea_3->viewport()->setPalette(p);
- ui->scrollArea_4->viewport()->setPalette(p);
+ ui.scrollArea->viewport()->setPalette(p);
+ ui.scrollArea_2->viewport()->setPalette(p);
+ ui.scrollArea_3->viewport()->setPalette(p);
+ ui.scrollArea_4->viewport()->setPalette(p);
}
}
@@ -122,23 +121,23 @@ void MainTab::enableEdition()
mainWindow()->dive_list()->setEnabled(false);
// We may be editing one or more dives here. backup everything.
notesBackup.clear();
- ui->notesButtonBox->show();
- ui->equipmentButtonBox->show();
+ ui.notesButtonBox->show();
+ ui.equipmentButtonBox->show();
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// we are editing trip location and notes
- ui->diveNotesMessage->setText(tr("This trip is being edited. Select Save or Undo when ready."));
- ui->diveNotesMessage->animatedShow();
- ui->diveEquipmentMessage->setText(tr("This trip is being edited. Select Save or Undo when ready."));
- ui->diveEquipmentMessage->animatedShow();
- notesBackup[NULL].notes = ui->notes->toPlainText();
- notesBackup[NULL].location = ui->location->text();
+ ui.diveNotesMessage->setText(tr("This trip is being edited. Select Save or Undo when ready."));
+ ui.diveNotesMessage->animatedShow();
+ ui.diveEquipmentMessage->setText(tr("This trip is being edited. Select Save or Undo when ready."));
+ ui.diveEquipmentMessage->animatedShow();
+ notesBackup[NULL].notes = ui.notes->toPlainText();
+ notesBackup[NULL].location = ui.location->text();
editMode = TRIP;
} else {
- ui->diveNotesMessage->setText(tr("This dive is being edited. Select Save or Undo when ready."));
- ui->diveNotesMessage->animatedShow();
- ui->diveEquipmentMessage->setText(tr("This dive is being edited. Select Save or Undo when ready."));
- ui->diveEquipmentMessage->animatedShow();
+ ui.diveNotesMessage->setText(tr("This dive is being edited. Select Save or Undo when ready."));
+ ui.diveNotesMessage->animatedShow();
+ ui.diveEquipmentMessage->setText(tr("This dive is being edited. Select Save or Undo when ready."));
+ ui.diveEquipmentMessage->animatedShow();
// We may be editing one or more dives here. backup everything.
struct dive *mydive;
@@ -158,7 +157,7 @@ void MainTab::enableEdition()
notesBackup[mydive].visibility = mydive->visibility;
notesBackup[mydive].latitude = mydive->latitude;
notesBackup[mydive].longitude = mydive->longitude;
- notesBackup[mydive].coordinates = ui->coordinates->text();
+ notesBackup[mydive].coordinates = ui.coordinates->text();
notesBackup[mydive].airtemp = get_temperature_string(mydive->airtemp, true);
notesBackup[mydive].watertemp = get_temperature_string(mydive->watertemp, true);
notesBackup[mydive].datetime = QDateTime::fromTime_t(mydive->when - gettimezoneoffset()).toString(QString("M/d/yy h:mm"));
@@ -177,12 +176,12 @@ void MainTab::enableEdition()
bool MainTab::eventFilter(QObject* object, QEvent* event)
{
- if (isEnabled() && event->type() == QEvent::KeyPress && object == ui->dateTimeEdit) {
+ if (isEnabled() && event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) {
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
enableEdition();
}
- if (isEnabled() && event->type() == QEvent::FocusIn && (object == ui->rating || object == ui->visibility)) {
+ if (isEnabled() && event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility)) {
tabBar()->setTabIcon(currentIndex(), QIcon(":warning"));
enableEdition();
}
@@ -200,41 +199,41 @@ void MainTab::clearEquipment()
void MainTab::clearInfo()
{
- ui->sacText->clear();
- ui->otuText->clear();
- ui->oxygenHeliumText->clear();
- ui->gasUsedText->clear();
- ui->dateText->clear();
- ui->diveTimeText->clear();
- ui->surfaceIntervalText->clear();
- ui->maximumDepthText->clear();
- ui->averageDepthText->clear();
- ui->waterTemperatureText->clear();
- ui->airTemperatureText->clear();
- ui->airPressureText->clear();
+ ui.sacText->clear();
+ ui.otuText->clear();
+ ui.oxygenHeliumText->clear();
+ ui.gasUsedText->clear();
+ ui.dateText->clear();
+ ui.diveTimeText->clear();
+ ui.surfaceIntervalText->clear();
+ ui.maximumDepthText->clear();
+ ui.averageDepthText->clear();
+ ui.waterTemperatureText->clear();
+ ui.airTemperatureText->clear();
+ ui.airPressureText->clear();
}
void MainTab::clearStats()
{
- ui->depthLimits->clear();
- ui->sacLimits->clear();
- ui->divesAllText->clear();
- ui->tempLimits->clear();
- ui->totalTimeAllText->clear();
- ui->timeLimits->clear();
+ ui.depthLimits->clear();
+ ui.sacLimits->clear();
+ ui.divesAllText->clear();
+ ui.tempLimits->clear();
+ ui.totalTimeAllText->clear();
+ ui.timeLimits->clear();
}
#define UPDATE_TEXT(d, field) \
if (!d || !d->field) \
- ui->field->setText(""); \
+ ui.field->setText(""); \
else \
- ui->field->setText(d->field)
+ ui.field->setText(d->field)
#define UPDATE_TEMP(d, field) \
if (!d || d->field.mkelvin == 0) \
- ui->field->setText(""); \
+ ui.field->setText(""); \
else \
- ui->field->setText(get_temperature_string(d->field, TRUE))
+ ui.field->setText(get_temperature_string(d->field, TRUE))
void MainTab::updateDiveInfo(int dive)
@@ -267,121 +266,121 @@ void MainTab::updateDiveInfo(int dive)
if (d) {
char buffer[256];
print_gps_coordinates(buffer, sizeof buffer, d->latitude.udeg, d->longitude.udeg);
- ui->coordinates->setText(buffer);
- ui->dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset()));
+ ui.coordinates->setText(buffer);
+ ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset()));
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// only use trip relevant fields
- ui->coordinates->setVisible(false);
- ui->divemaster->setVisible(false);
- ui->DivemasterLabel->setVisible(false);
- ui->buddy->setVisible(false);
- ui->BuddyLabel->setVisible(false);
- ui->suit->setVisible(false);
- ui->SuitLabel->setVisible(false);
- ui->rating->setVisible(false);
- ui->RatingLabel->setVisible(false);
- ui->visibility->setVisible(false);
- ui->visibilityLabel->setVisible(false);
+ ui.coordinates->setVisible(false);
+ ui.divemaster->setVisible(false);
+ ui.DivemasterLabel->setVisible(false);
+ ui.buddy->setVisible(false);
+ ui.BuddyLabel->setVisible(false);
+ ui.suit->setVisible(false);
+ ui.SuitLabel->setVisible(false);
+ ui.rating->setVisible(false);
+ ui.RatingLabel->setVisible(false);
+ ui.visibility->setVisible(false);
+ ui.visibilityLabel->setVisible(false);
// rename the remaining fields and fill data from selected trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
- ui->LocationLabel->setText(tr("Trip Location"));
- ui->location->setText(currentTrip->location);
- ui->NotesLabel->setText(tr("Trip Notes"));
- ui->notes->setText(currentTrip->notes);
+ ui.LocationLabel->setText(tr("Trip Location"));
+ ui.location->setText(currentTrip->location);
+ ui.NotesLabel->setText(tr("Trip Notes"));
+ ui.notes->setText(currentTrip->notes);
} else {
// make all the fields visible writeable
- ui->coordinates->setVisible(true);
- ui->divemaster->setVisible(true);
- ui->buddy->setVisible(true);
- ui->suit->setVisible(true);
- ui->SuitLabel->setVisible(true);
- ui->rating->setVisible(true);
- ui->RatingLabel->setVisible(true);
- ui->visibility->setVisible(true);
- ui->visibilityLabel->setVisible(true);
- ui->BuddyLabel->setVisible(true);
- ui->DivemasterLabel->setVisible(true);
+ ui.coordinates->setVisible(true);
+ ui.divemaster->setVisible(true);
+ ui.buddy->setVisible(true);
+ ui.suit->setVisible(true);
+ ui.SuitLabel->setVisible(true);
+ ui.rating->setVisible(true);
+ ui.RatingLabel->setVisible(true);
+ ui.visibility->setVisible(true);
+ ui.visibilityLabel->setVisible(true);
+ ui.BuddyLabel->setVisible(true);
+ ui.DivemasterLabel->setVisible(true);
/* and fill them from the dive */
- ui->rating->setCurrentStars(d->rating);
- ui->visibility->setCurrentStars(d->visibility);
+ ui.rating->setCurrentStars(d->rating);
+ ui.visibility->setCurrentStars(d->visibility);
// reset labels in case we last displayed trip notes
- ui->LocationLabel->setText(tr("Location"));
- ui->NotesLabel->setText(tr("Notes"));
+ ui.LocationLabel->setText(tr("Location"));
+ ui.NotesLabel->setText(tr("Notes"));
}
- ui->maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
- ui->averageDepthText->setText(get_depth_string(d->meandepth, TRUE));
- ui->otuText->setText(QString("%1").arg(d->otu));
- ui->waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
- ui->airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
- ui->gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE));
- ui->oxygenHeliumText->setText(get_gaslist(d));
- ui->dateText->setText(get_short_dive_date_string(d->when));
- ui->diveTimeText->setText(QString::number((int)((d->duration.seconds + 30) / 60)));
+ ui.maximumDepthText->setText(get_depth_string(d->maxdepth, TRUE));
+ ui.averageDepthText->setText(get_depth_string(d->meandepth, TRUE));
+ ui.otuText->setText(QString("%1").arg(d->otu));
+ ui.waterTemperatureText->setText(get_temperature_string(d->watertemp, TRUE));
+ ui.airTemperatureText->setText(get_temperature_string(d->airtemp, TRUE));
+ ui.gasUsedText->setText(get_volume_string(get_gas_used(d), TRUE));
+ ui.oxygenHeliumText->setText(get_gaslist(d));
+ ui.dateText->setText(get_short_dive_date_string(d->when));
+ ui.diveTimeText->setText(QString::number((int)((d->duration.seconds + 30) / 60)));
if (prevd)
- ui->surfaceIntervalText->setText(get_time_string(d->when - (prevd->when + prevd->duration.seconds), 4));
+ ui.surfaceIntervalText->setText(get_time_string(d->when - (prevd->when + prevd->duration.seconds), 4));
if ((sacVal.mliter = d->sac) > 0)
- ui->sacText->setText(get_volume_string(sacVal, TRUE).append(tr("/min")));
+ ui.sacText->setText(get_volume_string(sacVal, TRUE).append(tr("/min")));
else
- ui->sacText->clear();
+ ui.sacText->clear();
if (d->surface_pressure.mbar)
/* this is ALWAYS displayed in mbar */
- ui->airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
+ ui.airPressureText->setText(QString("%1mbar").arg(d->surface_pressure.mbar));
else
- ui->airPressureText->clear();
+ ui.airPressureText->clear();
(get_depth_string(stats_selection.max_depth, TRUE));
- ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE));
- ui->depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE));
- ui->sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, TRUE).append(tr("/min")));
- ui->sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, TRUE).append(tr("/min")));
- ui->sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, TRUE).append(tr("/min")));
- ui->divesAllText->setText(QString::number(stats_selection.selection_size));
+ ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, TRUE));
+ ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, TRUE));
+ ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, TRUE).append(tr("/min")));
+ ui.sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, TRUE).append(tr("/min")));
+ ui.sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, TRUE).append(tr("/min")));
+ ui.divesAllText->setText(QString::number(stats_selection.selection_size));
temp.mkelvin = stats_selection.max_temp;
- ui->tempLimits->setMaximum(get_temperature_string(temp, TRUE));
+ ui.tempLimits->setMaximum(get_temperature_string(temp, TRUE));
temp.mkelvin = stats_selection.min_temp;
- ui->tempLimits->setMinimum(get_temperature_string(temp, TRUE));
+ ui.tempLimits->setMinimum(get_temperature_string(temp, TRUE));
if (stats_selection.combined_temp && stats_selection.combined_count) {
const char *unit;
get_temp_units(0, &unit);
- ui->tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
+ ui.tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
}
- ui->totalTimeAllText->setText(get_time_string(stats_selection.total_time.seconds, 0));
+ ui.totalTimeAllText->setText(get_time_string(stats_selection.total_time.seconds, 0));
int seconds = stats_selection.total_time.seconds;
if (stats_selection.selection_size)
seconds /= stats_selection.selection_size;
- ui->timeLimits->setAverage(get_time_string(seconds, 0));
- ui->timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
- ui->timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
+ ui.timeLimits->setAverage(get_time_string(seconds, 0));
+ ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
+ ui.timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
multiEditEquipmentPlaceholder = *d;
cylindersModel->setDive(&multiEditEquipmentPlaceholder);
weightModel->setDive(&multiEditEquipmentPlaceholder);
} else {
/* clear the fields */
- ui->rating->setCurrentStars(0);
- ui->coordinates->clear();
- ui->sacText->clear();
- ui->otuText->clear();
- ui->oxygenHeliumText->clear();
- ui->dateText->clear();
- ui->diveTimeText->clear();
- ui->surfaceIntervalText->clear();
- ui->maximumDepthText->clear();
- ui->averageDepthText->clear();
- ui->visibility->setCurrentStars(0);
- ui->waterTemperatureText->clear();
- ui->airTemperatureText->clear();
- ui->gasUsedText->clear();
- ui->airPressureText->clear();
+ ui.rating->setCurrentStars(0);
+ ui.coordinates->clear();
+ ui.sacText->clear();
+ ui.otuText->clear();
+ ui.oxygenHeliumText->clear();
+ ui.dateText->clear();
+ ui.diveTimeText->clear();
+ ui.surfaceIntervalText->clear();
+ ui.maximumDepthText->clear();
+ ui.averageDepthText->clear();
+ ui.visibility->setCurrentStars(0);
+ ui.waterTemperatureText->clear();
+ ui.airTemperatureText->clear();
+ ui.gasUsedText->clear();
+ ui.airPressureText->clear();
cylindersModel->clear();
weightModel->clear();
- ui->depthLimits->clear();
- ui->sacLimits->clear();
- ui->divesAllText->clear();
- ui->tempLimits->clear();
- ui->totalTimeAllText->clear();
- ui->timeLimits->clear();
+ ui.depthLimits->clear();
+ ui.sacLimits->clear();
+ ui.divesAllText->clear();
+ ui.tempLimits->clear();
+ ui.totalTimeAllText->clear();
+ ui.timeLimits->clear();
/* turns out this is non-trivial for a dateTimeEdit... this is a partial hack */
- QLineEdit *le = ui->dateTimeEdit->findChild<QLineEdit*>();
+ QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit*>();
le->setText("");
}
}
@@ -413,14 +412,14 @@ void MainTab::acceptChanges()
mainWindow()->dive_list()->setEnabled(true);
tabBar()->setTabIcon(0, QIcon()); // Notes
tabBar()->setTabIcon(1, QIcon()); // Equipment
- ui->diveNotesMessage->animatedHide();
- ui->diveEquipmentMessage->animatedHide();
- ui->notesButtonBox->hide();
- ui->equipmentButtonBox->hide();
+ ui.diveNotesMessage->animatedHide();
+ ui.diveEquipmentMessage->animatedHide();
+ ui.notesButtonBox->hide();
+ ui.equipmentButtonBox->hide();
/* now figure out if things have changed */
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
- if (notesBackup[NULL].notes != ui->notes->toPlainText() ||
- notesBackup[NULL].location != ui->location->text())
+ if (notesBackup[NULL].notes != ui.notes->toPlainText() ||
+ notesBackup[NULL].location != ui.location->text())
mark_divelist_changed(TRUE);
} else {
struct dive *curr = current_dive;
@@ -428,22 +427,22 @@ void MainTab::acceptChanges()
char buffer[256];
print_gps_coordinates(buffer, sizeof buffer
, current_dive->latitude.udeg, current_dive->longitude.udeg);
- ui->coordinates->setText(buffer);
- if (notesBackup[curr].buddy != ui->buddy->text() ||
- notesBackup[curr].suit != ui->suit->text() ||
- notesBackup[curr].notes != ui->notes->toPlainText() ||
- notesBackup[curr].divemaster != ui->divemaster->text() ||
- notesBackup[curr].location != ui->location->text() ||
- notesBackup[curr].coordinates != ui->coordinates->text() ||
- notesBackup[curr].rating != ui->visibility->currentStars() ||
- notesBackup[curr].airtemp != ui->airtemp->text() ||
- notesBackup[curr].watertemp != ui->watertemp->text() ||
- notesBackup[curr].datetime != ui->dateTimeEdit->dateTime().toString(QString("M/d/yy h:mm")) ||
- notesBackup[curr].visibility != ui->rating->currentStars()) {
+ ui.coordinates->setText(buffer);
+ if (notesBackup[curr].buddy != ui.buddy->text() ||
+ notesBackup[curr].suit != ui.suit->text() ||
+ notesBackup[curr].notes != ui.notes->toPlainText() ||
+ notesBackup[curr].divemaster != ui.divemaster->text() ||
+ notesBackup[curr].location != ui.location->text() ||
+ notesBackup[curr].coordinates != ui.coordinates->text() ||
+ notesBackup[curr].rating != ui.visibility->currentStars() ||
+ notesBackup[curr].airtemp != ui.airtemp->text() ||
+ notesBackup[curr].watertemp != ui.watertemp->text() ||
+ notesBackup[curr].datetime != ui.dateTimeEdit->dateTime().toString(QString("M/d/yy h:mm")) ||
+ notesBackup[curr].visibility != ui.rating->currentStars()) {
mark_divelist_changed(TRUE);
}
- if (notesBackup[curr].location != ui->location->text() ||
- notesBackup[curr].coordinates != ui->coordinates->text()) {
+ if (notesBackup[curr].location != ui.location->text() ||
+ notesBackup[curr].coordinates != ui.coordinates->text()) {
mainWindow()->globe()->reload();
mainWindow()->globe()->centerOn(current_dive);
}
@@ -488,15 +487,15 @@ void MainTab::acceptChanges()
void MainTab::resetPallete()
{
QPalette p;
- ui->buddy->setPalette(p);
- ui->notes->setPalette(p);
- ui->location->setPalette(p);
- ui->coordinates->setPalette(p);
- ui->divemaster->setPalette(p);
- ui->suit->setPalette(p);
- ui->airtemp->setPalette(p);
- ui->watertemp->setPalette(p);
- ui->dateTimeEdit->setPalette(p);
+ ui.buddy->setPalette(p);
+ ui.notes->setPalette(p);
+ ui.location->setPalette(p);
+ ui.coordinates->setPalette(p);
+ ui.divemaster->setPalette(p);
+ ui.suit->setPalette(p);
+ ui.airtemp->setPalette(p);
+ ui.watertemp->setPalette(p);
+ ui.dateTimeEdit->setPalette(p);
}
@@ -517,8 +516,8 @@ void MainTab::rejectChanges()
mainWindow()->dive_list()->setEnabled(true);
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1){
- ui->notes->setText(notesBackup[NULL].notes );
- ui->location->setText(notesBackup[NULL].location);
+ ui.notes->setText(notesBackup[NULL].notes );
+ ui.location->setText(notesBackup[NULL].location);
}else{
if (editMode == ADD) {
// clean up
@@ -526,17 +525,17 @@ void MainTab::rejectChanges()
DivePlannerPointsModel::instance()->cancelPlan();
}
struct dive *curr = current_dive;
- ui->notes->setText(notesBackup[curr].notes );
- ui->location->setText(notesBackup[curr].location);
- ui->coordinates->setText(notesBackup[curr].coordinates);
- ui->buddy->setText(notesBackup[curr].buddy);
- ui->suit->setText(notesBackup[curr].suit);
- ui->divemaster->setText(notesBackup[curr].divemaster);
- ui->rating->setCurrentStars(notesBackup[curr].rating);
- ui->visibility->setCurrentStars(notesBackup[curr].visibility);
- ui->airtemp->setText(notesBackup[curr].airtemp);
- ui->watertemp->setText(notesBackup[curr].watertemp);
- ui->dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime, QString("M/d/y h:mm")));
+ ui.notes->setText(notesBackup[curr].notes );
+ ui.location->setText(notesBackup[curr].location);
+ ui.coordinates->setText(notesBackup[curr].coordinates);
+ ui.buddy->setText(notesBackup[curr].buddy);
+ ui.suit->setText(notesBackup[curr].suit);
+ ui.divemaster->setText(notesBackup[curr].divemaster);
+ ui.rating->setCurrentStars(notesBackup[curr].rating);
+ ui.visibility->setCurrentStars(notesBackup[curr].visibility);
+ ui.airtemp->setText(notesBackup[curr].airtemp);
+ ui.watertemp->setText(notesBackup[curr].watertemp);
+ ui.dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime, QString("M/d/y h:mm")));
struct dive *mydive;
for (int i = 0; i < dive_table.nr; i++) {
@@ -570,11 +569,11 @@ void MainTab::rejectChanges()
weightModel->setDive(&multiEditEquipmentPlaceholder);
}
- ui->diveNotesMessage->animatedHide();
- ui->diveEquipmentMessage->animatedHide();
+ ui.diveNotesMessage->animatedHide();
+ ui.diveEquipmentMessage->animatedHide();
mainWindow()->dive_list()->setEnabled(true);
- ui->notesButtonBox->hide();
- ui->equipmentButtonBox->hide();
+ ui.notesButtonBox->hide();
+ ui.equipmentButtonBox->hide();
notesBackup.clear();
resetPallete();
if (editMode == ADD) {
@@ -611,31 +610,31 @@ void markChangedWidget(QWidget *w){
void MainTab::on_buddy_textChanged(const QString& text)
{
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->buddy, text) );
- markChangedWidget(ui->buddy);
+ markChangedWidget(ui.buddy);
}
void MainTab::on_divemaster_textChanged(const QString& text)
{
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->divemaster, text) );
- markChangedWidget(ui->divemaster);
+ markChangedWidget(ui.divemaster);
}
void MainTab::on_airtemp_textChanged(const QString& text)
{
EDIT_SELECTED_DIVES( mydive->airtemp.mkelvin = parseTemperatureToMkelvin(text) );
- markChangedWidget(ui->airtemp);
+ markChangedWidget(ui.airtemp);
}
void MainTab::on_watertemp_textChanged(const QString& text)
{
EDIT_SELECTED_DIVES( mydive->watertemp.mkelvin = parseTemperatureToMkelvin(text) );
- markChangedWidget(ui->watertemp);
+ markChangedWidget(ui.watertemp);
}
void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime& datetime)
{
EDIT_SELECTED_DIVES( mydive->when = datetime.toTime_t() + gettimezoneoffset() );
- markChangedWidget(ui->dateTimeEdit);
+ markChangedWidget(ui.dateTimeEdit);
}
void MainTab::on_location_textChanged(const QString& text)
@@ -647,8 +646,8 @@ void MainTab::on_location_textChanged(const QString& text)
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->location, text);
} else if (editMode == DIVE || editMode == ADD){
- if (!ui->coordinates->isModified() ||
- ui->coordinates->text().trimmed().isEmpty()) {
+ if (!ui.coordinates->isModified() ||
+ ui.coordinates->text().trimmed().isEmpty()) {
struct dive* dive;
int i = 0;
for_each_dive(i, dive){
@@ -660,8 +659,8 @@ void MainTab::on_location_textChanged(const QString& text)
char buffer[256];
print_gps_coordinates(buffer, sizeof buffer
, dive->latitude.udeg, dive->longitude.udeg);
- ui->coordinates->setText(buffer);
- markChangedWidget(ui->coordinates);
+ ui.coordinates->setText(buffer);
+ markChangedWidget(ui.coordinates);
break;
}
}
@@ -669,13 +668,13 @@ void MainTab::on_location_textChanged(const QString& text)
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->location, text) );
}
- markChangedWidget(ui->location);
+ markChangedWidget(ui.location);
}
void MainTab::on_suit_textChanged(const QString& text)
{
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->suit, text) );
- markChangedWidget(ui->suit);
+ markChangedWidget(ui.suit);
}
void MainTab::on_notes_textChanged()
@@ -685,11 +684,11 @@ void MainTab::on_notes_textChanged()
if (editMode == TRIP && mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// we are editing a trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
- EDIT_TEXT(currentTrip->notes, ui->notes->toPlainText());
+ EDIT_TEXT(currentTrip->notes, ui.notes->toPlainText());
} else if (editMode == DIVE || editMode == ADD) {
- EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui->notes->toPlainText()) );
+ EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui.notes->toPlainText()) );
}
- markChangedWidget(ui->notes);
+ markChangedWidget(ui.notes);
}
#undef EDIT_TEXT
@@ -700,11 +699,11 @@ void MainTab::on_coordinates_textChanged(const QString& text)
gboolean gpsChanged = FALSE;
EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data()));
if (gpsChanged) {
- markChangedWidget(ui->coordinates);
+ markChangedWidget(ui.coordinates);
} else {
QPalette p;
p.setBrush(QPalette::Base, QColor(Qt::red).lighter());
- ui->coordinates->setPalette(p);
+ ui.coordinates->setPalette(p);
}
}
@@ -724,7 +723,7 @@ void MainTab::editCylinderWidget(const QModelIndex& index)
enableEdition();
if (index.isValid() && index.column() != CylindersModel::REMOVE)
- ui->cylinders->edit(index);
+ ui.cylinders->edit(index);
}
void MainTab::editWeigthWidget(const QModelIndex& index)
@@ -733,5 +732,5 @@ void MainTab::editWeigthWidget(const QModelIndex& index)
enableEdition();
if (index.isValid() && index.column() != WeightModel::REMOVE)
- ui->weights->edit(index);
+ ui.weights->edit(index);
}
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index f1a981517..8afa5ff02 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -76,7 +76,7 @@ public slots:
void addDiveStarted();
private:
- Ui::MainTab *ui;
+ Ui::MainTab ui;
WeightModel *weightModel;
CylindersModel *cylindersModel;
QMap<dive*, NotesBackup> notesBackup;
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index e32256982..9a26404e2 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -44,32 +44,32 @@ MainWindow* mainWindow()
return instance;
}
-MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0)
+MainWindow::MainWindow() : helpView(0)
{
instance = this;
- ui->setupUi(this);
+ ui.setupUi(this);
setWindowIcon(QIcon(":subsurface-icon"));
- connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
+ connect(ui.ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(update()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(reloadHeaderActions()));
- connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ProfileWidget, SLOT(refresh()));
- ui->mainErrorMessage->hide();
- ui->ListWidget->reload(DiveTripModel::TREE);
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update()));
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions()));
+ connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ProfileWidget, SLOT(refresh()));
+ ui.mainErrorMessage->hide();
+ ui.ListWidget->reload(DiveTripModel::TREE);
initialUiSetup();
readSettings();
- ui->ListWidget->reloadHeaderActions();
- ui->ListWidget->setFocus();
- ui->globe->reload();
+ ui.ListWidget->reloadHeaderActions();
+ ui.ListWidget->setFocus();
+ ui.globe->reload();
}
// this gets called after we download dives from a divecomputer
void MainWindow::refreshDisplay()
{
- ui->InfoWidget->reload();
- ui->globe->reload();
- ui->ListWidget->reload(DiveTripModel::TREE);
- ui->ListWidget->setFocus();
+ ui.InfoWidget->reload();
+ ui.globe->reload();
+ ui.ListWidget->reload(DiveTripModel::TREE);
+ ui.ListWidget->setFocus();
WSInfoModel *wsim = WSInfoModel::instance();
wsim->updateInfo();
}
@@ -78,15 +78,15 @@ void MainWindow::current_dive_changed(int divenr)
{
if (divenr >= 0) {
select_dive(divenr);
- ui->globe->centerOn(get_dive(selected_dive));
+ ui.globe->centerOn(get_dive(selected_dive));
redrawProfile();
}
- ui->InfoWidget->updateDiveInfo(divenr);
+ ui.InfoWidget->updateDiveInfo(divenr);
}
void MainWindow::redrawProfile()
{
- ui->ProfileWidget->refresh();
+ ui.ProfileWidget->refresh();
}
void MainWindow::on_actionNew_triggered()
@@ -136,13 +136,13 @@ void MainWindow::on_actionSaveAs_triggered()
void MainWindow::cleanUpEmpty()
{
- ui->InfoWidget->clearStats();
- ui->InfoWidget->clearInfo();
- ui->InfoWidget->clearEquipment();
- ui->InfoWidget->updateDiveInfo(-1);
- ui->ProfileWidget->clear();
- ui->ListWidget->reload(DiveTripModel::TREE);
- ui->globe->reload();
+ ui.InfoWidget->clearStats();
+ ui.InfoWidget->clearInfo();
+ ui.InfoWidget->clearEquipment();
+ ui.InfoWidget->updateDiveInfo(-1);
+ ui.ProfileWidget->clear();
+ ui.ListWidget->reload(DiveTripModel::TREE);
+ ui.globe->reload();
setTitle(MWTF_DEFAULT);
}
@@ -200,29 +200,29 @@ void MainWindow::on_actionPrint_triggered()
void MainWindow::disableDcShortcuts()
{
- ui->actionPreviousDC->setShortcut(QKeySequence());
- ui->actionNextDC->setShortcut(QKeySequence());
+ ui.actionPreviousDC->setShortcut(QKeySequence());
+ ui.actionNextDC->setShortcut(QKeySequence());
}
void MainWindow::enableDcShortcuts()
{
- ui->actionPreviousDC->setShortcut(Qt::Key_Left);
- ui->actionNextDC->setShortcut(Qt::Key_Right);
+ ui.actionPreviousDC->setShortcut(Qt::Key_Left);
+ ui.actionNextDC->setShortcut(Qt::Key_Right);
}
void MainWindow::on_actionDivePlanner_triggered()
{
disableDcShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(true);
- ui->stackedWidget->setCurrentIndex(PLANNERPROFILE);
- ui->infoPane->setCurrentIndex(PLANNERWIDGET);
+ ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
+ ui.infoPane->setCurrentIndex(PLANNERWIDGET);
}
void MainWindow::showProfile()
{
enableDcShortcuts();
- ui->stackedWidget->setCurrentIndex(PROFILE);
- ui->infoPane->setCurrentIndex(MAINTAB);
+ ui.stackedWidget->setCurrentIndex(PROFILE);
+ ui.infoPane->setCurrentIndex(MAINTAB);
}
@@ -273,12 +273,12 @@ void MainWindow::on_actionAddDive_triggered()
dive->dc.model = _("manually added dive"); // do not use tr here since it expects a char*.
record_dive(dive);
select_dive(get_divenr(dive));
- ui->InfoWidget->updateDiveInfo(selected_dive);
- ui->stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
- ui->infoPane->setCurrentIndex(MAINTAB);
+ ui.InfoWidget->updateDiveInfo(selected_dive);
+ ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
+ ui.infoPane->setCurrentIndex(MAINTAB);
DivePlannerPointsModel::instance()->createSimpleDive();
refreshDisplay();
- ui->InfoWidget->addDiveStarted();
+ ui.InfoWidget->addDiveStarted();
}
void MainWindow::on_actionRenumber_triggered()
@@ -294,7 +294,7 @@ void MainWindow::on_actionAutoGroup_triggered()
void MainWindow::on_actionToggleZoom_triggered()
{
zoomed_plot = !zoomed_plot;
- ui->ProfileWidget->refresh();
+ ui.ProfileWidget->refresh();
}
void MainWindow::on_actionYearlyStatistics_triggered()
@@ -333,40 +333,40 @@ void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx)
#define BEHAVIOR QList<int>()
void MainWindow::on_actionViewList_triggered()
{
- ui->listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
- ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
+ ui.listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
+ ui.mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
}
void MainWindow::on_actionViewProfile_triggered()
{
- ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
- ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
+ ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
+ ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
redrawProfile();
}
void MainWindow::on_actionViewInfo_triggered()
{
- ui->infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
- ui->mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
+ ui.infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
+ ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED);
}
void MainWindow::on_actionViewGlobe_triggered()
{
- ui->mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
- ui->listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
+ ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
+ ui.listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
}
#undef BEHAVIOR
void MainWindow::on_actionViewAll_triggered()
{
// big number squash the info profile to it's minimum.
- ui->infoProfileSplitter->setSizes(QList<int>() << 1 << 20000);
+ ui.infoProfileSplitter->setSizes(QList<int>() << 1 << 20000);
// big number squash the globe view.
- ui->listGlobeSplitter->setSizes(QList<int>() << 2000 << 1 );
+ ui.listGlobeSplitter->setSizes(QList<int>() << 2000 << 1 );
// half and half?
- ui->mainSplitter->setSizes( QList<int>() << 1 << 1);
+ ui.mainSplitter->setSizes( QList<int>() << 1 << 1);
redrawProfile();
}
@@ -505,25 +505,25 @@ void MainWindow::initialUiSetup()
settings.beginGroup("MainWindow");
QSize sz = settings.value("size").value<QSize>();
resize(sz);
- ui->mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
- ui->infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
- ui->listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray());
+ ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
+ ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
+ ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray());
settings.endGroup();
settings.beginGroup("ListWidget");
/* if no width are set, use the calculated width for each column;
* for that to work we need to temporarily expand all rows */
- ui->ListWidget->expandAll();
+ ui.ListWidget->expandAll();
for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
QVariant width = settings.value(QString("colwidth%1").arg(i));
if (width.isValid())
- ui->ListWidget->setColumnWidth(i, width.toInt());
+ ui.ListWidget->setColumnWidth(i, width.toInt());
else
- ui->ListWidget->resizeColumnToContents(i);
+ ui.ListWidget->resizeColumnToContents(i);
}
- ui->ListWidget->collapseAll();
- ui->ListWidget->expand(ui->ListWidget->model()->index(0,0));
- ui->ListWidget->scrollTo(ui->ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter);
+ ui.ListWidget->collapseAll();
+ ui.ListWidget->expand(ui.ListWidget->model()->index(0,0));
+ ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter);
settings.endGroup();
}
@@ -598,15 +598,15 @@ void MainWindow::writeSettings()
settings.beginGroup("MainWindow");
settings.setValue("size",size());
- settings.setValue("mainSplitter", ui->mainSplitter->saveState());
- settings.setValue("infoProfileSplitter", ui->infoProfileSplitter->saveState());
- settings.setValue("listGlobeSplitter", ui->listGlobeSplitter->saveState());
+ settings.setValue("mainSplitter", ui.mainSplitter->saveState());
+ settings.setValue("infoProfileSplitter", ui.infoProfileSplitter->saveState());
+ settings.setValue("listGlobeSplitter", ui.listGlobeSplitter->saveState());
settings.endGroup();
settings.beginGroup("ListWidget");
for (i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++)
- if (!ui->ListWidget->isColumnHidden(i))
- settings.setValue(QString("colwidth%1").arg(i), ui->ListWidget->columnWidth(i));
+ if (!ui.ListWidget->isColumnHidden(i))
+ settings.setValue(QString("colwidth%1").arg(i), ui.ListWidget->columnWidth(i));
settings.endGroup();
settings.beginGroup("Units");
SAVE_VALUE("length", units.length);
@@ -665,22 +665,22 @@ void MainWindow::closeEvent(QCloseEvent *event)
DiveListView* MainWindow::dive_list()
{
- return ui->ListWidget;
+ return ui.ListWidget;
}
GlobeGPS* MainWindow::globe()
{
- return ui->globe;
+ return ui.globe;
}
ProfileGraphicsView* MainWindow::graphics()
{
- return ui->ProfileWidget;
+ return ui.ProfileWidget;
}
MainTab* MainWindow::information()
{
- return ui->InfoWidget;
+ return ui.InfoWidget;
}
void MainWindow::file_save_as(void)
@@ -725,10 +725,10 @@ void MainWindow::showError(QString message)
{
if (message.isEmpty())
return;
- ui->mainErrorMessage->setText(message);
- ui->mainErrorMessage->setCloseButtonVisible(true);
- ui->mainErrorMessage->setMessageType(KMessageWidget::Error);
- ui->mainErrorMessage->animatedShow();
+ ui.mainErrorMessage->setText(message);
+ ui.mainErrorMessage->setCloseButtonVisible(true);
+ ui.mainErrorMessage->setMessageType(KMessageWidget::Error);
+ ui.mainErrorMessage->animatedShow();
}
void MainWindow::setTitle(enum MainWindowTitleFormat format)
@@ -761,10 +761,10 @@ void MainWindow::importFiles(const QStringList fileNames)
}
process_dives(TRUE, FALSE);
- ui->InfoWidget->reload();
- ui->globe->reload();
- ui->ListWidget->reload(DiveTripModel::TREE);
- ui->ListWidget->setFocus();
+ ui.InfoWidget->reload();
+ ui.globe->reload();
+ ui.ListWidget->reload(DiveTripModel::TREE);
+ ui.ListWidget->setFocus();
WSInfoModel *wsim = WSInfoModel::instance();
wsim->updateInfo();
}
@@ -788,10 +788,10 @@ void MainWindow::loadFiles(const QStringList fileNames)
process_dives(FALSE, FALSE);
- ui->InfoWidget->reload();
- ui->globe->reload();
- ui->ListWidget->reload(DiveTripModel::TREE);
- ui->ListWidget->setFocus();
+ ui.InfoWidget->reload();
+ ui.globe->reload();
+ ui.ListWidget->reload(DiveTripModel::TREE);
+ ui.ListWidget->setFocus();
WSInfoModel *wsim = WSInfoModel::instance();
wsim->updateInfo();
}
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 275416c7a..db6f41a39 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -108,7 +108,7 @@ public slots:
void showProfile();
private:
- Ui::MainWindow *ui;
+ Ui::MainWindow ui;
QAction *actionNextDive;
QAction *actionPreviousDive;
QWebView *helpView;
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 0d49d4928..b996bf2df 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -9,11 +9,10 @@ PreferencesDialog* PreferencesDialog::instance()
return dialog;
}
-PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f),
- ui(new Ui::PreferencesDialog())
+PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
{
- ui->setupUi(this);
- connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ ui.setupUi(this);
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
setUiFromPrefs();
rememberPrefs();
}
@@ -28,52 +27,52 @@ void PreferencesDialog::showEvent(QShowEvent *event)
void PreferencesDialog::setUiFromPrefs()
{
// graphs
- ui->phe->setChecked(prefs.pp_graphs.phe);
- ui->pheThreshold->setEnabled(ui->phe->isChecked());
- ui->po2->setChecked(prefs.pp_graphs.po2);
- ui->po2Threshold->setEnabled(ui->po2->isChecked());
- ui->pn2->setChecked(prefs.pp_graphs.pn2);
- ui->pn2Threshold->setEnabled(ui->pn2->isChecked());
- ui->pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
- ui->po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
- ui->pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
- ui->ead_end_eadd->setChecked(prefs.ead);
- ui->dc_reported_ceiling->setChecked(prefs.profile_dc_ceiling);
- ui->red_ceiling->setEnabled(ui->dc_reported_ceiling->isChecked());
- ui->red_ceiling->setChecked(prefs.profile_red_ceiling);
- ui->calculated_ceiling->setChecked(prefs.profile_calc_ceiling);
- ui->increment_3m->setEnabled(ui->calculated_ceiling->isChecked());
- ui->increment_3m->setChecked(prefs.calc_ceiling_3m_incr);
- ui->all_tissues->setEnabled(ui->calculated_ceiling->isChecked());
- ui->all_tissues->setChecked(prefs.calc_all_tissues);
- ui->groupBox->setEnabled(ui->personalize->isChecked());
-
- ui->gflow->setValue(prefs.gflow);
- ui->gfhigh->setValue(prefs.gfhigh);
+ ui.phe->setChecked(prefs.pp_graphs.phe);
+ ui.pheThreshold->setEnabled(ui.phe->isChecked());
+ ui.po2->setChecked(prefs.pp_graphs.po2);
+ ui.po2Threshold->setEnabled(ui.po2->isChecked());
+ ui.pn2->setChecked(prefs.pp_graphs.pn2);
+ ui.pn2Threshold->setEnabled(ui.pn2->isChecked());
+ ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
+ ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
+ ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
+ ui.ead_end_eadd->setChecked(prefs.ead);
+ ui.dc_reported_ceiling->setChecked(prefs.profile_dc_ceiling);
+ ui.red_ceiling->setEnabled(ui.dc_reported_ceiling->isChecked());
+ ui.red_ceiling->setChecked(prefs.profile_red_ceiling);
+ ui.calculated_ceiling->setChecked(prefs.profile_calc_ceiling);
+ ui.increment_3m->setEnabled(ui.calculated_ceiling->isChecked());
+ ui.increment_3m->setChecked(prefs.calc_ceiling_3m_incr);
+ ui.all_tissues->setEnabled(ui.calculated_ceiling->isChecked());
+ ui.all_tissues->setChecked(prefs.calc_all_tissues);
+ ui.groupBox->setEnabled(ui.personalize->isChecked());
+
+ ui.gflow->setValue(prefs.gflow);
+ ui.gfhigh->setValue(prefs.gfhigh);
// units
if (prefs.unit_system == METRIC)
- ui->metric->setChecked(true);
+ ui.metric->setChecked(true);
else if (prefs.unit_system == IMPERIAL)
- ui->imperial->setChecked(true);
+ ui.imperial->setChecked(true);
else
- ui->personalize->setChecked(true);
-
- ui->celsius->setChecked(prefs.units.temperature == units::CELSIUS);
- ui->fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
- ui->meter->setChecked(prefs.units.length == units::METERS);
- ui->feet->setChecked(prefs.units.length == units::FEET);
- ui->bar->setChecked(prefs.units.pressure == units::BAR);
- ui->psi->setChecked(prefs.units.pressure == units::PSI);
- ui->liter->setChecked(prefs.units.volume == units::LITER);
- ui->cuft->setChecked(prefs.units.volume == units::CUFT);
- ui->kgs->setChecked(prefs.units.weight == units::KG);
- ui->lbs->setChecked(prefs.units.weight == units::LBS);
- ui->font->setFont(QString(prefs.divelist_font));
- ui->fontsize->setValue(prefs.font_size);
- ui->defaultfilename->setText(prefs.default_filename);
- ui->displayinvalid->setChecked(prefs.show_invalid);
- ui->show_time->setChecked(prefs.show_time);
+ ui.personalize->setChecked(true);
+
+ ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS);
+ ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
+ ui.meter->setChecked(prefs.units.length == units::METERS);
+ ui.feet->setChecked(prefs.units.length == units::FEET);
+ ui.bar->setChecked(prefs.units.pressure == units::BAR);
+ ui.psi->setChecked(prefs.units.pressure == units::PSI);
+ ui.liter->setChecked(prefs.units.volume == units::LITER);
+ ui.cuft->setChecked(prefs.units.volume == units::CUFT);
+ ui.kgs->setChecked(prefs.units.weight == units::KG);
+ ui.lbs->setChecked(prefs.units.weight == units::LBS);
+ ui.font->setFont(QString(prefs.divelist_font));
+ ui.fontsize->setValue(prefs.font_size);
+ ui.defaultfilename->setText(prefs.default_filename);
+ ui.displayinvalid->setChecked(prefs.show_invalid);
+ ui.show_time->setChecked(prefs.show_time);
}
void PreferencesDialog::restorePrefs()
@@ -90,31 +89,31 @@ void PreferencesDialog::rememberPrefs()
void PreferencesDialog::setPrefsFromUi()
{
- SP(pp_graphs.phe, ui->phe);
- SP(pp_graphs.po2, ui->po2);
- SP(pp_graphs.pn2, ui->pn2);
- prefs.pp_graphs.phe_threshold = ui->pheThreshold->value();
- prefs.pp_graphs.po2_threshold = ui->po2Threshold->value();
- prefs.pp_graphs.pn2_threshold = ui->pn2Threshold->value();
- SP(ead, ui->ead_end_eadd);
- SP(profile_dc_ceiling, ui->dc_reported_ceiling);
- SP(profile_red_ceiling, ui->red_ceiling);
- SP(profile_calc_ceiling, ui->calculated_ceiling);
- SP(calc_ceiling_3m_incr, ui->increment_3m);
- SP(calc_all_tissues, ui->all_tissues);
- prefs.gflow = ui->gflow->value();
- prefs.gfhigh = ui->gfhigh->value();
- prefs.unit_system = ui->metric->isChecked() ? METRIC : (ui->imperial->isChecked() ? IMPERIAL : PERSONALIZE);
- prefs.units.temperature = ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS;
- prefs.units.length = ui->feet->isChecked() ? units::FEET : units::METERS;
- prefs.units.pressure = ui->psi->isChecked() ? units::PSI : units::BAR;
- prefs.units.volume = ui->cuft->isChecked() ? units::CUFT : units::LITER;
- prefs.units.weight = ui->lbs->isChecked() ? units::LBS : units::KG;
- prefs.divelist_font = strdup(ui->font->font().family().toUtf8().data());
- prefs.font_size = ui->fontsize->value();
- prefs.default_filename = strdup(ui->defaultfilename->text().toUtf8().data());
- prefs.display_invalid_dives = ui->displayinvalid->isChecked();
- SP(show_time, ui->show_time);
+ SP(pp_graphs.phe, ui.phe);
+ SP(pp_graphs.po2, ui.po2);
+ SP(pp_graphs.pn2, ui.pn2);
+ prefs.pp_graphs.phe_threshold = ui.pheThreshold->value();
+ prefs.pp_graphs.po2_threshold = ui.po2Threshold->value();
+ prefs.pp_graphs.pn2_threshold = ui.pn2Threshold->value();
+ SP(ead, ui.ead_end_eadd);
+ SP(profile_dc_ceiling, ui.dc_reported_ceiling);
+ SP(profile_red_ceiling, ui.red_ceiling);
+ SP(profile_calc_ceiling, ui.calculated_ceiling);
+ SP(calc_ceiling_3m_incr, ui.increment_3m);
+ SP(calc_all_tissues, ui.all_tissues);
+ prefs.gflow = ui.gflow->value();
+ prefs.gfhigh = ui.gfhigh->value();
+ prefs.unit_system = ui.metric->isChecked() ? METRIC : (ui.imperial->isChecked() ? IMPERIAL : PERSONALIZE);
+ prefs.units.temperature = ui.fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS;
+ prefs.units.length = ui.feet->isChecked() ? units::FEET : units::METERS;
+ prefs.units.pressure = ui.psi->isChecked() ? units::PSI : units::BAR;
+ prefs.units.volume = ui.cuft->isChecked() ? units::CUFT : units::LITER;
+ prefs.units.weight = ui.lbs->isChecked() ? units::LBS : units::KG;
+ prefs.divelist_font = strdup(ui.font->font().family().toUtf8().data());
+ prefs.font_size = ui.fontsize->value();
+ prefs.default_filename = strdup(ui.defaultfilename->text().toUtf8().data());
+ prefs.display_invalid_dives = ui.displayinvalid->isChecked();
+ SP(show_time, ui.show_time);
}
#define SB(V, B) s.setValue(V, (int)(B->isChecked() ? 1 : 0))
@@ -126,39 +125,39 @@ void PreferencesDialog::syncSettings()
// Graph
s.beginGroup("TecDetails");
- SB("phegraph", ui->phe);
- SB("po2graph", ui->po2);
- SB("pn2graph", ui->pn2);
- s.setValue("phethreshold", ui->pheThreshold->value());
- s.setValue("po2threshold", ui->po2Threshold->value());
- s.setValue("pn2threshold", ui->pn2Threshold->value());
- SB("ead", ui->ead_end_eadd);
- SB("dcceiling", ui->dc_reported_ceiling);
- SB("redceiling", ui->red_ceiling);
- SB("calcceiling", ui->calculated_ceiling);
- SB("calcceiling3m", ui->increment_3m);
- SB("calcalltissues", ui->all_tissues);
- s.setValue("gflow", ui->gflow->value());
- s.setValue("gfhigh", ui->gfhigh->value());
- SB("show_time", ui->show_time);
+ SB("phegraph", ui.phe);
+ SB("po2graph", ui.po2);
+ SB("pn2graph", ui.pn2);
+ s.setValue("phethreshold", ui.pheThreshold->value());
+ s.setValue("po2threshold", ui.po2Threshold->value());
+ s.setValue("pn2threshold", ui.pn2Threshold->value());
+ SB("ead", ui.ead_end_eadd);
+ SB("dcceiling", ui.dc_reported_ceiling);
+ SB("redceiling", ui.red_ceiling);
+ SB("calcceiling", ui.calculated_ceiling);
+ SB("calcceiling3m", ui.increment_3m);
+ SB("calcalltissues", ui.all_tissues);
+ s.setValue("gflow", ui.gflow->value());
+ s.setValue("gfhigh", ui.gfhigh->value());
+ SB("show_time", ui.show_time);
s.endGroup();
// Units
s.beginGroup("Units");
- QString unitSystem = ui->metric->isChecked() ? "metric" : (ui->imperial->isChecked() ? "imperial" : "personal");
+ QString unitSystem = ui.metric->isChecked() ? "metric" : (ui.imperial->isChecked() ? "imperial" : "personal");
s.setValue("unit_system", unitSystem);
- s.setValue("temperature", ui->fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
- s.setValue("length", ui->feet->isChecked() ? units::FEET : units::METERS);
- s.setValue("pressure", ui->psi->isChecked() ? units::PSI : units::BAR);
- s.setValue("volume", ui->cuft->isChecked() ? units::CUFT : units::LITER);
- s.setValue("weight", ui->lbs->isChecked() ? units::LBS : units::KG);
+ s.setValue("temperature", ui.fahrenheit->isChecked() ? units::FAHRENHEIT : units::CELSIUS);
+ s.setValue("length", ui.feet->isChecked() ? units::FEET : units::METERS);
+ s.setValue("pressure", ui.psi->isChecked() ? units::PSI : units::BAR);
+ s.setValue("volume", ui.cuft->isChecked() ? units::CUFT : units::LITER);
+ s.setValue("weight", ui.lbs->isChecked() ? units::LBS : units::KG);
s.endGroup();
// Defaults
s.beginGroup("GeneralSettings");
- s.value("table_fonts", ui->font->font().family());
- s.value("font_size", ui->fontsize->value());
- s.value("default_filename", ui->defaultfilename->text());
- s.value("displayinvalid", ui->displayinvalid->isChecked());
+ s.value("table_fonts", ui.font->font().family());
+ s.value("font_size", ui.fontsize->value());
+ s.value("default_filename", ui.defaultfilename->text());
+ s.value("displayinvalid", ui.displayinvalid->isChecked());
s.endGroup();
s.sync();
@@ -167,7 +166,7 @@ void PreferencesDialog::syncSettings()
void PreferencesDialog::buttonClicked(QAbstractButton* button)
{
- switch(ui->buttonBox->standardButton(button)){
+ switch(ui.buttonBox->standardButton(button)){
case QDialogButtonBox::Discard:
restorePrefs();
setUiFromPrefs();
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index 0d40b4059..86f200934 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -27,7 +27,7 @@ private:
void setUiFromPrefs();
void setPrefsFromUi();
void setUIFromSettings();
- Ui::PreferencesDialog* ui;
+ Ui::PreferencesDialog ui;
struct preferences oldPrefs;
};
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 437eb3f9e..d68078bad 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -2,10 +2,9 @@
#include "../display.h"
PrintOptions::PrintOptions(QWidget *parent, struct options *printOpt)
-: ui( new Ui::PrintOptions())
{
hasSetupSlots = false;
- ui->setupUi(this);
+ ui.setupUi(this);
if (parent)
setParent(parent);
if (!printOpt)
@@ -17,48 +16,48 @@ void PrintOptions::setup(struct options *printOpt)
{
printOptions = printOpt;
// layout height sliders
- initSliderWithLabel(ui->sliderPHeight, ui->valuePHeight, printOptions->profile_height);
- initSliderWithLabel(ui->sliderOHeight, ui->valueOHeight, printOptions->notes_height);
- initSliderWithLabel(ui->sliderNHeight, ui->valueNHeight, printOptions->tanks_height);
+ initSliderWithLabel(ui.sliderPHeight, ui.valuePHeight, printOptions->profile_height);
+ initSliderWithLabel(ui.sliderOHeight, ui.valueOHeight, printOptions->notes_height);
+ initSliderWithLabel(ui.sliderNHeight, ui.valueNHeight, printOptions->tanks_height);
// print type radio buttons
switch (printOptions->type) {
case options::PRETTY:
- ui->radioSixDives->setChecked(true);
+ ui.radioSixDives->setChecked(true);
break;
case options::TWOPERPAGE:
- ui->radioTwoDives->setChecked(true);
+ ui.radioTwoDives->setChecked(true);
break;
case options::TABLE:
- ui->radioTablePrint->setChecked(true);
+ ui.radioTablePrint->setChecked(true);
break;
}
// general print option checkboxes
if (printOptions->color_selected)
- ui->printInColor->setChecked(true);
+ ui.printInColor->setChecked(true);
if (printOptions->print_selected)
- ui->printSelected->setChecked(true);
+ ui.printSelected->setChecked(true);
// ordering
if (printOptions->notes_up)
- ui->notesOnTop->setChecked(true);
+ ui.notesOnTop->setChecked(true);
else
- ui->profileOnTop->setChecked(true);
+ ui.profileOnTop->setChecked(true);
// connect slots only once
if (hasSetupSlots)
return;
- connect(ui->sliderPHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderPHeightMoved(int)));
- connect(ui->sliderOHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderOHeightMoved(int)));
- connect(ui->sliderNHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderNHeightMoved(int)));
+ connect(ui.sliderPHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderPHeightMoved(int)));
+ connect(ui.sliderOHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderOHeightMoved(int)));
+ connect(ui.sliderNHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderNHeightMoved(int)));
- connect(ui->radioSixDives, SIGNAL(clicked(bool)), this, SLOT(radioSixDivesClicked(bool)));
- connect(ui->radioTwoDives, SIGNAL(clicked(bool)), this, SLOT(radioTwoDivesClicked(bool)));
- connect(ui->radioTablePrint, SIGNAL(clicked(bool)), this, SLOT(radioTablePrintClicked(bool)));
+ connect(ui.radioSixDives, SIGNAL(clicked(bool)), this, SLOT(radioSixDivesClicked(bool)));
+ connect(ui.radioTwoDives, SIGNAL(clicked(bool)), this, SLOT(radioTwoDivesClicked(bool)));
+ connect(ui.radioTablePrint, SIGNAL(clicked(bool)), this, SLOT(radioTablePrintClicked(bool)));
- connect(ui->printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
- connect(ui->printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
+ connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
+ connect(ui.printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
- connect(ui->notesOnTop, SIGNAL(clicked(bool)), this, SLOT(notesOnTopClicked(bool)));
- connect(ui->profileOnTop, SIGNAL(clicked(bool)), this, SLOT(profileOnTopClicked(bool)));
+ connect(ui.notesOnTop, SIGNAL(clicked(bool)), this, SLOT(notesOnTopClicked(bool)));
+ connect(ui.profileOnTop, SIGNAL(clicked(bool)), this, SLOT(profileOnTopClicked(bool)));
hasSetupSlots = true;
}
@@ -77,19 +76,19 @@ QString PrintOptions::formatSliderValueText(int value)
void PrintOptions::sliderPHeightMoved(int value)
{
- ui->valuePHeight->setText(formatSliderValueText(value));
+ ui.valuePHeight->setText(formatSliderValueText(value));
printOptions->profile_height = value;
}
void PrintOptions::sliderOHeightMoved(int value)
{
- ui->valueOHeight->setText(formatSliderValueText(value));
+ ui.valueOHeight->setText(formatSliderValueText(value));
printOptions->notes_height = value;
}
void PrintOptions::sliderNHeightMoved(int value)
{
- ui->valueNHeight->setText(formatSliderValueText(value));
+ ui.valueNHeight->setText(formatSliderValueText(value));
printOptions->tanks_height = value;
}
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 86d9ba37d..0f1e9e848 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -16,7 +16,7 @@ public:
void setup(struct options *printOpt);
private:
- Ui::PrintOptions *ui;
+ Ui::PrintOptions ui;
void setLabelFromSlider(QSlider *slider, QLabel *label);
void initSliderWithLabel(QSlider *slider, QLabel *label, int value);
QString formatSliderValueText(int value);
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 5b6c7a886..1da090fdd 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -108,16 +108,16 @@ RenumberDialog* RenumberDialog::instance()
void RenumberDialog::buttonClicked(QAbstractButton* button)
{
- if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
+ if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
qDebug() << "Renumbering.";
- renumber_dives(ui->spinBox->value());
+ renumber_dives(ui.spinBox->value());
}
}
-RenumberDialog::RenumberDialog(): QDialog(), ui( new Ui::RenumberDialog())
+RenumberDialog::RenumberDialog(): QDialog()
{
- ui->setupUi(this);
- connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ ui.setupUi(this);
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
}
bool isGnome3Session()
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 32b299868..057a97251 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -30,10 +30,6 @@ private:
MinMaxAvgWidgetPrivate *d;
};
-namespace Ui{
- class RenumberDialog;
-};
-
class RenumberDialog : public QDialog {
Q_OBJECT
public:
@@ -42,7 +38,7 @@ private slots:
void buttonClicked(QAbstractButton *button);
private:
explicit RenumberDialog();
- Ui::RenumberDialog *ui;
+ Ui::RenumberDialog ui;
};
bool isGnome3Session();
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index cdc5f5aa1..f0d33e53f 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -23,13 +23,13 @@ SubsurfaceWebServices* SubsurfaceWebServices::instance()
}
SubsurfaceWebServices::SubsurfaceWebServices(QWidget* parent, Qt::WindowFlags f)
-: ui( new Ui::SubsurfaceWebServices()){
- ui->setupUi(this);
- connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
- connect(ui->download, SIGNAL(clicked(bool)), this, SLOT(startDownload()));
- ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+{
+ ui.setupUi(this);
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
+ connect(ui.download, SIGNAL(clicked(bool)), this, SLOT(startDownload()));
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
QSettings s;
- ui->userID->setText(s.value("webservice_uid").toString());
+ ui.userID->setText(s.value("webservice_uid").toString());
}
@@ -43,8 +43,8 @@ static void clear_table(struct dive_table *table)
void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
{
- ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
- switch(ui->buttonBox->buttonRole(button)){
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+ switch(ui.buttonBox->buttonRole(button)){
case QDialogButtonBox::ApplyRole:{
clear_table(&gps_location_table);
QByteArray url = tr("Webservice").toLocal8Bit();
@@ -57,7 +57,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
/* store last entered uid in config */
QSettings s;
- s.setValue("webservice_uid", ui->userID->text());
+ s.setValue("webservice_uid", ui.userID->text());
s.sync();
hide();
close();
@@ -68,7 +68,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
// makes Subsurface throw a SIGSEGV...
// manager->deleteLater();
reply->deleteLater();
- ui->progressBar->setMaximum(1);
+ ui.progressBar->setMaximum(1);
break;
case QDialogButtonBox::HelpRole:
QDesktopServices::openUrl(QUrl("http://api.hohndel.org"));
@@ -81,17 +81,17 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
void SubsurfaceWebServices::startDownload()
{
QUrl url("http://api.hohndel.org/api/dive/get/");
- url.setQueryItems( QList<QPair<QString,QString> >() << qMakePair(QString("login"), ui->userID->text()));
+ url.setQueryItems( QList<QPair<QString,QString> >() << qMakePair(QString("login"), ui.userID->text()));
manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(url);
request.setRawHeader("Accept", "text/xml");
reply = manager->get(request);
- ui->status->setText(tr("Wait a bit untill we have something..."));
- ui->progressBar->setRange(0,0); // this makes the progressbar do an 'infinite spin'
- ui->download->setEnabled(false);
- ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+ ui.status->setText(tr("Wait a bit untill we have something..."));
+ ui.progressBar->setRange(0,0); // this makes the progressbar do an 'infinite spin'
+ ui.download->setEnabled(false);
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
@@ -100,16 +100,16 @@ void SubsurfaceWebServices::startDownload()
void SubsurfaceWebServices::downloadFinished()
{
- ui->progressBar->setRange(0,1);
+ ui.progressBar->setRange(0,1);
downloadedData = reply->readAll();
- ui->download->setEnabled(true);
- ui->status->setText(tr("Download Finished"));
+ ui.download->setEnabled(true);
+ ui.status->setText(tr("Download Finished"));
uint resultCode = download_dialog_parse_response(downloadedData);
setStatusText(resultCode);
if (resultCode == DD_STATUS_OK){
- ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
+ ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
}
manager->deleteLater();
reply->deleteLater();
@@ -117,9 +117,9 @@ void SubsurfaceWebServices::downloadFinished()
void SubsurfaceWebServices::downloadError(QNetworkReply::NetworkError error)
{
- ui->download->setEnabled(true);
- ui->progressBar->setRange(0,1);
- ui->status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
+ ui.download->setEnabled(true);
+ ui.progressBar->setRange(0,1);
+ ui.status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
manager->deleteLater();
reply->deleteLater();
}
@@ -133,7 +133,7 @@ void SubsurfaceWebServices::setStatusText(int status)
case DD_STATUS_ERROR_PARSE: text = tr("Cannot parse response!"); break;
case DD_STATUS_OK: text = tr("Download Success!"); break;
}
- ui->status->setText(text);
+ ui.status->setText(text);
}
void SubsurfaceWebServices::runDialog()
diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h
index 9e85db155..0719a8f15 100644
--- a/qt-ui/subsurfacewebservices.h
+++ b/qt-ui/subsurfacewebservices.h
@@ -5,9 +5,8 @@
#include <QNetworkReply>
#include <libxml/tree.h>
-namespace Ui{
- class SubsurfaceWebServices;
-};
+#include "ui_subsurfacewebservices.h"
+
class QAbstractButton;
class QNetworkReply;
@@ -29,10 +28,10 @@ private:
unsigned int download_dialog_parse_response(const QByteArray& length);
explicit SubsurfaceWebServices(QWidget* parent = 0, Qt::WindowFlags f = 0);
- Ui::SubsurfaceWebServices *ui;
+ Ui::SubsurfaceWebServices ui;
QNetworkReply *reply;
QNetworkAccessManager *manager;
QByteArray downloadedData;
};
-#endif \ No newline at end of file
+#endif
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp
index b3d2c360d..d9731b477 100644
--- a/qt-ui/tableview.cpp
+++ b/qt-ui/tableview.cpp
@@ -7,20 +7,21 @@
#include <QTextStream>
#include <QSettings>
-TableView::TableView(QWidget *parent) : QWidget(parent), ui(new Ui::TableView){
- ui->setupUi(this);
+TableView::TableView(QWidget *parent) : QWidget(parent)
+{
+ ui.setupUi(this);
QFile cssFile(":table-css");
cssFile.open(QIODevice::ReadOnly);
QTextStream reader(&cssFile);
QString css = reader.readAll();
- ui->tableView->setStyleSheet(css);
+ ui.tableView->setStyleSheet(css);
/* There`s mostly a need for a Mac fix here too. */
if (qApp->style()->objectName() == "gtk+")
- ui->groupBox->layout()->setContentsMargins(0, 9, 0, 0);
+ ui.groupBox->layout()->setContentsMargins(0, 9, 0, 0);
else
- ui->groupBox->layout()->setContentsMargins(0, 0, 0, 0);
+ ui.groupBox->layout()->setContentsMargins(0, 0, 0, 0);
QIcon plusIcon(":plus");
- plusBtn = new QPushButton(plusIcon, QString(), ui->groupBox);
+ plusBtn = new QPushButton(plusIcon, QString(), ui.groupBox);
plusBtn->setFlat(true);
plusBtn->setToolTip(tr("Add Cylinder"));
plusBtn->setIconSize(QSize(16,16));
@@ -31,8 +32,8 @@ TableView::~TableView()
{
QSettings s;
s.beginGroup(objectName());
- for (int i = 0; i < ui->tableView->model()->columnCount(); i++) {
- s.setValue(QString("colwidth%1").arg(i), ui->tableView->columnWidth(i));
+ for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
+ s.setValue(QString("colwidth%1").arg(i), ui.tableView->columnWidth(i));
}
s.endGroup();
s.sync();
@@ -45,31 +46,31 @@ void TableView::setBtnToolTip(const QString& tooltip)
void TableView::setTitle(const QString& title)
{
- ui->groupBox->setTitle(title);
+ ui.groupBox->setTitle(title);
}
void TableView::setModel(QAbstractItemModel *model){
- ui->tableView->setModel(model);
- connect(ui->tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
+ ui.tableView->setModel(model);
+ connect(ui.tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
QSettings s;
s.beginGroup(objectName());
- for (int i = 0; i < ui->tableView->model()->columnCount(); i++) {
+ for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
QVariant width = s.value(QString("colwidth%1").arg(i));
if (width.isValid())
- ui->tableView->setColumnWidth(i, width.toInt());
+ ui.tableView->setColumnWidth(i, width.toInt());
else
- ui->tableView->resizeColumnToContents(i);
+ ui.tableView->resizeColumnToContents(i);
}
s.endGroup();
QFontMetrics metrics(defaultModelFont());
- ui->tableView->horizontalHeader()->setMinimumHeight(metrics.height() + 10);
+ ui.tableView->horizontalHeader()->setMinimumHeight(metrics.height() + 10);
}
void TableView::fixPlusPosition()
{
- plusBtn->setGeometry(ui->groupBox->contentsRect().width() - 30, 2, 24,24);
+ plusBtn->setGeometry(ui.groupBox->contentsRect().width() - 30, 2, 24,24);
}
// We need to manually position the 'plus' on cylinder and weight.
@@ -86,9 +87,9 @@ void TableView::showEvent(QShowEvent* event)
}
void TableView::edit(const QModelIndex& index){
- ui->tableView->edit(index);
+ ui.tableView->edit(index);
}
QTableView *TableView::view(){
- return ui->tableView;
+ return ui.tableView;
}
diff --git a/qt-ui/tableview.h b/qt-ui/tableview.h
index 0baac082a..9ffee429e 100644
--- a/qt-ui/tableview.h
+++ b/qt-ui/tableview.h
@@ -37,7 +37,7 @@ signals:
void addButtonClicked();
private:
- Ui::TableView *ui;
+ Ui::TableView ui;
QPushButton *plusBtn;
};