-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
executable file
·117 lines (106 loc) · 2.56 KB
/
mainwindow.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QVBoxLayout>
#include <QTableView>
#include "setdialog.h"
#include <QSettings>
double A ;
double B ;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// uchar buf[100] ;
// for(int i = 0; i< 100 ;i++)
// {
// if(i%2)
// buf[i] = 1;
// else
// buf[i] = 0 ;
// }
// QFile file("1#2010-01-06 08-33-11.dat",this);
// file.open(QIODevice::WriteOnly);
// for(int i= 0 ;i<500 ;i++)
// file.write((const char*)buf,100);
// file.flush();
// file.close();
QSettings set ;
A = set.value("A").toDouble();
B = set.value("B").toDouble();
ui->setupUi(this);
dataTabs = new QTabWidget(this);
setCentralWidget(dataTabs);
dataTabs->setTabsClosable(true);
}
MainWindow::~MainWindow()
{
dataTabs->clear();
delete ui;
}
bool MainWindow::loadData(QString filePath)
{
return true ;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::addNewTab(QString fileName)
{
MyWidget *pNew = new MyWidget(fileName,dataTabs);
dataTabs->addTab(pNew,fileName);
connect(dataTabs, SIGNAL(tabCloseRequested(int)), SLOT(onTabClose(int)));
}
void MainWindow::on_actionOpen_triggered()
{
QString fileName = QFileDialog::getOpenFileName(this);
if(fileName.isEmpty())
return ;
QString name = fileName.right(fileName.length()-fileName.indexOf("#")-1);
QString timename = name.left(name.length()-4);
QDateTime startTime=QDateTime::fromString(timename,"yyyy-MM-dd hh-mm-ss");
if(startTime.isValid()==false)
{
QMessageBox::critical(this,"error","wrong file name");
return;
}
if(loadData(fileName))
{
addNewTab(fileName);
}
}
void MainWindow::onTabClose(int tabNum)
{
// if (tabWidget->widget(tabNum) == containerWidget)
// deleteLater();
dataTabs->removeTab(tabNum);
}
void MainWindow::on_actionExit_triggered()
{
close();
}
void MainWindow::on_actionSet_triggered()
{
SetDialog dlg(this);
// dlg.setVar(A,B);
if(QDialog::Accepted==dlg.exec())
{
// dlg.getVar(&A,&B);
// QSettings set ;
// set.setValue("A",A);
// set.setValue("B",B);
}
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this,"About Analyzer","Copyright 2010.Analyze data tools ");
}