Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
b9d3cef2
Commit
b9d3cef2
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
proper use of beginResetModel instead of extra connections
parent
a213a595
No related branches found
Branches containing commit
No related tags found
1 merge request
!2397
InstrumentsSet and SamplesSet based on SetWithModel, which owns a QListModel
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Model/Type/SetWithModel.h
+4
-0
4 additions, 0 deletions
GUI/Model/Type/SetWithModel.h
GUI/View/List/InstrumentsQListView.cpp
+0
-6
0 additions, 6 deletions
GUI/View/List/InstrumentsQListView.cpp
GUI/View/List/SamplesQListView.cpp
+0
-8
0 additions, 8 deletions
GUI/View/List/SamplesQListView.cpp
with
4 additions
and
14 deletions
GUI/Model/Type/SetWithModel.h
+
4
−
0
View file @
b9d3cef2
...
@@ -45,8 +45,10 @@ public:
...
@@ -45,8 +45,10 @@ public:
void
clear
()
void
clear
()
{
{
m_qmodel
->
beginResetModel
();
m_vec
.
clear
();
m_vec
.
clear
();
m_idx
=
-
1
;
m_idx
=
-
1
;
m_qmodel
->
endResetModel
();
emit
SetBase
::
setChanged
();
emit
SetBase
::
setChanged
();
}
}
void
delete_current
()
void
delete_current
()
...
@@ -70,8 +72,10 @@ public:
...
@@ -70,8 +72,10 @@ public:
void
setCurrentIndex
(
size_t
i
)
void
setCurrentIndex
(
size_t
i
)
{
{
ASSERT
(
i
<
m_vec
.
size
()
||
i
==
size_t
(
-
1
));
ASSERT
(
i
<
m_vec
.
size
()
||
i
==
size_t
(
-
1
));
m_qmodel
->
beginResetModel
();
if
(
i
!=
m_idx
)
if
(
i
!=
m_idx
)
m_idx
=
i
;
m_idx
=
i
;
m_qmodel
->
endResetModel
();
emit
SetBase
::
setChanged
();
emit
SetBase
::
setChanged
();
}
}
...
...
This diff is collapsed.
Click to expand it.
GUI/View/List/InstrumentsQListView.cpp
+
0
−
6
View file @
b9d3cef2
...
@@ -27,10 +27,4 @@ InstrumentsQListView::InstrumentsQListView(InstrumentsSet* set)
...
@@ -27,10 +27,4 @@ InstrumentsQListView::InstrumentsQListView(InstrumentsSet* set)
connect
(
this
,
&
QListView
::
clicked
,
connect
(
this
,
&
QListView
::
clicked
,
[
this
,
set
](
const
QModelIndex
&
qi
)
{
set
->
setCurrentIndex
(
qi
.
row
());
});
[
this
,
set
](
const
QModelIndex
&
qi
)
{
set
->
setCurrentIndex
(
qi
.
row
());
});
disconnect
(
gDoc
->
instruments
(),
&
InstrumentsSet
::
setChanged
,
nullptr
,
nullptr
);
connect
(
gDoc
->
instruments
(),
&
InstrumentsSet
::
setChanged
,
[
this
,
set
]
{
setCurrentIndex
(
set
->
model
()
->
index
(
set
->
currentIndex
(),
0
));
repaint
();
});
}
}
This diff is collapsed.
Click to expand it.
GUI/View/List/SamplesQListView.cpp
+
0
−
8
View file @
b9d3cef2
...
@@ -27,12 +27,4 @@ SamplesQListView::SamplesQListView(SamplesSet* set)
...
@@ -27,12 +27,4 @@ SamplesQListView::SamplesQListView(SamplesSet* set)
connect
(
this
,
&
QListView
::
clicked
,
connect
(
this
,
&
QListView
::
clicked
,
[
this
,
set
](
const
QModelIndex
&
qi
)
{
set
->
setCurrentIndex
(
qi
.
row
());
});
[
this
,
set
](
const
QModelIndex
&
qi
)
{
set
->
setCurrentIndex
(
qi
.
row
());
});
disconnect
(
gDoc
->
samples
(),
&
SamplesSet
::
setChanged
,
nullptr
,
nullptr
);
connect
(
gDoc
->
samples
(),
&
SamplesSet
::
setChanged
,
[
this
,
set
]
{
setCurrentIndex
(
set
->
model
()
->
index
(
set
->
currentIndex
(),
0
));
repaint
();
});
// TODO reinvestigate connect(selectionModel(), &QItemSelectionModel::currentChanged,
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment