Rev 112 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | paul | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'mergedoc.ui' |
||
3 | ** |
||
4 | ** Created: Sam Apr 5 09:30:28 2003 |
||
5 | ** by: The User Interface Compiler ($Id: mergedoc.cpp 118 2003-12-01 22:53:17Z Franz $) |
||
6 | ** |
||
7 | ** WARNING! All changes made in this file will be lost! |
||
8 | ****************************************************************************/ |
||
9 | |||
10 | #include "mergedoc.h" |
||
11 | #include "mergedoc.moc" |
||
12 | #include "customfdialog.h" |
||
13 | #include "scribusXml.h" |
||
14 | #include "config.h" |
||
15 | #include <qcursor.h> |
||
16 | |||
17 | extern QPixmap loadIcon(QString nam); |
||
18 | |||
118 | Franz | 19 | MergeDoc::MergeDoc( QWidget* parent, bool Mpages ) : QDialog( parent, "merge", true, 0 ) |
3 | paul | 20 | { |
21 | setCaption( tr( "Import a Page" ) ); |
||
83 | Franz | 22 | setIcon(loadIcon("AppIcon.png")); |
3 | paul | 23 | Count = 0; |
118 | Franz | 24 | Mpa = Mpages; |
3 | paul | 25 | MergeDocLayout = new QVBoxLayout( this, 11, 6, "MergeDocLayout"); |
26 | textLabel1 = new QLabel( this, "textLabel1" ); |
||
27 | textLabel1->setText( tr( "Document to load:" ) ); |
||
28 | MergeDocLayout->addWidget( textLabel1 ); |
||
29 | layout1 = new QHBoxLayout( 0, 0, 5, "layout1"); |
||
30 | Filename = new QLineEdit( this, "Filename" ); |
||
31 | Filename->setMinimumSize( QSize( 120, 0 ) ); |
||
32 | layout1->addWidget( Filename ); |
||
33 | Change = new QPushButton( this, "Change" ); |
||
34 | Change->setAutoDefault( FALSE ); |
||
35 | Change->setText( tr( "Change..." ) ); |
||
36 | layout1->addWidget( Change ); |
||
37 | MergeDocLayout->addLayout( layout1 ); |
||
38 | |||
39 | Inform = new QLabel( this, "Inform" ); |
||
40 | Inform->setText( tr( "Document contains: 0 Page(s)" ) ); |
||
41 | MergeDocLayout->addWidget( Inform ); |
||
42 | |||
43 | layout2 = new QHBoxLayout( 0, 0, 2, "layout2"); |
||
44 | textLabel3 = new QLabel( this, "textLabel3" ); |
||
45 | textLabel3->setText( tr( "Import Page Nr:" ) ); |
||
46 | layout2->addWidget( textLabel3 ); |
||
118 | Franz | 47 | if (Mpa) |
48 | { |
||
49 | PageNa = new QComboBox( true, this, "Templ" ); |
||
50 | PageNa->setMinimumSize( QSize( 120, 22 ) ); |
||
51 | PageNa->setEditable(false); |
||
52 | PageNa->setEnabled(false); |
||
53 | layout2->addWidget( PageNa ); |
||
54 | } |
||
55 | else |
||
56 | { |
||
57 | PageNr = new QSpinBox( this, "PageNr" ); |
||
58 | PageNr->setMinValue( 1 ); |
||
59 | PageNr->setMaxValue( 2000 ); |
||
60 | PageNr->setValue( 1 ); |
||
61 | PageNr->setEnabled(false); |
||
62 | layout2->addWidget( PageNr ); |
||
63 | } |
||
3 | paul | 64 | MergeDocLayout->addLayout( layout2 ); |
65 | |||
66 | layout3 = new QHBoxLayout( 0, 0, 2, "layout3"); |
||
67 | QSpacerItem* spacer = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
68 | layout3->addItem( spacer ); |
||
69 | Import = new QPushButton( this, "Import" ); |
||
70 | Import->setText( tr( "Import" ) ); |
||
71 | Import->setEnabled(false); |
||
72 | layout3->addWidget( Import ); |
||
73 | QSpacerItem* spacer_2 = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
74 | layout3->addItem( spacer_2 ); |
||
75 | Cancel = new QPushButton( this, "Cancel" ); |
||
76 | Cancel->setDefault( TRUE ); |
||
77 | Cancel->setText( tr( "Cancel" ) ); |
||
78 | layout3->addWidget( Cancel ); |
||
79 | QSpacerItem* spacer_3 = new QSpacerItem( 41, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
||
80 | layout3->addItem( spacer_3 ); |
||
81 | MergeDocLayout->addLayout( layout3 ); |
||
82 | resize( QSize(350, 134).expandedTo(minimumSizeHint()) ); |
||
83 | clearWState( WState_Polished ); |
||
84 | connect( Import, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
||
85 | connect( Cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
||
86 | connect( Change, SIGNAL( clicked() ), this, SLOT( ChangeFile() ) ); |
||
87 | } |
||
88 | |||
89 | /* |
||
90 | * Destroys the object and frees any allocated resources |
||
91 | */ |
||
92 | MergeDoc::~MergeDoc() |
||
93 | { |
||
94 | // no need to delete child widgets, Qt does it all for us |
||
95 | } |
||
96 | |||
97 | void MergeDoc::ChangeFile() |
||
98 | { |
||
99 | QString fn; |
||
118 | Franz | 100 | int dummy; |
101 | bool ret = false; |
||
102 | Count = 0; |
||
3 | paul | 103 | #ifdef HAVE_LIBZ |
61 | paul | 104 | CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;All Files (*)")); |
3 | paul | 105 | #else |
61 | paul | 106 | CustomFDialog dia(this, tr("Open"), tr("Documents (*.sla *.scd);;All Files (*)")); |
3 | paul | 107 | #endif |
108 | if (Filename->text() != "") |
||
109 | dia.setSelection(Filename->text()); |
||
110 | if (dia.exec() == QDialog::Accepted) |
||
111 | { |
||
112 | fn = dia.selectedFile(); |
||
113 | if (!fn.isEmpty()) |
||
114 | { |
||
115 | qApp->setOverrideCursor(QCursor(waitCursor), true); |
||
116 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
118 | Franz | 117 | if (Mpa) |
118 | ret = ss->ReadPageCount(fn, &dummy, &Count); |
||
119 | else |
||
120 | ret = ss->ReadPageCount(fn, &Count, &dummy); |
||
3 | paul | 121 | qApp->setOverrideCursor(QCursor(arrowCursor), true); |
118 | Franz | 122 | if ((ret) && (Count != 0)) |
3 | paul | 123 | { |
124 | Filename->setText(fn); |
||
125 | Import->setEnabled(true); |
||
118 | Franz | 126 | if (Mpa) |
127 | { |
||
128 | PageNa->clear(); |
||
129 | PageNa->setEnabled(true); |
||
130 | PageNa->insertStringList(ss->MNames); |
||
131 | } |
||
132 | else |
||
133 | { |
||
134 | PageNr->setEnabled(true); |
||
135 | PageNr->setValue(1); |
||
136 | PageNr->setMaxValue(Count); |
||
137 | } |
||
112 | Franz | 138 | Inform->setText( tr("Document contains: %1 Page(s)").arg(Count)); |
3 | paul | 139 | } |
140 | delete ss; |
||
141 | } |
||
142 | } |
||
143 | else |
||
144 | { |
||
145 | Filename->setText(""); |
||
146 | Count = 0; |
||
147 | Import->setEnabled(false); |
||
118 | Franz | 148 | if (Mpa) |
149 | { |
||
150 | PageNa->clear(); |
||
151 | PageNa->setEnabled(false); |
||
152 | } |
||
153 | else |
||
154 | { |
||
155 | PageNr->setEnabled(false); |
||
156 | PageNr->setValue(1); |
||
157 | PageNr->setMaxValue(Count); |
||
158 | } |
||
112 | Franz | 159 | Inform->setText( tr("Document contains: %1 Page(s)").arg(Count)); |
3 | paul | 160 | } |
161 | } |
||
162 |