CPoiListDialog: Make use of Qt 5 signals and slots
This commit is contained in:
parent
8f0a3669d4
commit
9c4c387696
|
@ -26,7 +26,7 @@ class CPoiListModel : public QAbstractListModel
|
||||||
QList<CScriptNode*> mObjList;
|
QList<CScriptNode*> mObjList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPoiListModel(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = 0)
|
CPoiListModel(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = nullptr)
|
||||||
: QAbstractListModel(pParent)
|
: QAbstractListModel(pParent)
|
||||||
, mpPoiTemplate(pPoiTemplate)
|
, mpPoiTemplate(pPoiTemplate)
|
||||||
{
|
{
|
||||||
|
@ -41,12 +41,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rowCount(const QModelIndex&) const
|
int rowCount(const QModelIndex&) const override
|
||||||
{
|
{
|
||||||
return mObjList.size();
|
return mObjList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(const QModelIndex& rkIndex, int Role) const
|
QVariant data(const QModelIndex& rkIndex, int Role) const override
|
||||||
{
|
{
|
||||||
if (!rkIndex.isValid()) return QVariant::Invalid;
|
if (!rkIndex.isValid()) return QVariant::Invalid;
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ public:
|
||||||
|
|
||||||
if (Role == Qt::DecorationRole)
|
if (Role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
CScriptNode *pNode = mObjList[rkIndex.row()];
|
const CScriptNode *pNode = mObjList[rkIndex.row()];
|
||||||
CScan *pScan = static_cast<CPointOfInterestExtra*>(pNode->Extra())->GetScan();
|
const CScan *pScan = static_cast<CPointOfInterestExtra*>(pNode->Extra())->GetScan();
|
||||||
bool IsImportant = (pScan ? pScan->IsCriticalPropertyRef() : false);
|
const bool IsImportant = (pScan ? pScan->IsCriticalPropertyRef() : false);
|
||||||
|
|
||||||
if (IsImportant)
|
if (IsImportant)
|
||||||
return QIcon(":/icons/POI Important.svg");
|
return QIcon(QStringLiteral(":/icons/POI Important.svg"));
|
||||||
else
|
else
|
||||||
return QIcon(":/icons/POI Normal.svg");
|
return QIcon(QStringLiteral(":/icons/POI Normal.svg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
|
@ -86,7 +86,7 @@ class CPoiListDialog : public QDialog
|
||||||
QDialogButtonBox *mpButtonBox;
|
QDialogButtonBox *mpButtonBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPoiListDialog(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = 0)
|
CPoiListDialog(CScriptTemplate *pPoiTemplate, CPoiMapModel *pMapModel, CScene *pScene, QWidget *pParent = nullptr)
|
||||||
: QDialog(pParent)
|
: QDialog(pParent)
|
||||||
, mSourceModel(pPoiTemplate, pMapModel, pScene)
|
, mSourceModel(pPoiTemplate, pMapModel, pScene)
|
||||||
{
|
{
|
||||||
|
@ -106,14 +106,14 @@ public:
|
||||||
mpListView->setModel(&mModel);
|
mpListView->setModel(&mModel);
|
||||||
mModel.sort(0);
|
mModel.sort(0);
|
||||||
|
|
||||||
setWindowTitle("Add POIs");
|
setWindowTitle(tr("Add POIs"));
|
||||||
mpListView->setEditTriggers(QListView::NoEditTriggers);
|
mpListView->setEditTriggers(QListView::NoEditTriggers);
|
||||||
mpListView->setSelectionMode(QListView::ExtendedSelection);
|
mpListView->setSelectionMode(QListView::ExtendedSelection);
|
||||||
mpListView->setVerticalScrollMode(QListView::ScrollPerPixel);
|
mpListView->setVerticalScrollMode(QListView::ScrollPerPixel);
|
||||||
|
|
||||||
connect(mpListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnOkClicked()));
|
connect(mpListView, &QListView::doubleClicked, this, &CPoiListDialog::OnOkClicked);
|
||||||
connect(mpButtonBox, SIGNAL(accepted()), this, SLOT(OnOkClicked()));
|
connect(mpButtonBox, &QDialogButtonBox::accepted, this, &CPoiListDialog::OnOkClicked);
|
||||||
connect(mpButtonBox, SIGNAL(rejected()), this, SLOT(OnCancelClicked()));
|
connect(mpButtonBox, &QDialogButtonBox::rejected, this, &CPoiListDialog::OnCancelClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<CScriptNode*>& Selection() const
|
const QList<CScriptNode*>& Selection() const
|
||||||
|
|
Loading…
Reference in New Issue