Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
5 | diffor | 1 | /* |
2 | * TableView Preview & Print demo |
||
3 | * Copyright (C) 2004-2008 by Gordos Kund / QnD Co Bt. |
||
4 | * |
||
5 | * This library is free software; you can redistribute it and/or |
||
6 | * modify it under the terms of the GNU Lesser General Public |
||
7 | * License as published by the Free Software Foundation; either |
||
8 | * version 2.1 of the License, or (at your option) any later version. |
||
9 | * |
||
10 | * This library is distributed in the hope that it will be useful, |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
13 | * Lesser General Public License for more details. |
||
14 | * |
||
15 | * You should have received a copy of the GNU Lesser General Public |
||
16 | * License along with this library; if not, write to the Free Software |
||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | * Please contact gordos.kund@gmail.com with any questions on this license. |
||
19 | */ |
||
20 | |||
21 | #include "tableprinterexample.h" |
||
22 | #include "custommodel.h" |
||
23 | #include <QMessageBox> |
||
24 | #include <QDebug> |
||
25 | |||
26 | TablePrinterExample::TablePrinterExample( QWidget* parent) : QWidget( parent) |
||
27 | { |
||
28 | grid=TDPreviewDialog::NoGrid; |
||
29 | ui.setupUi(this); |
||
30 | printer= new QPrinter(QPrinter::HighResolution); |
||
31 | CustomModel *model=new CustomModel(this); |
||
32 | ui.tableView->setModel(model); |
||
33 | } |
||
34 | |||
35 | //======================================== |
||
36 | |||
37 | TablePrinterExample::~TablePrinterExample() |
||
38 | { |
||
39 | } |
||
40 | |||
41 | //======================================== |
||
42 | |||
43 | void TablePrinterExample::on_printPushButton_clicked() |
||
44 | { |
||
45 | TDPreviewDialog *dialog = new TDPreviewDialog(ui.tableView,printer,this); |
||
46 | dialog->setGridMode(grid); |
||
47 | dialog->print(); |
||
48 | delete dialog; |
||
49 | } |
||
50 | |||
51 | //======================================== |
||
52 | |||
53 | void TablePrinterExample::on_previewPushButton_clicked() |
||
54 | { |
||
55 | TDPreviewDialog *dialog = new TDPreviewDialog(ui.tableView,printer,this); |
||
56 | dialog->setGridMode(grid); |
||
57 | dialog->exec(); |
||
58 | //do printing here... |
||
59 | //... |
||
60 | delete dialog; |
||
61 | } |
||
62 | |||
63 | //======================================== |
||
64 | |||
65 | void TablePrinterExample::on_comboBox_currentIndexChanged ( int index ) |
||
66 | { |
||
67 | switch (index) |
||
68 | { |
||
69 | case 0: |
||
70 | grid=TDPreviewDialog::NoGrid; |
||
71 | break; |
||
72 | case 1: |
||
73 | grid=TDPreviewDialog::NormalGrid; |
||
74 | break; |
||
75 | case 2: |
||
76 | grid=TDPreviewDialog::AlternateColor; |
||
77 | break; |
||
78 | case 3: |
||
79 | grid= TDPreviewDialog::AlternateWithGrid; |
||
80 | } |
||
81 | } |