-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.cpp
61 lines (53 loc) · 1.19 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "test.h"
#include "ui_test.h"
#include <QFileDialog>
Test::Test(QWidget *parent) :
QWidget(parent),
ui(new Ui::Test)
, m_model(nullptr)
, m_separator(QChar::Tabulation)
, m_currentFile(QString())
, m_header(false)
, m_path(".")
{
ui->setupUi(this);
}
Test::~Test()
{
delete ui;
}
void Test::on_lineEdit_editingFinished()
{
if(ui->lineEdit->text().isEmpty())
{
m_separator = QChar::Tabulation;
}
else
{
m_separator = ui->lineEdit->text().at(0);
}
}
void Test::on_checkBox_stateChanged(int arg1)
{
Q_UNUSED(arg1)
m_header = ui->checkBox->isChecked();
}
void Test::on_pushButtonReload_clicked()
{
if(!m_currentFile.isEmpty())
{
QFileInfo m(m_currentFile);
m_path = m.path();
if(m_model != nullptr)
{
delete m_model;
}
m_model = new CSVTableModel(m_currentFile, this->m_separator, this->m_header, ui->tableView);
ui->tableView->setModel(m_model);
}
}
void Test::on_pushButtonOpen_clicked()
{
m_currentFile = QFileDialog::getOpenFileName(this, tr("Open File"), m_path, tr("Image Files (*.csv *.txt)"));
on_pushButtonReload_clicked();
}