forked from qt-creator/qt-creator
Aggregation: Use Qt5-style connects
Change-Id: Ifee501f2da7d2834f6ce8a63f85e9fab9c683b5d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
9370e863f8
commit
4ed9b68fbf
@@ -203,7 +203,7 @@ Aggregate::~Aggregate()
|
|||||||
{
|
{
|
||||||
QWriteLocker locker(&lock());
|
QWriteLocker locker(&lock());
|
||||||
foreach (QObject *component, m_components) {
|
foreach (QObject *component, m_components) {
|
||||||
disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
|
disconnect(component, &QObject::destroyed, this, &Aggregate::deleteSelf);
|
||||||
aggregateMap().remove(component);
|
aggregateMap().remove(component);
|
||||||
}
|
}
|
||||||
components = m_components;
|
components = m_components;
|
||||||
@@ -246,7 +246,7 @@ void Aggregate::add(QObject *component)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_components.append(component);
|
m_components.append(component);
|
||||||
connect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
|
connect(component, &QObject::destroyed, this, &Aggregate::deleteSelf);
|
||||||
aggregateMap().insert(component, this);
|
aggregateMap().insert(component, this);
|
||||||
}
|
}
|
||||||
emit changed();
|
emit changed();
|
||||||
@@ -267,7 +267,7 @@ void Aggregate::remove(QObject *component)
|
|||||||
QWriteLocker locker(&lock());
|
QWriteLocker locker(&lock());
|
||||||
aggregateMap().remove(component);
|
aggregateMap().remove(component);
|
||||||
m_components.removeAll(component);
|
m_components.removeAll(component);
|
||||||
disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
|
disconnect(component, &QObject::destroyed, this, &Aggregate::deleteSelf);
|
||||||
}
|
}
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,10 +72,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void deleteSelf(QObject *obj);
|
void deleteSelf(QObject *obj);
|
||||||
|
|
||||||
private:
|
|
||||||
static QHash<QObject *, Aggregate *> &aggregateMap();
|
static QHash<QObject *, Aggregate *> &aggregateMap();
|
||||||
|
|
||||||
QList<QObject *> m_components;
|
QList<QObject *> m_components;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ MyMain::MyMain(QWidget *parent, Qt::WFlags flags)
|
|||||||
: QWidget(parent, flags)
|
: QWidget(parent, flags)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(select(int)));
|
connect(ui.comboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &MyMain::select);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyMain::add(IComboEntry *obj)
|
void MyMain::add(IComboEntry *obj)
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ public:
|
|||||||
|
|
||||||
void add(IComboEntry *obj);
|
void add(IComboEntry *obj);
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void select(int index);
|
void select(int index);
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::mainClass ui;
|
Ui::mainClass ui;
|
||||||
|
|
||||||
QList<IComboEntry *> m_entries;
|
QList<IComboEntry *> m_entries;
|
||||||
|
|||||||
Reference in New Issue
Block a user