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
ddad5411
Commit
ddad5411
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rm factor spinbox, rm signal
parent
a2424b55
No related branches found
No related tags found
1 merge request
!1649
Generic legacy 1D tables can again be read, now using new modal format dialog (#601)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Import/Legacy1dDialog.cpp
+26
-108
26 additions, 108 deletions
GUI/View/Import/Legacy1dDialog.cpp
GUI/View/Import/Legacy1dDialog.h
+4
-23
4 additions, 23 deletions
GUI/View/Import/Legacy1dDialog.h
with
30 additions
and
131 deletions
GUI/View/Import/Legacy1dDialog.cpp
+
26
−
108
View file @
ddad5411
...
...
@@ -28,7 +28,6 @@
ImportSettings1D
Legacy1dDialog
::
Msettings
=
legacy1D_3cols
;
Legacy1dDialog
::
Legacy1dDialog
()
:
m_allowFactors
(
false
)
{
setWindowTitle
(
"Define legacy input format"
);
setWindowFlags
(
Qt
::
Dialog
);
...
...
@@ -58,40 +57,40 @@ Legacy1dDialog::Legacy1dDialog()
auto
form211
=
new
QFormLayout
;
w21
->
setLayout
(
form211
);
m_
linesToSkipEdit
=
new
QLineEdit
;
form211
->
addRow
(
"Ignore line numbers:"
,
m_
linesToSkipEdit
);
auto
linesToSkipEdit
=
new
QLineEdit
;
form211
->
addRow
(
"Ignore line numbers:"
,
linesToSkipEdit
);
if
(
Msettings
.
linesToSkip
.
empty
())
m_
linesToSkipEdit
->
setPlaceholderText
(
"Example: 1-5, 12"
);
linesToSkipEdit
->
setPlaceholderText
(
"Example: 1-5, 12"
);
else
m_
linesToSkipEdit
->
setText
(
QString
::
fromStdString
(
Msettings
.
linesToSkip
));
connect
(
m_
linesToSkipEdit
,
&
QLineEdit
::
textEdited
,
linesToSkipEdit
->
setText
(
QString
::
fromStdString
(
Msettings
.
linesToSkip
));
connect
(
linesToSkipEdit
,
&
QLineEdit
::
textEdited
,
[
&
p
=
Msettings
](
const
QString
&
text
)
{
p
.
linesToSkip
=
text
.
toStdString
();
});
m_
headerPrefixEdit
=
new
QLineEdit
;
form211
->
addRow
(
"Ignore lines starting with:"
,
m_
headerPrefixEdit
);
auto
headerPrefixEdit
=
new
QLineEdit
;
form211
->
addRow
(
"Ignore lines starting with:"
,
headerPrefixEdit
);
if
(
Msettings
.
headerPrefix
.
empty
())
m_
headerPrefixEdit
->
setPlaceholderText
(
"#,//"
);
headerPrefixEdit
->
setPlaceholderText
(
"#,//"
);
else
m_
headerPrefixEdit
->
setText
(
QString
::
fromStdString
(
Msettings
.
headerPrefix
));
connect
(
m_
headerPrefixEdit
,
&
QLineEdit
::
textEdited
,
headerPrefixEdit
->
setText
(
QString
::
fromStdString
(
Msettings
.
headerPrefix
));
connect
(
headerPrefixEdit
,
&
QLineEdit
::
textEdited
,
[
&
p
=
Msettings
](
const
QString
&
text
)
{
p
.
headerPrefix
=
text
.
toStdString
();
});
m_
separatorCombo
=
new
QComboBox
;
form211
->
addRow
(
"Separator:"
,
m_
separatorCombo
);
m_
separatorCombo
->
addItem
(
"SPACE"
);
m_
separatorCombo
->
addItem
(
"TAB"
);
m_
separatorCombo
->
addItem
(
","
);
m_
separatorCombo
->
addItem
(
";"
);
m_
separatorCombo
->
setCurrentText
(
QString
::
fromStdString
(
Msettings
.
separator
));
connect
(
m_
separatorCombo
,
&
QComboBox
::
currentTextChanged
,
auto
separatorCombo
=
new
QComboBox
;
form211
->
addRow
(
"Separator:"
,
separatorCombo
);
separatorCombo
->
addItem
(
"SPACE"
);
separatorCombo
->
addItem
(
"TAB"
);
separatorCombo
->
addItem
(
","
);
separatorCombo
->
addItem
(
";"
);
separatorCombo
->
setCurrentText
(
QString
::
fromStdString
(
Msettings
.
separator
));
connect
(
separatorCombo
,
&
QComboBox
::
currentTextChanged
,
[
&
p
=
Msettings
](
const
QString
&
text
)
{
p
.
separator
=
text
.
toStdString
();
});
m_
qUnitCombo
=
new
QComboBox
;
form211
->
addRow
(
"Q given in units of:"
,
m_
qUnitCombo
);
m_
qUnitCombo
->
addItem
(
"1/nm"
);
m_
qUnitCombo
->
addItem
(
"1/Å"
);
m_
qUnitCombo
->
setCurrentIndex
((
int
)
Msettings
.
qUnit
);
connect
(
m_
qUnitCombo
,
&
QComboBox
::
currentIndexChanged
,
auto
qUnitCombo
=
new
QComboBox
;
form211
->
addRow
(
"Q given in units of:"
,
qUnitCombo
);
qUnitCombo
->
addItem
(
"1/nm"
);
qUnitCombo
->
addItem
(
"1/Å"
);
qUnitCombo
->
setCurrentIndex
((
int
)
Msettings
.
qUnit
);
connect
(
qUnitCombo
,
&
QComboBox
::
currentIndexChanged
,
[
&
p
=
Msettings
](
int
i
)
{
p
.
qUnit
=
(
QUnit
)
i
;
});
auto
buttonline
=
new
QHBoxLayout
;
...
...
@@ -102,18 +101,9 @@ Legacy1dDialog::Legacy1dDialog()
okButton
->
setDefault
(
true
);
connect
(
okButton
,
&
QPushButton
::
clicked
,
this
,
&
Legacy1dDialog
::
accept
);
allowFactors
(
false
);
connect
(
m_headerPrefixEdit
,
&
QLineEdit
::
textChanged
,
[
this
]()
{
emit
propertiesChanged
();
});
connect
(
m_linesToSkipEdit
,
&
QLineEdit
::
textChanged
,
[
this
]()
{
emit
propertiesChanged
();
});
connect
(
m_separatorCombo
,
&
QComboBox
::
currentTextChanged
,
[
this
]()
{
emit
propertiesChanged
();
});
connect
(
m_enableErrorCheckBox
,
&
QCheckBox
::
stateChanged
,
this
,
&
Legacy1dDialog
::
onErrorEnablingChanged
);
connect
(
m_qUnitCombo
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
[
this
]()
{
emit
propertiesChanged
();
});
// connect(m_enableErrorCheckBox, &QCheckBox::stateChanged, this,
// &Legacy1dDialog::onErrorEnablingChanged);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
// In the following: disable the checkbox before signaling propertyChanged to suppress ghost
...
...
@@ -123,67 +113,13 @@ Legacy1dDialog::Legacy1dDialog()
QSpinBox
*
sb
=
columnSpinBox
(
i
);
if
(
sb
)
sb
->
setEnabled
(
false
);
emit
propertiesChanged
();
if
(
sb
)
sb
->
setEnabled
(
true
);
});
connect
(
factorSpinBox
(
i
),
QOverload
<
double
>::
of
(
&
QDoubleSpinBox
::
valueChanged
),
[
this
,
i
]()
{
QDoubleSpinBox
*
sb
=
factorSpinBox
(
i
);
if
(
sb
)
sb
->
setEnabled
(
false
);
emit
propertiesChanged
();
if
(
sb
)
sb
->
setEnabled
(
true
);
});
}
}
void
Legacy1dDialog
::
allowFactors
(
bool
b
)
{
m_allowFactors
=
b
;
for
(
int
dataType
=
0
;
dataType
<
3
;
dataType
++
)
{
if
(
auto
*
label
=
factorLabel
(
dataType
))
label
->
setVisible
(
b
);
if
(
auto
*
sb
=
factorSpinBox
(
dataType
))
sb
->
setVisible
(
b
);
}
updateErrorEnabling
(
m_enableErrorCheckBox
->
isChecked
());
}
double
Legacy1dDialog
::
factor
(
int
dataType
)
const
{
auto
*
const
sb
=
factorSpinBox
(
dataType
);
return
sb
&&
sb
->
isVisible
()
?
sb
->
value
()
:
1.0
;
}
void
Legacy1dDialog
::
updateErrorEnabling
(
bool
enabled
)
const
{
const
int
lineInLayout
=
2
;
for
(
int
col
=
2
;
col
<
m_gridLayout
->
columnCount
();
col
++
)
{
auto
*
const
layoutItem
=
m_gridLayout
->
itemAtPosition
(
lineInLayout
,
col
);
if
(
layoutItem
)
{
QWidget
*
w
=
layoutItem
->
widget
();
if
(
w
)
{
const
bool
belongsToFactor
=
col
==
factorColumn
||
col
==
factorLabelColumn
;
w
->
setVisible
(
enabled
&&
(
!
belongsToFactor
||
m_allowFactors
));
}
}
}
}
void
Legacy1dDialog
::
onErrorEnablingChanged
()
{
const
bool
isEnabled
=
m_enableErrorCheckBox
->
isChecked
();
updateErrorEnabling
(
isEnabled
);
emit
propertiesChanged
();
}
QSpinBox
*
Legacy1dDialog
::
columnSpinBox
(
int
dataType
)
const
{
const
int
lineInLayout
=
dataType
;
...
...
@@ -192,21 +128,3 @@ QSpinBox* Legacy1dDialog::columnSpinBox(int dataType) const
return
{};
return
dynamic_cast
<
QSpinBox
*>
(
item
->
widget
());
}
QDoubleSpinBox
*
Legacy1dDialog
::
factorSpinBox
(
int
dataType
)
const
{
const
int
lineInLayout
=
dataType
;
QLayoutItem
*
item
=
m_gridLayout
->
itemAtPosition
(
lineInLayout
,
factorColumn
);
if
(
!
item
)
return
{};
return
dynamic_cast
<
QDoubleSpinBox
*>
(
item
->
widget
());
}
QLabel
*
Legacy1dDialog
::
factorLabel
(
int
dataType
)
const
{
const
int
lineInLayout
=
dataType
;
QLayoutItem
*
item
=
m_gridLayout
->
itemAtPosition
(
lineInLayout
,
factorLabelColumn
);
if
(
!
item
)
return
{};
return
dynamic_cast
<
QLabel
*>
(
item
->
widget
());
}
This diff is collapsed.
Click to expand it.
GUI/View/Import/Legacy1dDialog.h
+
4
−
23
View file @
ddad5411
...
...
@@ -25,38 +25,19 @@ class Legacy1dDialog : public QDialog {
public:
Legacy1dDialog
();
//! Factors shall not be supported. However, since the requirements have been there,
//! they are only deactivated. Call allowFactors(true) to enable them.
void
allowFactors
(
bool
b
);
double
factor
(
int
dataType
)
const
;
class
QSpinBox
*
columnSpinBox
(
int
dataType
)
const
;
class
QDoubleSpinBox
*
factorSpinBox
(
int
dataType
)
const
;
class
QGridLayout
*
m_gridLayout
;
class
QCheckBox
*
m_enableErrorCheckBox
;
class
QLineEdit
*
m_headerPrefixEdit
;
class
QLineEdit
*
m_linesToSkipEdit
;
class
QComboBox
*
m_separatorCombo
;
class
QComboBox
*
m_qUnitCombo
;
signals:
void
propertiesChanged
();
class
QLineEdit
*
headerPrefixEdit
;
class
QLineEdit
*
linesToSkipEdit
;
class
QComboBox
*
separatorCombo
;
class
QComboBox
*
qUnitCombo
;
private:
void
updateErrorEnabling
(
bool
enabled
)
const
;
void
onErrorEnablingChanged
();
class
QLabel
*
factorLabel
(
int
dataType
)
const
;
// factors shall not be supported. However, since the requirements have been there,
// they are only deactivated. Call allowFactors(true) to enable them.
bool
m_allowFactors
;
static
const
int
columnColumn
=
3
;
static
const
int
factorLabelColumn
=
4
;
static
const
int
factorColumn
=
factorLabelColumn
+
1
;
static
ImportSettings1D
Msettings
;
};
...
...
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