mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Cleanup: provide our own qOverload<> implementation.
This is only in Qt 5.7 and therefore can't be used in Qt 5.5 and 5.6 builds. Moreover, we can't simply reuse Qt's version owing to licensing concerns. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b0e1d88634
commit
0eb00ed700
2 changed files with 23 additions and 13 deletions
|
@ -116,6 +116,21 @@ void moveInVector(Vector &v, int rangeBegin, int rangeEnd, int destination)
|
||||||
std::rotate(it + destination, it + rangeBegin, it + rangeEnd);
|
std::rotate(it + destination, it + rangeBegin, it + rangeEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Qt overloads some signals(!) which can't therefore be used in connect() calls with
|
||||||
|
// pointers-to-member functions where the signatures of signal and slot don't match perfectly.
|
||||||
|
// For this case, Qt 5.7 provides the qOverload<> helper.
|
||||||
|
// Since we still support Qt 5.5 let's reimplement it here.
|
||||||
|
#if QT_VERSION < 0x050700
|
||||||
|
template <typename... Args>
|
||||||
|
struct QOverload {
|
||||||
|
template <typename Ret, typename Class>
|
||||||
|
static Ret (Class::*of(Ret (Class::*fun)(Args...)))(Args...)
|
||||||
|
{
|
||||||
|
return fun;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 3) Functions visible to C and C++
|
// 3) Functions visible to C and C++
|
||||||
|
|
|
@ -52,21 +52,16 @@ FilterWidget2::FilterWidget2(QWidget* parent) :
|
||||||
connect(ui.minVisibility, &StarWidget::valueChanged,
|
connect(ui.minVisibility, &StarWidget::valueChanged,
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
// We need these insane casts because Qt decided to function-overload some of their signals(!).
|
connect(ui.maxAirTemp, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
// QDoubleSpinBox::valueChanged() sends double and QString using the same signal name.
|
|
||||||
// QComboBox::currentIndexChanged() sends int and QString using the same signal name.
|
|
||||||
// Qt 5.7 provides a "convenient" helper that hides this, but only if compiling in C++14
|
|
||||||
// or higher. One can then write: "QOverload<double>(&QDoubleSpinBox::valueChanged)", etc.
|
|
||||||
connect(ui.maxAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.minAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui.minAirTemp, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.maxWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui.maxWaterTemp, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.minWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
connect(ui.minWaterTemp, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.fromDate, &QDateTimeEdit::dateChanged,
|
connect(ui.fromDate, &QDateTimeEdit::dateChanged,
|
||||||
|
@ -84,25 +79,25 @@ FilterWidget2::FilterWidget2(QWidget* parent) :
|
||||||
connect(ui.tags, &QLineEdit::textChanged,
|
connect(ui.tags, &QLineEdit::textChanged,
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.tagsMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui.tagsMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.people, &QLineEdit::textChanged,
|
connect(ui.people, &QLineEdit::textChanged,
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.peopleMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui.peopleMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.location, &QLineEdit::textChanged,
|
connect(ui.location, &QLineEdit::textChanged,
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.locationMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui.locationMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.suit, &QLineEdit::textChanged,
|
connect(ui.suit, &QLineEdit::textChanged,
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.suitMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui.suitMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &FilterWidget2::updateFilter);
|
this, &FilterWidget2::updateFilter);
|
||||||
|
|
||||||
connect(ui.dnotes, &QLineEdit::textChanged,
|
connect(ui.dnotes, &QLineEdit::textChanged,
|
||||||
|
|
Loading…
Add table
Reference in a new issue