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
ad587afa
Commit
ad587afa
authored
6 years ago
by
Juan Manuel Carmona Loaiza
Browse files
Options
Downloads
Patches
Plain Diff
Reload csv on separator change
parent
42c7aa27
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.cpp
+16
-3
16 additions, 3 deletions
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.cpp
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.h
+1
-0
1 addition, 0 deletions
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.h
with
17 additions
and
3 deletions
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.cpp
+
16
−
3
View file @
ad587afa
...
@@ -95,7 +95,7 @@ QBoxLayout* CsvImportAssistant::createLayout()
...
@@ -95,7 +95,7 @@ QBoxLayout* CsvImportAssistant::createLayout()
m_separatorField
=
new
QLineEdit
(
QString
(
""
));
m_separatorField
=
new
QLineEdit
(
QString
(
""
));
m_separatorField
->
setMaxLength
(
1
);
m_separatorField
->
setMaxLength
(
1
);
m_separatorField
->
setMaximumWidth
(
50
);
m_separatorField
->
setMaximumWidth
(
50
);
connect
(
m_separatorField
,
&
QLineEdit
::
editingFinished
,
this
,
&
CsvImportAssistant
::
R
eload
);
connect
(
m_separatorField
,
&
QLineEdit
::
editingFinished
,
this
,
&
CsvImportAssistant
::
r
eload
CsvFile
);
//First Row SpinBox
//First Row SpinBox
m_firstDataRowSpinBox
=
new
QSpinBox
();
m_firstDataRowSpinBox
=
new
QSpinBox
();
...
@@ -133,7 +133,7 @@ QBoxLayout* CsvImportAssistant::createLayout()
...
@@ -133,7 +133,7 @@ QBoxLayout* CsvImportAssistant::createLayout()
auto
tableLayout
=
new
QVBoxLayout
;
auto
tableLayout
=
new
QVBoxLayout
;
tableLayout
->
setMargin
(
10
);
tableLayout
->
setMargin
(
10
);
tableLayout
->
addWidget
(
new
QLabel
(
"Right click on the table or use the controls below to modify what will be imported"
));
tableLayout
->
addWidget
(
new
QLabel
(
"Right click on the table or use the controls below to modify what will be imported"
));
tableLayout
->
addWidget
(
m_columnTypeSelector
);
//
tableLayout->addWidget(m_columnTypeSelector);
tableLayout
->
addWidget
(
m_tableWidget
);
tableLayout
->
addWidget
(
m_tableWidget
);
//place separator_field, single_column_spinbox and first_row:
//place separator_field, single_column_spinbox and first_row:
...
@@ -177,6 +177,19 @@ void CsvImportAssistant::Reload()
...
@@ -177,6 +177,19 @@ void CsvImportAssistant::Reload()
}
}
}
}
void
CsvImportAssistant
::
reloadCsvFile
(){
reset
();
try
{
if
(
!
m_fileName
.
isEmpty
())
m_csvFile
=
std
::
make_unique
<
CSVFile
>
(
m_fileName
.
toStdString
(),
separator
());
}
catch
(...)
{
showErrorMessage
(
"There was a problem opening the file
\"
"
+
m_fileName
.
toStdString
()
+
"
\"
"
);
return
;
}
Reload
();
}
void
CsvImportAssistant
::
onRejectButton
(){
void
CsvImportAssistant
::
onRejectButton
(){
reject
();
reject
();
}
}
...
@@ -188,7 +201,7 @@ void CsvImportAssistant::onImportButton()
...
@@ -188,7 +201,7 @@ void CsvImportAssistant::onImportButton()
auto
data
=
getData
();
auto
data
=
getData
();
accept
();
accept
();
}
catch
(
std
::
exception
&
e
){
}
catch
(
std
::
exception
&
e
){
QString
message
=
QString
(
"Unable to import,
check
the following e
rror message may help
:
\n
"
)
+
QString
::
fromStdString
(
e
.
what
());
QString
message
=
QString
(
"Unable to import, the following e
xception was thrown
:
\n
"
)
+
QString
::
fromStdString
(
e
.
what
());
QMessageBox
::
warning
(
nullptr
,
"Wrong data format"
,
message
);
QMessageBox
::
warning
(
nullptr
,
"Wrong data format"
,
message
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant.h
+
1
−
0
View file @
ad587afa
...
@@ -57,6 +57,7 @@ private:
...
@@ -57,6 +57,7 @@ private:
QBoxLayout
*
createFileDetailsLayout
();
QBoxLayout
*
createFileDetailsLayout
();
char
guessSeparator
()
const
;
char
guessSeparator
()
const
;
void
reloadCsvFile
();
void
generate_table
();
void
generate_table
();
void
set_table_data
(
std
::
vector
<
std
::
vector
<
std
::
string
>>
dataArray
);
void
set_table_data
(
std
::
vector
<
std
::
vector
<
std
::
string
>>
dataArray
);
void
removeBlankColumns
(
std
::
vector
<
std
::
vector
<
std
::
string
>>
&
dataArray
);
void
removeBlankColumns
(
std
::
vector
<
std
::
vector
<
std
::
string
>>
&
dataArray
);
...
...
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