-
Notifications
You must be signed in to change notification settings - Fork 52
/
MainWindow.cpp
60 lines (51 loc) · 1.5 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
#include "MainWindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QDebug>
#include <QKeySequence>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
openShortcut(QKeySequence::Open, this, SLOT(onOpenFile())),
m_currentH264Model(NULL)
{
ui->setupUi(this);
connect(ui->openPushButton, SIGNAL(clicked()), this, SLOT(onOpenFile()));
connect(ui->nalTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(onNalTableItemClicked(QModelIndex)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::onOpenFile()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Open H264 file"), ".", tr("H264 Files (*.h264 *.264)"));
QFileInfo fileInfo(filename);
ui->filePathLineEdit->setText(fileInfo.absoluteFilePath());
H264NALListModel *oldModel = NULL;
if (m_currentH264Model)
{
oldModel = m_currentH264Model;
}
m_currentH264Model = new H264NALListModel(filename, this);
ui->nalTableView->setModel(m_currentH264Model);
/*
for (int c = 0; c < ui->nalTableView->horizontalHeader()->count(); ++c)
{
ui->nalTableView->horizontalHeader()->setSectionResizeMode(c, QHeaderView::Stretch);
}
*/
if (oldModel)
{
delete oldModel;
}
}
void MainWindow::onNalTableItemClicked(QModelIndex index)
{
if (m_currentH264Model)
{
ui->nalPlainTextEdit->setPlainText(m_currentH264Model->data(index, Qt::UserRole).toString());
}
}