Commit 2febbc1c authored by Ben Boeckel's avatar Ben Boeckel

qtFileItem: remove usage of the deprecated QSignalMapper

parent 60ec14ff
Pipeline #158302 failed with stages
in 15 minutes and 50 seconds
......@@ -24,7 +24,6 @@
#include <QLineEdit>
#include <QPointer>
#include <QPushButton>
#include <QSignalMapper>
#include <QSizePolicy>
#include <QTextEdit>
#include <QToolButton>
......@@ -86,7 +85,6 @@ public:
// for extensible items
QMap<QToolButton*, QPair<QPointer<QLayout>, QPointer<QWidget> > > ExtensibleMap;
QPointer<QSignalMapper> SignalMapper;
QList<QToolButton*> MinusButtonIndices;
QPointer<QToolButton> AddItemButton;
};
......@@ -107,7 +105,6 @@ qtFileItem::qtFileItem(const qtAttributeItemInfo& info)
this->Internals = new qtFileItemInternals;
this->Internals->IsDirectory =
(m_itemInfo.item()->type() == smtk::attribute::Item::DirectoryType);
this->Internals->SignalMapper = new QSignalMapper();
m_isLeafItem = true;
this->Internals->VectorItemOrient = Qt::Horizontal;
this->createWidget();
......@@ -294,34 +291,19 @@ QWidget* qtFileItem::createFileBrowseWidget(int elementIdx,
m_itemInfo.uiManager()->setWidgetColorToInvalid(fileTextWidget);
}
QObject::connect(
fileBrowserButton, SIGNAL(clicked()), this->Internals->SignalMapper, SLOT(map()));
this->Internals->SignalMapper->setMapping(fileBrowserButton, fileBrowserButton);
// We use a QSignalMapper here to connect our signal, which comes from one of
// potentially several lineEdits, fileCombos or fileBrowserButtons, to our
// slot, which is the method setActiveField(QWidget*). This way,
// setActiveField can tag the appropriate field to be used within
// onInputValueChanged().
//
// TODO: This may be handled more elegantly using lambda expressions as
// slots.
if (lineEdit)
{
QObject::connect(
lineEdit, SIGNAL(textChanged(const QString&)), this->Internals->SignalMapper, SLOT(map()));
this->Internals->SignalMapper->setMapping(lineEdit, lineEdit);
lineEdit, SIGNAL(textChanged(const QString&)), [this] { setActiveField(lineEdit) });
QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(onInputValueChanged()));
this->Internals->SignalMapper->setMapping(fileBrowserButton, lineEdit);
QObject::connect(fileBrowserButton, SIGNAL(clicked()), [this] { setActiveField(lineEdit) });
if (this->Internals->fileExtCombo)
{
QObject::connect(this->Internals->fileExtCombo, SIGNAL(currentTextChanged(const QString&)),
this->Internals->SignalMapper, SLOT(map()));
[this] { setActiveField(lineEdit) });
QObject::connect(this->Internals->fileExtCombo, SIGNAL(currentIndexChanged(int)),
this->Internals->SignalMapper, SLOT(map()));
this->Internals->SignalMapper->setMapping(this->Internals->fileExtCombo, lineEdit);
[this] { setActiveField(lineEdit) });
QObject::connect(this->Internals->fileExtCombo, SIGNAL(currentIndexChanged(int)), this,
SLOT(onInputValueChanged()));
......@@ -329,21 +311,23 @@ QWidget* qtFileItem::createFileBrowseWidget(int elementIdx,
}
else if (fileCombo)
{
QObject::connect(fileCombo, SIGNAL(editTextChanged(const QString&)),
this->Internals->SignalMapper, SLOT(map()));
QObject::connect(
fileCombo, SIGNAL(currentIndexChanged(int)), this->Internals->SignalMapper, SLOT(map()));
this->Internals->SignalMapper->setMapping(fileCombo, fileCombo);
fileCombo, SIGNAL(editTextChanged(const QString&)), [this] { setActiveField(fileCombo) });
QObject::connect(
fileCombo, SIGNAL(currentIndexChanged(int)), [this] { setActiveField(fileCombo) });
QObject::connect(
fileCombo->lineEdit(), SIGNAL(editingFinished()), this, SLOT(onInputValueChanged()));
QObject::connect(
fileCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onInputValueChanged()));
this->Internals->SignalMapper->setMapping(fileBrowserButton, fileCombo);
QObject::connect(fileBrowserButton, SIGNAL(clicked()), [this] { setActiveField(fileCombo) });
}
else
{
QObject::connect(
fileBrowserButton, SIGNAL(clicked()), [this] { setActiveField(fileBrowserButton) });
}
QObject::connect(
this->Internals->SignalMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveField(QWidget*)));
QObject::connect(fileBrowserButton, SIGNAL(clicked()), this, SLOT(onLaunchFileBrowser()));
return frame;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment