-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextviewer.cc
62 lines (56 loc) · 1.52 KB
/
textviewer.cc
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 "textviewer.h"
#include "ui_textviewer.h"
#include <QFileSystemModel>
#include <QMouseEvent>
TextViewer::TextViewer(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::TextViewer)
{
ui->setupUi(this);
this->setWindowIcon(QIcon(":/icon/QGOPDD.ico"));
ui->mdiArea->setTabsMovable(true);
this->setWindowTitle("Rinex Viewer");
// setCentralWidget(ui->mdiArea);
setWindowState(Qt::WindowMaximized);
}
void TextViewer::SetDirname(QString dirname) {
this->dirname_ = dirname;
ui->lineEdit->setText(dirname);
this->file_model_ = new QFileSystemModel(this);
this->file_model_->setRootPath(dirname);
qDebug() << this->file_model_->rootDirectory();
ui->treeView->setModel(this->file_model_);
ui->treeView->setRootIndex(this->file_model_->index(dirname));
ui->treeView->show();
// ui->treeView->show();
qDebug() << dirname;
}
TextViewer::~TextViewer()
{
delete ui;
}
void TextViewer::on_treeView_doubleClicked(const QModelIndex &index)
{
if (index.column() == 0) {
TFormDoc* t = new TFormDoc();
auto ind = index;
QString data;
while (true) {
auto da = ind.data();
auto pa = ind.parent();
// if (dirname_.contains((pa.data().toString()))) {
// break;
// }
data = "/" + da.toString() + data;
ind = pa;
if (dirname_.contains((pa.data().toString()))) {
break;
}
}
qDebug() << data;
qDebug() << this->dirname_ + data;
t->LoadFromFile(this->dirname_ + "/" + data);
ui->mdiArea->addSubWindow(t);
t->show();
}
}