mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
cleanup: use pointer-to-member style connect for ComboBoxDelegate
This was still using the archaic macro version, because Qt decided to parameter-overload the signals (which turned out to be a horrible idea). However, since we switched to fairly recent Qt this can be solved using the qOverload template. In this case things are a bit more complicated because we overload the corresponding slots. Since we have control over that, let's just disambiguate their names instead of using the cryptic qOverload. While doing this, tighten the access specifiers of the slots. Turn public into private and protected as appropriate. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fc6d99eb93
commit
27505aedfb
2 changed files with 12 additions and 10 deletions
|
@ -112,10 +112,10 @@ QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
|||
comboDelegate->view()->installEventFilter(const_cast<QObject *>(qobject_cast<const QObject *>(this)));
|
||||
QAbstractItemView *comboPopup = comboDelegate->lineEdit()->completer()->popup();
|
||||
comboPopup->setMouseTracking(true);
|
||||
connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString)));
|
||||
connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation()));
|
||||
connect(comboPopup, SIGNAL(entered(QModelIndex)), this, SLOT(testActivation(QModelIndex)));
|
||||
connect(comboPopup, SIGNAL(activated(QModelIndex)), this, SLOT(fakeActivation()));
|
||||
connect(comboDelegate, QOverload<const QString &>::of(&QComboBox::highlighted), this, &ComboBoxDelegate::testActivationString);
|
||||
connect(comboDelegate, QOverload<int>::of(&QComboBox::activated), this, &ComboBoxDelegate::fakeActivation);
|
||||
connect(comboPopup, &QAbstractItemView::entered, this, &ComboBoxDelegate::testActivationIndex);
|
||||
connect(comboPopup, &QAbstractItemView::activated, this, &ComboBoxDelegate::fakeActivation);
|
||||
currCombo.comboEditor = comboDelegate;
|
||||
currCombo.currRow = index.row();
|
||||
currCombo.model = const_cast<QAbstractItemModel *>(index.model());
|
||||
|
@ -138,15 +138,15 @@ QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
|||
* One thing is important, if the user writes a *new* cylinder or weight type, it will
|
||||
* be ADDED to the list, and the user will need to fill the other data.
|
||||
*/
|
||||
void ComboBoxDelegate::testActivation(const QString &currText)
|
||||
void ComboBoxDelegate::testActivationString(const QString &currText)
|
||||
{
|
||||
currCombo.activeText = currText.isEmpty() ? currCombo.comboEditor->currentText() : currText;
|
||||
setModelData(currCombo.comboEditor, currCombo.model, QModelIndex());
|
||||
}
|
||||
|
||||
void ComboBoxDelegate::testActivation(const QModelIndex &currIndex)
|
||||
void ComboBoxDelegate::testActivationIndex(const QModelIndex &currIndex)
|
||||
{
|
||||
testActivation(currIndex.data().toString());
|
||||
testActivationString(currIndex.data().toString());
|
||||
}
|
||||
|
||||
// HACK, send a fake event so Qt thinks we hit 'enter' on the line edit.
|
||||
|
|
|
@ -34,12 +34,14 @@ class ComboBoxDelegate : public QStyledItemDelegate {
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit ComboBoxDelegate(QAbstractItemModel *model, QObject *parent = 0, bool allowEdit = true);
|
||||
public
|
||||
private
|
||||
slots:
|
||||
void testActivation(const QString &currString);
|
||||
void testActivation(const QModelIndex &currIndex);
|
||||
void testActivationString(const QString &currString);
|
||||
void testActivationIndex(const QModelIndex &currIndex);
|
||||
//HACK: try to get rid of this in the future.
|
||||
void fakeActivation();
|
||||
protected
|
||||
slots:
|
||||
virtual void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
||||
private:
|
||||
bool editable;
|
||||
|
|
Loading…
Reference in a new issue