mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
272338875d
This code adds a Renumber Dialog, that's most a copy & paste of the GTK visual, I didn't tried to do anything fance with it, but I still dont like how it looks like. a better management form is needed. :) ( Well, actually my dislike is mostly because it's on a menu and it's on a popup, I think a 'toolbox' should exist to hold all of those widgets that don't belong to the menu - will try that later ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
120 lines
2.8 KiB
C++
120 lines
2.8 KiB
C++
#include "simplewidgets.h"
|
|
|
|
#include <QLabel>
|
|
#include <QLabel>
|
|
#include <QFormLayout>
|
|
#include <QIcon>
|
|
#include <QAbstractButton>
|
|
#include <QSpinBox>
|
|
#include <QButtonGroup>
|
|
#include <QDebug>
|
|
|
|
#include "../dive.h"
|
|
|
|
#include "ui_renumber.h"
|
|
|
|
class MinMaxAvgWidgetPrivate{
|
|
public:
|
|
QLabel *avgIco, *avgValue;
|
|
QLabel *minIco, *minValue;
|
|
QLabel *maxIco, *maxValue;
|
|
|
|
MinMaxAvgWidgetPrivate(MinMaxAvgWidget *owner){
|
|
avgIco = new QLabel(owner);
|
|
avgIco->setPixmap(QIcon(":/average").pixmap(16,16));
|
|
avgIco->setToolTip(QObject::tr("Average"));
|
|
minIco = new QLabel(owner);
|
|
minIco->setPixmap(QIcon(":/minimum").pixmap(16,16));
|
|
minIco->setToolTip(QObject::tr("Minimum"));
|
|
maxIco = new QLabel(owner);
|
|
maxIco->setPixmap(QIcon(":/maximum").pixmap(16,16));
|
|
maxIco->setToolTip(QObject::tr("Maximum"));
|
|
avgValue = new QLabel(owner);
|
|
minValue = new QLabel(owner);
|
|
maxValue = new QLabel(owner);
|
|
|
|
QGridLayout *formLayout = new QGridLayout();
|
|
formLayout->addWidget(maxIco, 0, 0);
|
|
formLayout->addWidget(maxValue, 0, 1);
|
|
formLayout->addWidget(avgIco, 1, 0);
|
|
formLayout->addWidget(avgValue, 1, 1);
|
|
formLayout->addWidget(minIco, 2, 0);
|
|
formLayout->addWidget(minValue, 2, 1);
|
|
owner->setLayout(formLayout);
|
|
}
|
|
};
|
|
|
|
double MinMaxAvgWidget::average() const
|
|
{
|
|
return d->avgValue->text().toDouble();
|
|
}
|
|
|
|
double MinMaxAvgWidget::maximum() const
|
|
{
|
|
return d->maxValue->text().toDouble();
|
|
}
|
|
double MinMaxAvgWidget::minimum() const
|
|
{
|
|
return d->minValue->text().toDouble();
|
|
}
|
|
|
|
MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent)
|
|
: d(new MinMaxAvgWidgetPrivate(this)){
|
|
|
|
}
|
|
|
|
void MinMaxAvgWidget::clear()
|
|
{
|
|
d->avgValue->setText(QString());
|
|
d->maxValue->setText(QString());
|
|
d->minValue->setText(QString());
|
|
}
|
|
|
|
void MinMaxAvgWidget::setAverage(double average)
|
|
{
|
|
d->avgValue->setText(QString::number(average));
|
|
}
|
|
|
|
void MinMaxAvgWidget::setMaximum(double maximum)
|
|
{
|
|
d->maxValue->setText(QString::number(maximum));
|
|
}
|
|
void MinMaxAvgWidget::setMinimum(double minimum)
|
|
{
|
|
d->minValue->setText(QString::number(minimum));
|
|
}
|
|
|
|
void MinMaxAvgWidget::setAverage(const QString& average)
|
|
{
|
|
d->avgValue->setText(average);
|
|
}
|
|
|
|
void MinMaxAvgWidget::setMaximum(const QString& maximum)
|
|
{
|
|
d->maxValue->setText(maximum);
|
|
}
|
|
|
|
void MinMaxAvgWidget::setMinimum(const QString& minimum)
|
|
{
|
|
d->minValue->setText(minimum);
|
|
}
|
|
|
|
RenumberDialog* RenumberDialog::instance()
|
|
{
|
|
static RenumberDialog* self = new RenumberDialog();
|
|
return self;
|
|
}
|
|
|
|
void RenumberDialog::buttonClicked(QAbstractButton* button)
|
|
{
|
|
if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole){
|
|
qDebug() << "Renumbering.";
|
|
renumber_dives(ui->spinBox->value());
|
|
}
|
|
}
|
|
|
|
RenumberDialog::RenumberDialog(): QDialog(), ui( new Ui::RenumberDialog())
|
|
{
|
|
ui->setupUi(this);
|
|
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
|
}
|