| 156 |
- |
1 |
#include "qmreportwindow.h"
|
| 204 |
- |
2 |
#include <QVariant>
|
|
|
3 |
#include <QApplication>
|
|
|
4 |
#include <QTabWidget>
|
|
|
5 |
#include <QWidget>
|
|
|
6 |
#include <QWebView>
|
| 168 |
david |
7 |
#include <QVBoxLayout>
|
| 204 |
- |
8 |
#include <QButtonGroup>
|
|
|
9 |
#include <QHBoxLayout>
|
|
|
10 |
#include <QLabel>
|
|
|
11 |
#include <QSpacerItem>
|
| 156 |
- |
12 |
|
| 168 |
david |
13 |
#include "consts.h"
|
|
|
14 |
#include "structs.h"
|
|
|
15 |
#include "proto.h"
|
|
|
16 |
|
| 204 |
- |
17 |
QmReportWindow::QmReportWindow(QWidget *parent) : QWidget(parent)
|
| 156 |
- |
18 |
{
|
| 204 |
- |
19 |
QVBoxLayout *verticalLayout;
|
|
|
20 |
|
|
|
21 |
QWidget *widget;
|
|
|
22 |
QHBoxLayout *horizontalLayout_2;
|
|
|
23 |
QHBoxLayout *horizontalLayout;
|
|
|
24 |
//QSpacerItem *horizontalSpacer;
|
|
|
25 |
QLabel *label;
|
|
|
26 |
|
|
|
27 |
verticalLayout = new QVBoxLayout(this);
|
|
|
28 |
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
29 |
tabWidget = new QTabWidget();
|
|
|
30 |
tabWidget->setTabsClosable(true);
|
|
|
31 |
tabWidget->setUsesScrollButtons(true);
|
|
|
32 |
verticalLayout->addWidget(tabWidget);
|
|
|
33 |
|
|
|
34 |
widget = new QWidget();
|
|
|
35 |
horizontalLayout_2 = new QHBoxLayout(widget);
|
|
|
36 |
horizontalLayout = new QHBoxLayout();
|
|
|
37 |
//horizontalLayout->setSpacing(6);
|
|
|
38 |
//horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
39 |
//horizontalLayout->addItem(horizontalSpacer);
|
|
|
40 |
label = new QLabel("Path", widget);
|
|
|
41 |
horizontalLayout->addWidget(label);
|
|
|
42 |
tabPath = new QLineEdit(widget);
|
|
|
43 |
tabPath->setReadOnly(true);
|
|
|
44 |
horizontalLayout->addWidget(tabPath);
|
|
|
45 |
pb_original = new QPushButton("Original",widget);
|
|
|
46 |
horizontalLayout->addWidget(pb_original);
|
|
|
47 |
pb_back = new QPushButton("Back",widget);
|
|
|
48 |
horizontalLayout->addWidget(pb_back);
|
|
|
49 |
pb_print = new QPushButton("Print",widget);
|
|
|
50 |
horizontalLayout->addWidget(pb_print);
|
|
|
51 |
horizontalLayout_2->addLayout(horizontalLayout);
|
|
|
52 |
verticalLayout->addWidget(widget);
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
connect(tabWidget,SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
|
|
56 |
connect(tabWidget,SIGNAL(tabCloseRequested(int)), this, SLOT(deleteTab(int)));
|
|
|
57 |
connect(pb_back,SIGNAL(clicked()), this, SLOT(back()));
|
|
|
58 |
|
| 203 |
- |
59 |
QWebView *webView = new QWebView();
|
| 174 |
- |
60 |
webView->setUrl(QUrl(QString(filepath)+ filebase + "_index.html",QUrl::TolerantMode));
|
|
|
61 |
qDebug("ReportUrl:%s", qPrintable(webView->url().path()));
|
| 204 |
- |
62 |
tabWidget->addTab(webView, "Index");
|
| 168 |
david |
63 |
|
| 204 |
- |
64 |
tabWidget->setCurrentIndex(0);
|
|
|
65 |
tabChanged(0);
|
|
|
66 |
|
| 156 |
- |
67 |
}
|
|
|
68 |
|
| 203 |
- |
69 |
void QmReportWindow::addReport(const QString &report, const QString &name)
|
|
|
70 |
{
|
|
|
71 |
QWebView *webView = NULL;
|
| 204 |
- |
72 |
bool adding = false;
|
|
|
73 |
for( int index = 0; index < tabWidget->count(); index++)
|
| 203 |
- |
74 |
{
|
| 204 |
- |
75 |
if (tabWidget->tabText(index) == name)
|
| 203 |
- |
76 |
{
|
| 204 |
- |
77 |
webView = dynamic_cast<QWebView *>(tabWidget->widget(index));
|
| 203 |
- |
78 |
if (webView)
|
|
|
79 |
{
|
|
|
80 |
qDebug("Reuse Tab:%s", qPrintable(report));
|
|
|
81 |
break;
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
if (webView == NULL)
|
|
|
87 |
{
|
|
|
88 |
webView = new QWebView();
|
| 204 |
- |
89 |
adding = true;
|
| 203 |
- |
90 |
}
|
| 204 |
- |
91 |
|
| 203 |
- |
92 |
webView->setUrl(QUrl(report,QUrl::TolerantMode));
|
| 204 |
- |
93 |
if ( adding )
|
|
|
94 |
{
|
|
|
95 |
int tab = tabWidget->addTab(webView, name);
|
|
|
96 |
tabChanged(tab);
|
|
|
97 |
qDebug("Adding(%d):%s", tab, qPrintable(report));
|
|
|
98 |
}
|
| 203 |
- |
99 |
|
|
|
100 |
}
|
|
|
101 |
|
| 204 |
- |
102 |
void QmReportWindow::deleteTab(int tab)
|
|
|
103 |
{
|
|
|
104 |
qDebug("Delete TAB:%d", tab);
|
|
|
105 |
tabWidget->removeTab(tab);
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
void QmReportWindow::tabChanged(int tab)
|
|
|
109 |
{
|
|
|
110 |
qDebug("Update TAB:%d", tab);
|
|
|
111 |
QWebView *webView = dynamic_cast<QWebView *>(tabWidget->currentWidget());
|
|
|
112 |
if ( webView )
|
|
|
113 |
{
|
|
|
114 |
tabPath->setText( webView->url().path());
|
|
|
115 |
pb_original->setEnabled(true);
|
|
|
116 |
pb_back->setEnabled(true);
|
|
|
117 |
pb_print->setEnabled(true);
|
|
|
118 |
}
|
|
|
119 |
else
|
|
|
120 |
{
|
|
|
121 |
tabPath->setText("");
|
|
|
122 |
pb_original->setEnabled(false);
|
|
|
123 |
pb_back->setEnabled(false);
|
|
|
124 |
pb_print->setEnabled(false);
|
|
|
125 |
}
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
void QmReportWindow::back(void)
|
|
|
129 |
{
|
|
|
130 |
QWebView *webView = dynamic_cast<QWebView *>(tabWidget->currentWidget());
|
|
|
131 |
if ( webView )
|
|
|
132 |
{
|
|
|
133 |
webView->back();
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
|
| 156 |
- |
137 |
QmReportWindow::~QmReportWindow()
|
|
|
138 |
{
|
|
|
139 |
}
|