Subversion Repositories svn1

Rev

Rev 211 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 211 Rev 380
Line 8... Line 8...
8
#include <QHBoxLayout>
8
#include <QHBoxLayout>
9
#include <QLabel>
9
#include <QLabel>
10
#include <QSpacerItem>
10
#include <QSpacerItem>
11
#include <QToolBar>
11
#include <QToolBar>
12
#include <QPrintDialog>
12
#include <QPrintDialog>
-
 
13
#include <QPrinter>
13
#include <QPrintPreviewDialog>
14
#include <QPrintPreviewDialog>
-
 
15
#include <QDesktopServices>
14
 
16
 
15
#include <QDirIterator>
17
#include <QDirIterator>
16
#include <QtDebug>
18
#include <QtDebug>
17
 
19
 
18
#include    "consts.h"
20
#include    "consts.h"
19
#include    "structs.h"
21
#include    "structs.h"
20
#include    "proto.h"
22
#include    "proto.h"
21
 
23
 
-
 
24
QmReportWindow *reportWindow = NULL;
-
 
25
 
22
QmReportWindow::QmReportWindow(QWidget *parent) : QWidget(parent)
26
QmReportWindow::QmReportWindow(QWidget *parent) : QWidget(parent)
23
{
27
{
24
    currentWebView = NULL;
28
    currentWebView = NULL;
-
 
29
    currentWebViewPrinter = NULL;
-
 
30
    printPreviewDialog = NULL;
-
 
31
    reportWindow = this;
25
 
32
 
-
 
33
    // Allocate one printer for the entire widget
-
 
34
    // Setting made to the printer will then be used in all reports
-
 
35
    //
-
 
36
    printer = new QPrinter();
-
 
37
    printer->setPageMargins(10,10,10,10,QPrinter::Millimeter);
-
 
38
 
26
    printPreviewDialog = new QPrintPreviewDialog(this);
39
//    printPreviewDialog = new QPrintPreviewDialog(this);
27
    printPreviewDialog->setModal ( true );
40
//    printPreviewDialog->setModal ( true );
28
    connect(printPreviewDialog,SIGNAL(paintRequested(QPrinter *)), this , SLOT(printPreview(QPrinter *)) );
41
//    connect(printPreviewDialog,SIGNAL(paintRequested(QPrinter *)), this , SLOT(printPreview(QPrinter *)) );
29
 
42
 
30
    QVBoxLayout *verticalLayout;
43
    QVBoxLayout *verticalLayout;
31
    QLabel *label;
44
    QLabel *label;
32
    QToolBar *tb;
45
    QToolBar *tb;
33
 
46
 
Line 37... Line 50...
37
    tb = new QToolBar ( "Actions" );
50
    tb = new QToolBar ( "Actions" );
38
    verticalLayout->addWidget(tb);
51
    verticalLayout->addWidget(tb);
39
    pb_original = tb->addAction ( QIcon(":/webkit/inspector/Images/reloadButtonGlyph.png"),"Home", this, SLOT(home()));
52
    pb_original = tb->addAction ( QIcon(":/webkit/inspector/Images/reloadButtonGlyph.png"),"Home", this, SLOT(home()));
40
    pb_back = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/left-32.png"),"Back", this, SLOT(back()));
53
    pb_back = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/left-32.png"),"Back", this, SLOT(back()));
41
    pb_forward = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/right-32.png"),"Forward", this, SLOT(forward()));
54
    pb_forward = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/right-32.png"),"Forward", this, SLOT(forward()));
-
 
55
 
-
 
56
    tb->addSeparator();
-
 
57
    pb_openExternal = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/viewdetailed-32.png" ),"Open in External viewer", this, SLOT(openExternal()));
42
    pb_print = tb->addAction ( QIcon(":/trolltech/dialogs/qprintpreviewdialog/images/print-32.png" ),"Print", this, SLOT(print()));
58
    pb_explore = tb->addAction ( QIcon(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png" ),"Open Location", this, SLOT(openLocation()));
-
 
59
 
43
    tb->addSeparator();
60
    tb->addSeparator();
-
 
61
    pb_print = tb->addAction ( QIcon(":/trolltech/dialogs/qprintpreviewdialog/images/print-32.png" ),"Print", this, SLOT(print()));
-
 
62
    pb_size = new QDoubleSpinBox();
-
 
63
    pb_size->setSingleStep (0.05);
-
 
64
    pb_size->setValue(1.4);
-
 
65
    pb_size->setToolTip("Printer Scaling Size");
-
 
66
    tb->addWidget(pb_size);
44
    label = new QLabel("Path");
67
    label = new QLabel("Path");
45
    tb->addWidget(label);
68
    tb->addWidget(label);
46
    tabPath = new QLineEdit();
69
    tabPath = new QLineEdit();
47
    tabPath->setReadOnly(true);
70
    tabPath->setReadOnly(true);
48
    tb->addWidget(tabPath);
71
    tb->addWidget(tabPath);
Line 53... Line 76...
53
    verticalLayout->addWidget(tabWidget);
76
    verticalLayout->addWidget(tabWidget);
54
 
77
 
55
    connect(tabWidget,SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
78
    connect(tabWidget,SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
56
    connect(tabWidget,SIGNAL(tabCloseRequested(int)), this, SLOT(deleteTab(int)));
79
    connect(tabWidget,SIGNAL(tabCloseRequested(int)), this, SLOT(deleteTab(int)));
57
 
80
 
58
    addReport(QString(filepath)+ filebase + "_index.html", "Index");
81
    addReport(QString(filepath)+ "web/" + filebase + "_index.html", "Index");
-
 
82
    addReport(QString(filepath)+ "web/" + filebase + "_legindex.html", "Master Leg Index");
-
 
83
 
-
 
84
    //addReport(QString(filepath) + "brmr2011_l2_2.txt", "Starters Report 2");
59
    tabWidget->setCurrentIndex(0);
85
    tabWidget->setCurrentIndex(0);
60
 
86
 
61
//    {
87
//    {
62
//        QDirIterator it(":", QDirIterator::Subdirectories);
88
//        QDirIterator it(":", QDirIterator::Subdirectories);
63
//        while (it.hasNext())
89
//        while (it.hasNext())
Line 99... Line 125...
99
        tabChanged(tab);
125
        tabChanged(tab);
100
        //qDebug("Adding(%d):%s", tab, qPrintable(report));
126
        //qDebug("Adding(%d):%s", tab, qPrintable(report));
101
    }
127
    }
102
}
128
}
103
 
129
 
-
 
130
QmWebView *QmReportWindow::newTab(void)
-
 
131
{
-
 
132
    QmWebView *webView = NULL;
-
 
133
    if (reportWindow)
-
 
134
    {
-
 
135
        webView = new QmWebView();
-
 
136
        int tab = reportWindow->tabWidget->addTab(webView, "New");
-
 
137
        webView->setTab(tab);
-
 
138
        reportWindow->tabChanged(tab);
-
 
139
 
-
 
140
    }
-
 
141
    return(webView);
-
 
142
}
-
 
143
 
-
 
144
void QmReportWindow::setTabName(const int tab, const QString &name)
-
 
145
{
-
 
146
    if (reportWindow)
-
 
147
    {
-
 
148
        reportWindow->tabWidget->setTabText(tab, name);
-
 
149
    }
-
 
150
}
-
 
151
 
-
 
152
void QmReportWindow::updateTabPath(void)
-
 
153
{
-
 
154
    if (reportWindow)
-
 
155
    {
-
 
156
        QString target = reportWindow->currentWebView->url().toString();
-
 
157
        target.remove(QRegExp("#.*$"));
-
 
158
        reportWindow->tabPath->setText(target);
-
 
159
    }
-
 
160
}
-
 
161
 
104
void QmReportWindow::deleteTab(int tab)
162
void QmReportWindow::deleteTab(int tab)
105
{
163
{
106
//    qDebug("Delete TAB:%d", tab);
164
//    qDebug("Delete TAB:%d", tab);
107
    tabWidget->removeTab(tab);
165
    tabWidget->removeTab(tab);
108
}
166
}
Line 115... Line 173...
115
 
173
 
116
    pb_original->setEnabled(enable);
174
    pb_original->setEnabled(enable);
117
    pb_back->setEnabled(enable);
175
    pb_back->setEnabled(enable);
118
    pb_forward->setEnabled(enable);
176
    pb_forward->setEnabled(enable);
119
    pb_print->setEnabled(enable);
177
    pb_print->setEnabled(enable);
-
 
178
    pb_explore->setEnabled(enable);
-
 
179
    pb_openExternal->setEnabled(enable);
120
 
180
 
121
    if ( enable )
181
    if ( enable )
122
    {
182
    {
123
        tabPath->setText(currentWebView->homeUrl);
183
        //tabPath->setText(currentWebView->homeUrl);
-
 
184
        //tabPath->setText(currentWebView->url().toString());
-
 
185
        QmReportWindow::updateTabPath();
124
    }
186
    }
125
    else
187
    else
126
    {
188
    {
127
        tabPath->setText("");
189
        tabPath->setText("");
128
    }
190
    }
Line 150... Line 212...
150
     {
212
     {
151
         currentWebView->home();
213
         currentWebView->home();
152
     }
214
     }
153
}
215
}
154
 
216
 
-
 
217
void QmReportWindow::openLocation(void)
-
 
218
{
-
 
219
    if ( currentWebView )
-
 
220
    {
-
 
221
        QString target = tabPath->text();
-
 
222
        target.remove(QRegExp("/[^/]*$"));
-
 
223
        QDesktopServices::openUrl(target);
-
 
224
    }
-
 
225
}
-
 
226
 
-
 
227
void QmReportWindow::openExternal(void)
-
 
228
{
-
 
229
    if ( currentWebView )
-
 
230
    {
-
 
231
        QString target = tabPath->text();
-
 
232
        QDesktopServices::openUrl(target);
-
 
233
    }
-
 
234
}
-
 
235
 
155
void QmReportWindow::print(void)
236
void QmReportWindow::print(void)
156
{
237
{
157
     if ( currentWebView )
238
     if ( currentWebView )
158
     {
239
     {
-
 
240
         // Delete printer preview if we are previewing a different page
-
 
241
         //
-
 
242
         if ( printPreviewDialog /* && currentWebViewPrinter !=  currentWebView */)
-
 
243
         {
-
 
244
             delete printPreviewDialog;
-
 
245
             printPreviewDialog = NULL;
-
 
246
             currentWebViewPrinter = NULL;
-
 
247
         }
-
 
248
 
-
 
249
         // Allocate Printer Preview if we don't have one
-
 
250
         if (printPreviewDialog == NULL)
-
 
251
         {
-
 
252
             currentWebViewPrinter = currentWebView;
-
 
253
             printPreviewDialog = new QPrintPreviewDialog(printer, this);
-
 
254
             printPreviewDialog->setModal ( true );
-
 
255
             printPreviewDialog->setSizeGripEnabled(true);
-
 
256
             printer->setDocName(currentWebView->url().toString());
-
 
257
         }
-
 
258
 
159
//        printPreviewDialog->open(this,SLOT(fred()));
259
//        printPreviewDialog->open(this,SLOT(fred()));
160
         //currentWebView->setStyleSheet("*{font 50px;}");
260
         //currentWebView->setStyleSheet("*{font-size:250%;}");
161
         //currentWebView->setZoomFactor(2.0);
261
         //currentWebView->setZoomFactor(2.0);
-
 
262
         currentWebView->setTextSizeMultiplier ( pb_size->value() );
-
 
263
         qDebug("setTextSizeMultiplier:%f", pb_size->value());
-
 
264
 
-
 
265
         connect(printPreviewDialog,SIGNAL(paintRequested(QPrinter *)), this , SLOT(printPreview(QPrinter *)) );
162
        printPreviewDialog->exec();
266
         printPreviewDialog->exec();
-
 
267
 
-
 
268
         currentWebView->setTextSizeMultiplier ( 1.0 );
163
 
269
 
164
//         QPrintDialog printDialog(this);
270
//         QPrintDialog printDialog(this);
165
//         if (printDialog.exec() == QDialog::Accepted) {
271
//         if (printDialog.exec() == QDialog::Accepted) {
166
//             QPrinter * printer = printDialog.printer();
272
//             QPrinter * printer = printDialog.printer();
167
//             currentWebView->print(printer);
273
//             currentWebView->print(printer);