@@ -39,7 +39,8 @@ RegisterDialog::RegisterDialog(GraphDataModel* pGraphDataModel, SettingsModel* p
3939
4040 /* Except following columns */
4141 _pUi->registerView ->horizontalHeader ()->setSectionResizeMode (GraphDataModel::column::TEXT, QHeaderView::Stretch);
42- _pUi->registerView ->horizontalHeader ()->setSectionResizeMode (GraphDataModel::column::EXPRESSION, QHeaderView::Stretch);
42+ _pUi->registerView ->horizontalHeader ()->setSectionResizeMode (GraphDataModel::column::EXPRESSION,
43+ QHeaderView::Stretch);
4344
4445 auto triggers = QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed;
4546 _pUi->registerView ->setEditTriggers (triggers);
@@ -68,20 +69,23 @@ RegisterDialog::RegisterDialog(GraphDataModel* pGraphDataModel, SettingsModel* p
6869
6970 const QStringList ids = _pSettingsModel->adapterIds ();
7071 const QString adapterId = ids.isEmpty () ? QString () : ids.first ();
71- auto registerPopupMenu = new AddRegisterWidget (_pSettingsModel, adapterId, this );
72- connect (registerPopupMenu, &AddRegisterWidget::graphDataConfigured, this , &RegisterDialog::addRegister);
72+ if (!adapterId.isEmpty ())
73+ {
74+ auto registerPopupMenu = new AddRegisterWidget (_pSettingsModel, adapterId, this );
75+ connect (registerPopupMenu, &AddRegisterWidget::graphDataConfigured, this , &RegisterDialog::addRegister);
7376
74- _registerPopupAction = std::make_unique<QWidgetAction>(this );
75- _registerPopupAction->setDefaultWidget (registerPopupMenu);
76- _pUi->btnAdd ->addAction (_registerPopupAction.get ());
77+ _registerPopupAction = std::make_unique<QWidgetAction>(this );
78+ _registerPopupAction->setDefaultWidget (registerPopupMenu);
79+ _pUi->btnAdd ->addAction (_registerPopupAction.get ());
80+ }
7781}
7882
7983RegisterDialog::~RegisterDialog ()
8084{
8185 delete _pUi;
8286}
8387
84- void RegisterDialog::addRegister (const GraphData & graphData)
88+ void RegisterDialog::addRegister (const GraphData& graphData)
8589{
8690 _pGraphDataModel->add (graphData);
8791}
@@ -93,10 +97,7 @@ void RegisterDialog::addDefaultRegister()
9397
9498void RegisterDialog::activatedCell (QModelIndex modelIndex)
9599{
96- if (
97- (modelIndex.column () == GraphDataModel::column::COLOR)
98- && (modelIndex.row () < _pGraphDataModel->size ())
99- )
100+ if ((modelIndex.column () == GraphDataModel::column::COLOR) && (modelIndex.row () < _pGraphDataModel->size ()))
100101 {
101102 QColor color = QColorDialog::getColor (_pGraphDataModel->color (modelIndex.row ()));
102103
@@ -107,7 +108,7 @@ void RegisterDialog::activatedCell(QModelIndex modelIndex)
107108 }
108109}
109110
110- void RegisterDialog::onRegisterInserted (const QModelIndex & parent, int first, int last)
111+ void RegisterDialog::onRegisterInserted (const QModelIndex& parent, int first, int last)
111112{
112113 Q_UNUSED (parent);
113114 Q_UNUSED (last);
@@ -119,14 +120,14 @@ void RegisterDialog::onRegisterInserted(const QModelIndex &parent, int first, in
119120void RegisterDialog::removeRegisterRow ()
120121{
121122 // get list of selected rows
122- QItemSelectionModel * selected = _pUi->registerView ->selectionModel ();
123+ QItemSelectionModel* selected = _pUi->registerView ->selectionModel ();
123124 QModelIndexList rowList = selected->selectedRows ();
124125
125126 // sort QModelIndexList
126127 // We need to remove the highest rows first
127128 std::sort (rowList.begin (), rowList.end (), &RegisterDialog::sortRegistersLastFirst);
128129
129- foreach (QModelIndex rowIndex, rowList)
130+ foreach (QModelIndex rowIndex, rowList)
130131 {
131132 _pGraphDataModel->removeRow (rowIndex.row ());
132133 }
@@ -169,7 +170,7 @@ int RegisterDialog::selectedRowAfterDelete(int deletedStartIndex, int rowCnt)
169170 return nextSelectedRow;
170171}
171172
172- bool RegisterDialog::sortRegistersLastFirst (const QModelIndex & s1, const QModelIndex & s2)
173+ bool RegisterDialog::sortRegistersLastFirst (const QModelIndex& s1, const QModelIndex& s2)
173174{
174175 return s1.row () > s2.row ();
175176}
0 commit comments