forked from qt-creator/qt-creator
DependencyModel: Modernize connections
Change-Id: Ie1eb9802907da2bf82c40dcbf5ce86855540cbbd Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -52,13 +52,13 @@ DependenciesModel::DependenciesModel(Project *project, QObject *parent)
|
|||||||
// We can't select ourselves as a dependency
|
// We can't select ourselves as a dependency
|
||||||
m_projects.removeAll(m_project);
|
m_projects.removeAll(m_project);
|
||||||
|
|
||||||
QObject *sessionManager = SessionManager::instance();
|
SessionManager *sessionManager = SessionManager::instance();
|
||||||
connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
connect(sessionManager, &SessionManager::projectRemoved,
|
||||||
this, SLOT(resetModel()));
|
this, &DependenciesModel::resetModel);
|
||||||
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
connect(sessionManager, &SessionManager::projectAdded,
|
||||||
this, SLOT(resetModel()));
|
this, &DependenciesModel::resetModel);
|
||||||
connect(sessionManager, SIGNAL(sessionLoaded(QString)),
|
connect(sessionManager, &SessionManager::sessionLoaded,
|
||||||
this, SLOT(resetModel()));
|
this, &DependenciesModel::resetModel);
|
||||||
// qDebug()<<"Dependencies Model"<<this<<"for project"<<project<<"("<<project->file()->fileName()<<")";
|
// qDebug()<<"Dependencies Model"<<this<<"for project"<<project<<"("<<project->file()->fileName()<<")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,27 +157,27 @@ QSize DependenciesView::sizeHint() const
|
|||||||
void DependenciesView::setModel(QAbstractItemModel *newModel)
|
void DependenciesView::setModel(QAbstractItemModel *newModel)
|
||||||
{
|
{
|
||||||
if (QAbstractItemModel *oldModel = model()) {
|
if (QAbstractItemModel *oldModel = model()) {
|
||||||
disconnect(oldModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
disconnect(oldModel, &QAbstractItemModel::rowsInserted,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
disconnect(oldModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
disconnect(oldModel, &QAbstractItemModel::rowsRemoved,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
disconnect(oldModel, SIGNAL(modelReset()),
|
disconnect(oldModel, &QAbstractItemModel::modelReset,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
disconnect(oldModel, SIGNAL(layoutChanged()),
|
disconnect(oldModel, &QAbstractItemModel::layoutChanged,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeView::setModel(newModel);
|
QTreeView::setModel(newModel);
|
||||||
|
|
||||||
if (newModel) {
|
if (newModel) {
|
||||||
connect(newModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
|
connect(newModel, &QAbstractItemModel::rowsInserted,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
connect(newModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
|
connect(newModel, &QAbstractItemModel::rowsRemoved,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
connect(newModel, SIGNAL(modelReset()),
|
connect(newModel, &QAbstractItemModel::modelReset,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
connect(newModel, SIGNAL(layoutChanged()),
|
connect(newModel, &QAbstractItemModel::layoutChanged,
|
||||||
this, SLOT(updateSizeHint()));
|
this, &DependenciesView::updateSizeHint);
|
||||||
}
|
}
|
||||||
updateSizeHint();
|
updateSizeHint();
|
||||||
}
|
}
|
||||||
|
@@ -59,10 +59,9 @@ public:
|
|||||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
public slots:
|
private:
|
||||||
void resetModel();
|
void resetModel();
|
||||||
|
|
||||||
private:
|
|
||||||
Project *m_project;
|
Project *m_project;
|
||||||
QList<Project *> m_projects;
|
QList<Project *> m_projects;
|
||||||
};
|
};
|
||||||
@@ -77,10 +76,9 @@ public:
|
|||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
void setModel(QAbstractItemModel *model);
|
void setModel(QAbstractItemModel *model);
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void updateSizeHint();
|
void updateSizeHint();
|
||||||
|
|
||||||
private:
|
|
||||||
QSize m_sizeHint;
|
QSize m_sizeHint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user