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
9fe299d0
Commit
9fe299d0
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
ditto via new methods in SetWithModel
parent
e9cfc6a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2405
Update instrument & sample lists after change of name or description
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Type/SetWithModel.h
+18
-4
18 additions, 4 deletions
GUI/Model/Type/SetWithModel.h
GUI/View/Views/InstrumentView.cpp
+4
-8
4 additions, 8 deletions
GUI/View/Views/InstrumentView.cpp
with
22 additions
and
12 deletions
GUI/Model/Type/SetWithModel.h
+
18
−
4
View file @
9fe299d0
...
...
@@ -102,11 +102,19 @@ public:
emit
AbstractSetModel
::
setChanged
();
}
//! To be called when name or description of the current item have changed.
void
currentDataChanged
()
void
setCurrentName
(
const
QString
&
s
)
{
QModelIndex
qi
=
m_qmodel
->
index
(
m_idx
,
0
);
m_qmodel
->
dataChanged
(
qi
,
qi
,
QVector
<
int
>
({
Qt
::
DisplayRole
,
Qt
::
EditRole
}));
if
(
s
!=
currentItem
()
->
name
())
{
currentItem
()
->
setName
(
s
);
currentDataChanged
();
}
}
void
setCurrentDescription
(
const
QString
&
s
)
{
if
(
s
!=
currentItem
()
->
description
())
{
currentItem
()
->
setDescription
(
s
);
currentDataChanged
();
}
}
size_t
currentIndex
()
const
{
return
m_idx
;
}
...
...
@@ -148,6 +156,12 @@ private:
if
(
m_idx
==
m_vec
.
size
())
m_idx
=
m_vec
.
size
()
-
1
;
}
//! To be called when name or description of the current item have changed.
void
currentDataChanged
()
{
QModelIndex
qi
=
m_qmodel
->
index
(
m_idx
,
0
);
m_qmodel
->
dataChanged
(
qi
,
qi
,
QVector
<
int
>
({
Qt
::
DisplayRole
,
Qt
::
EditRole
}));
}
OwningVector
<
T
>
m_vec
;
size_t
m_idx
=
-
1
;
//!< current index, or -1 for empty set
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Views/InstrumentView.cpp
+
4
−
8
View file @
9fe299d0
...
...
@@ -165,11 +165,8 @@ QWidget* InstrumentView::createEditor(InstrumentItem* t)
layout
->
addWidget
(
g
);
auto
*
nameEdit
=
new
QLineEdit
(
t
->
name
(),
g
);
connect
(
nameEdit
,
&
QLineEdit
::
textEdited
,
[
this
,
t
](
const
QString
&
text
)
{
if
(
text
!=
t
->
name
())
{
t
->
setName
(
text
);
m_set
->
currentDataChanged
();
}
connect
(
nameEdit
,
&
QLineEdit
::
textEdited
,
[
this
](
const
QString
&
text
)
{
m_set
->
setCurrentName
(
text
);
});
formLayout
->
addRow
(
"Name:"
,
nameEdit
);
...
...
@@ -179,9 +176,8 @@ QWidget* InstrumentView::createEditor(InstrumentItem* t)
descriptionEdit
->
setAcceptRichText
(
false
);
descriptionEdit
->
setTabChangesFocus
(
true
);
descriptionEdit
->
setPlainText
(
t
->
description
());
connect
(
descriptionEdit
,
&
QTextEdit
::
textChanged
,
[
this
,
t
,
descriptionEdit
]
{
t
->
setDescription
(
descriptionEdit
->
toPlainText
());
m_set
->
currentDataChanged
();
connect
(
descriptionEdit
,
&
QTextEdit
::
textChanged
,
[
this
,
descriptionEdit
]
{
m_set
->
setCurrentDescription
(
descriptionEdit
->
toPlainText
());
});
formLayout
->
addRow
(
"Description:"
,
descriptionEdit
);
...
...
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