2018-10-13 09:52:08 +00:00
|
|
|
#include "desktop-widgets/filterwidget2.h"
|
|
|
|
#include "desktop-widgets/simplewidgets.h"
|
|
|
|
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
|
|
|
|
FilterWidget2::FilterWidget2(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, ui(new Ui::FilterWidget2())
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2018-12-06 19:07:47 +00:00
|
|
|
|
|
|
|
FilterData data;
|
|
|
|
ui->minRating->setCurrentStars(data.minRating);
|
|
|
|
ui->maxRating->setCurrentStars(data.maxRating);
|
|
|
|
ui->minVisibility->setCurrentStars(data.minVisibility);
|
|
|
|
ui->maxVisibility->setCurrentStars(data.maxVisibility);
|
|
|
|
ui->minAirTemp->setValue(data.minAirTemp);
|
|
|
|
ui->maxAirTemp->setValue(data.maxAirTemp);
|
|
|
|
ui->minWaterTemp->setValue(data.minWaterTemp);
|
|
|
|
ui->maxWaterTemp->setValue(data.maxWaterTemp);
|
2019-01-01 17:49:56 +00:00
|
|
|
ui->planned->setChecked(data.logged);
|
|
|
|
ui->planned->setChecked(data.planned);
|
2018-11-16 14:23:39 +00:00
|
|
|
|
|
|
|
// TODO: unhide this when we discover how to search for equipment.
|
|
|
|
ui->equipment->hide();
|
|
|
|
ui->labelEquipment->hide();
|
|
|
|
ui->invertFilter->hide();
|
|
|
|
|
2018-12-06 19:07:47 +00:00
|
|
|
ui->to->setDate(data.to.date());
|
2018-10-13 09:52:08 +00:00
|
|
|
|
|
|
|
connect(ui->maxRating, &StarWidget::valueChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->minRating, &StarWidget::valueChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->maxVisibility, &StarWidget::valueChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->minVisibility, &StarWidget::valueChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->maxAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->minAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->maxWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->minWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->from, &QDateTimeEdit::dateTimeChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->to, &QDateTimeEdit::dateTimeChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->tags, &QLineEdit::textChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->people, &QLineEdit::textChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
|
|
|
|
|
|
|
connect(ui->location, &QLineEdit::textChanged,
|
|
|
|
this, &FilterWidget2::updateFilter);
|
2019-01-01 17:49:56 +00:00
|
|
|
|
|
|
|
connect(ui->logged, SIGNAL(stateChanged(int)), this, SLOT(updateLogged(int)));
|
|
|
|
|
|
|
|
connect(ui->planned, SIGNAL(stateChanged(int)), this, SLOT(updatePlanned(int)));
|
|
|
|
|
2018-10-13 09:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FilterWidget2::updateFilter()
|
|
|
|
{
|
2018-12-06 19:07:47 +00:00
|
|
|
FilterData data;
|
|
|
|
|
|
|
|
data.validFilter = true;
|
|
|
|
data.minVisibility = ui->minVisibility->currentStars();
|
|
|
|
data.maxVisibility = ui->maxVisibility->currentStars();
|
|
|
|
data.minRating = ui->minRating->currentStars();
|
|
|
|
data.maxRating = ui->maxRating->currentStars();
|
|
|
|
data.minWaterTemp = ui->minWaterTemp->value();
|
|
|
|
data.maxWaterTemp = ui->maxWaterTemp->value();
|
|
|
|
data.minAirTemp = ui->minAirTemp->value();
|
|
|
|
data.maxWaterTemp = ui->maxWaterTemp->value();
|
|
|
|
data.from = ui->from->dateTime();
|
|
|
|
data.to = ui->to->dateTime();
|
|
|
|
data.tags = ui->tags->text().split(",", QString::SkipEmptyParts);
|
|
|
|
data.people = ui->people->text().split(",", QString::SkipEmptyParts);
|
|
|
|
data.location = ui->location->text().split(",", QString::SkipEmptyParts);
|
|
|
|
data.equipment = ui->equipment->text().split(",", QString::SkipEmptyParts);
|
|
|
|
data.invertFilter = ui->invertFilter->isChecked();
|
2019-01-01 17:49:56 +00:00
|
|
|
data.logged = ui->logged->isChecked();
|
|
|
|
data.planned = ui->planned->isChecked();
|
2018-12-06 19:07:47 +00:00
|
|
|
|
2018-11-16 14:24:11 +00:00
|
|
|
filterData = data;
|
|
|
|
emit filterDataChanged(data);
|
|
|
|
}
|
|
|
|
|
2019-01-01 17:49:56 +00:00
|
|
|
void FilterWidget2::updateLogged(int value) {
|
|
|
|
if (value == Qt::Unchecked)
|
|
|
|
ui->planned->setChecked(true);
|
|
|
|
updateFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FilterWidget2::updatePlanned(int value) {
|
|
|
|
if (value == Qt::Unchecked)
|
|
|
|
ui->logged->setChecked(true);
|
|
|
|
updateFilter();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-16 14:24:11 +00:00
|
|
|
void FilterWidget2::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
QWidget::showEvent(event);
|
|
|
|
emit filterDataChanged(filterData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FilterWidget2::hideEvent(QHideEvent *event)
|
|
|
|
{
|
|
|
|
QWidget::hideEvent(event);
|
|
|
|
FilterData data;
|
2018-12-06 19:07:47 +00:00
|
|
|
emit filterDataChanged(data);
|
2018-10-13 09:52:08 +00:00
|
|
|
}
|