Rev 18921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
10200 | cbradney | 7 | |
10859 | cbradney | 8 | #include <QEvent> |
8708 | fschmid | 9 | #include <QHeaderView> |
10200 | cbradney | 10 | #include <QHelpEvent> |
11 | #include <QImage> |
||
8501 | cbradney | 12 | #include <QLabel> |
10200 | cbradney | 13 | #include <QLayout> |
8708 | fschmid | 14 | #include <QList> |
10200 | cbradney | 15 | #include <QMenu> |
16 | #include <QMessageBox> |
||
8501 | cbradney | 17 | #include <QResizeEvent> |
10200 | cbradney | 18 | #include <QToolTip> |
19 | #include <QVariant> |
||
9514 | fschmid | 20 | #include <QWidgetAction> |
12378 | fschmid | 21 | #include <QShortcut> |
1460 | cbradney | 22 | |
10200 | cbradney | 23 | #include "actionmanager.h" |
11264 | fschmid | 24 | #include "canvasmode.h" |
2952 | cbradney | 25 | #include "commonstrings.h" |
11405 | cbradney | 26 | #include "contextmenu.h" |
10862 | cbradney | 27 | #include "outlinepalette.h" |
3670 | cbradney | 28 | #include "page.h" |
10862 | cbradney | 29 | #include "propertiespalette.h" |
173 | Franz | 30 | #include "scribus.h" |
8241 | fschmid | 31 | #include "selection.h" |
32 | #include "undomanager.h" |
||
10200 | cbradney | 33 | #include "util.h" |
10862 | cbradney | 34 | #include "util_color.h" |
10212 | cbradney | 35 | #include "util_formats.h" |
10200 | cbradney | 36 | #include "util_icon.h" |
1460 | cbradney | 37 | |
10862 | cbradney | 38 | |
10066 | cbradney | 39 | OutlineTreeItem::OutlineTreeItem(OutlineTreeItem* parent, OutlineTreeItem* after) : QTreeWidgetItem(parent, after) |
8217 | fschmid | 40 | { |
41 | PageObject = NULL; |
||
42 | PageItemObject = NULL; |
||
43 | type = -1; |
||
44 | } |
||
45 | |||
10066 | cbradney | 46 | OutlineTreeItem::OutlineTreeItem(QTreeWidget* parent, OutlineTreeItem* after) : QTreeWidgetItem(parent, after) |
8217 | fschmid | 47 | { |
48 | PageObject = NULL; |
||
49 | PageItemObject = NULL; |
||
50 | type = -1; |
||
51 | } |
||
52 | |||
10862 | cbradney | 53 | OutlineWidget::OutlineWidget(QWidget* parent) : QTreeWidget(parent) |
9598 | fschmid | 54 | { |
55 | } |
||
56 | |||
14404 | jghali | 57 | void OutlineWidget::selectItems(QList<QTreeWidgetItem*> items) |
58 | { |
||
59 | QItemSelection itemSelection; |
||
60 | for (int i = 0; i < items.count(); ++i) |
||
61 | { |
||
62 | QModelIndex index = this->indexFromItem(items.at(i)); |
||
63 | if (index.isValid()) |
||
64 | { |
||
65 | itemSelection.select(index, index); |
||
66 | } |
||
67 | } |
||
68 | selectionModel()->select(itemSelection, QItemSelectionModel::Select); |
||
69 | } |
||
70 | |||
10862 | cbradney | 71 | bool OutlineWidget::viewportEvent(QEvent *event) |
9598 | fschmid | 72 | { |
73 | if (event->type() == QEvent::ToolTip) |
||
74 | { |
||
75 | QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); |
||
76 | QTreeWidgetItem* it = itemAt(helpEvent->pos()); |
||
77 | if (it != 0) |
||
78 | { |
||
10066 | cbradney | 79 | OutlineTreeItem *item = (OutlineTreeItem*)it; |
9598 | fschmid | 80 | if (item != NULL) |
81 | { |
||
11587 | cbradney | 82 | QString tipText(""); |
9598 | fschmid | 83 | if ((item->type == 1) || (item->type == 3) || (item->type == 4)) |
84 | { |
||
85 | PageItem *pgItem = item->PageItemObject; |
||
86 | switch (pgItem->itemType()) |
||
87 | { |
||
88 | case PageItem::ImageFrame: |
||
11264 | fschmid | 89 | if (pgItem->asLatexFrame()) |
11587 | cbradney | 90 | tipText = CommonStrings::itemType_LatexFrame; |
11264 | fschmid | 91 | else |
11587 | cbradney | 92 | tipText = CommonStrings::itemType_ImageFrame; |
9598 | fschmid | 93 | break; |
94 | case PageItem::TextFrame: |
||
95 | switch (pgItem->annotation().Type()) |
||
96 | { |
||
97 | case 2: |
||
11587 | cbradney | 98 | tipText = CommonStrings::itemSubType_PDF_PushButton; |
9598 | fschmid | 99 | break; |
100 | case 3: |
||
11587 | cbradney | 101 | tipText = CommonStrings::itemSubType_PDF_TextField; |
9598 | fschmid | 102 | break; |
103 | case 4: |
||
11587 | cbradney | 104 | tipText = CommonStrings::itemSubType_PDF_CheckBox; |
9598 | fschmid | 105 | break; |
106 | case 5: |
||
11587 | cbradney | 107 | tipText = CommonStrings::itemSubType_PDF_ComboBox; |
9598 | fschmid | 108 | break; |
109 | case 6: |
||
11587 | cbradney | 110 | tipText = CommonStrings::itemSubType_PDF_ListBox; |
9598 | fschmid | 111 | break; |
112 | case 10: |
||
11587 | cbradney | 113 | tipText = CommonStrings::itemSubType_PDF_TextAnnotation; |
9598 | fschmid | 114 | break; |
115 | case 11: |
||
11587 | cbradney | 116 | tipText = CommonStrings::itemSubType_PDF_LinkAnnotation; |
9598 | fschmid | 117 | break; |
118 | default: |
||
11587 | cbradney | 119 | tipText = CommonStrings::itemType_TextFrame; |
9598 | fschmid | 120 | break; |
121 | } |
||
122 | break; |
||
123 | case PageItem::Line: |
||
11587 | cbradney | 124 | tipText = CommonStrings::itemType_Line; |
9598 | fschmid | 125 | break; |
126 | case PageItem::Polygon: |
||
11587 | cbradney | 127 | tipText = CommonStrings::itemType_Polygon; |
9598 | fschmid | 128 | break; |
129 | case PageItem::PolyLine: |
||
11587 | cbradney | 130 | tipText = CommonStrings::itemType_Polyline; |
9598 | fschmid | 131 | break; |
132 | case PageItem::PathText: |
||
11587 | cbradney | 133 | tipText = CommonStrings::itemType_PathText; |
9598 | fschmid | 134 | break; |
135 | default: |
||
136 | break; |
||
137 | } |
||
11202 | fschmid | 138 | QToolTip::showText(helpEvent->globalPos(), tipText, this); |
9598 | fschmid | 139 | return true; |
140 | } |
||
141 | } |
||
142 | } |
||
143 | } |
||
144 | return QTreeWidget::viewportEvent(event); |
||
145 | } |
||
146 | |||
10862 | cbradney | 147 | OutlinePalette::OutlinePalette( QWidget* parent) : ScrPaletteBase( parent, "Tree", false, 0 ) |
3 | paul | 148 | { |
12378 | fschmid | 149 | // resize( 220, 240 ); |
265 | Franz | 150 | setMinimumSize( QSize( 220, 240 ) ); |
21051 | jghali | 151 | // setMaximumSize( QSize( 800, 600 ) ); |
12378 | fschmid | 152 | |
153 | filterEdit = new QLineEdit; |
||
154 | filterEdit->setToolTip( tr("Enter a keyword or regular expression to filter the outline.") ); |
||
12804 | cbradney | 155 | QShortcut* filterShortcut = new QShortcut( QKeySequence( tr( "Ctrl+F", "Filter the Outline using a keyword" ) ), this ); |
12378 | fschmid | 156 | filterLabel = new QLabel( tr("Filter:") ); |
157 | filterLabel->setBuddy( filterEdit ); |
||
1448 | cbradney | 158 | |
10862 | cbradney | 159 | reportDisplay = new OutlineWidget( this ); |
3 | paul | 160 | |
12378 | fschmid | 161 | // reportDisplay->setGeometry( QRect( 0, 0, 220, 240 ) ); |
162 | // reportDisplay->setMinimumSize( QSize( 220, 240 ) ); |
||
1395 | fschmid | 163 | reportDisplay->setRootIsDecorated( true ); |
8708 | fschmid | 164 | reportDisplay->setColumnCount(1); |
165 | reportDisplay->setHeaderLabel( tr("Element")); |
||
166 | reportDisplay->header()->setClickable( false ); |
||
167 | reportDisplay->header()->setResizeMode( QHeaderView::ResizeToContents ); |
||
168 | reportDisplay->setSortingEnabled(false); |
||
11264 | fschmid | 169 | reportDisplay->setSelectionMode(QAbstractItemView::ExtendedSelection); |
9057 | fschmid | 170 | reportDisplay->setContextMenuPolicy(Qt::CustomContextMenu); |
12378 | fschmid | 171 | |
172 | QGridLayout* layout = new QGridLayout; |
||
173 | layout->addWidget( filterLabel, 0, 0 ); |
||
174 | layout->addWidget( filterEdit, 0, 1 ); |
||
175 | layout->addWidget( reportDisplay, 1, 0, 1, 2 ); |
||
176 | layout->setContentsMargins( 3, 3, 3, 3); |
||
177 | setLayout( layout ); |
||
178 | |||
5646 | cbradney | 179 | unsetDoc(); |
8245 | cbradney | 180 | imageIcon = loadIcon("22/insert-image.png"); |
11264 | fschmid | 181 | latexIcon = loadIcon("22/insert-latex.png"); |
1427 | fschmid | 182 | lineIcon = loadIcon("Stift.xpm"); |
8245 | cbradney | 183 | textIcon = loadIcon("22/insert-text-frame.png"); |
184 | polylineIcon = loadIcon("22/draw-path.png"); |
||
185 | polygonIcon = loadIcon("22/draw-polygon.png"); |
||
1427 | fschmid | 186 | groupIcon = loadIcon("u_group.png"); |
8240 | fschmid | 187 | buttonIcon = loadIcon("22/insert-button.png"); |
188 | textFieldIcon = loadIcon("22/text-field.png"); |
||
189 | checkBoxIcon = loadIcon("22/checkbox.png"); |
||
190 | comboBoxIcon = loadIcon("22/combobox.png"); |
||
191 | listBoxIcon = loadIcon("22/list-box.png"); |
||
192 | annotTextIcon = loadIcon("22/pdf-annotations.png"); |
||
193 | annotLinkIcon = loadIcon("goto.png"); |
||
1427 | fschmid | 194 | selectionTriggered = false; |
10211 | jghali | 195 | m_MainWindow = NULL; |
196 | freeObjects = NULL; |
||
197 | rootObject = NULL; |
||
198 | currentObject = NULL; |
||
2194 | cbradney | 199 | languageChange(); |
265 | Franz | 200 | // signals and slots connections |
9057 | fschmid | 201 | connect(reportDisplay, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(slotRightClick(QPoint))); |
11264 | fschmid | 202 | connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
203 | connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int))); |
||
12378 | fschmid | 204 | connect(filterEdit, SIGNAL(textChanged(const QString&)), this, SLOT(filterTree(const QString&))); |
205 | connect(filterShortcut, SIGNAL(activated()), filterEdit, SLOT(setFocus())); |
||
3 | paul | 206 | } |
207 | |||
10862 | cbradney | 208 | void OutlinePalette::setMainWindow(ScribusMainWindow *mw) |
5287 | cbradney | 209 | { |
210 | m_MainWindow=mw; |
||
211 | if (m_MainWindow==NULL) |
||
212 | clearPalette(); |
||
213 | } |
||
214 | |||
10862 | cbradney | 215 | void OutlinePalette::setDoc(ScribusDoc *newDoc) |
3691 | cbradney | 216 | { |
5287 | cbradney | 217 | if (m_MainWindow==NULL) |
218 | currDoc=NULL; |
||
219 | else |
||
220 | currDoc=newDoc; |
||
3695 | cbradney | 221 | if (currDoc==NULL) |
222 | clearPalette(); |
||
3691 | cbradney | 223 | } |
224 | |||
10862 | cbradney | 225 | void OutlinePalette::unsetDoc() |
3691 | cbradney | 226 | { |
227 | currDoc=NULL; |
||
228 | clearPalette(); |
||
229 | } |
||
230 | |||
10862 | cbradney | 231 | void OutlinePalette::setPaletteShown(bool visible) |
8221 | fschmid | 232 | { |
233 | ScrPaletteBase::setPaletteShown(visible); |
||
234 | if ((visible) && (currDoc != NULL)) |
||
235 | BuildTree(); |
||
236 | } |
||
237 | |||
10862 | cbradney | 238 | void OutlinePalette::slotRightClick(QPoint point) |
356 | Franz | 239 | { |
14755 | jghali | 240 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
9057 | fschmid | 241 | return; |
242 | QTreeWidgetItem *ite = reportDisplay->itemAt(point); |
||
8233 | fschmid | 243 | if (ite == NULL) |
265 | Franz | 244 | return; |
11264 | fschmid | 245 | if (!ite->isSelected()) |
246 | slotMultiSelect(); |
||
10066 | cbradney | 247 | OutlineTreeItem *item = (OutlineTreeItem*)ite; |
11405 | cbradney | 248 | |
8233 | fschmid | 249 | if (item != NULL) |
265 | Franz | 250 | { |
8242 | fschmid | 251 | if ((item->type == 0) || (item->type == 2)) |
11405 | cbradney | 252 | createContextMenu(NULL, point.x(), point.y()); |
253 | else if ((item->type == 1) || (item->type == 3) || (item->type == 4)) |
||
8241 | fschmid | 254 | { |
11405 | cbradney | 255 | PageItem *currItem = item->PageItemObject; |
256 | if (currItem!=NULL) |
||
257 | { |
||
258 | currentObject = ite; |
||
259 | createContextMenu(currItem, point.x(), point.y()); |
||
260 | } |
||
261 | } |
||
262 | } |
||
265 | Franz | 263 | } |
264 | |||
10862 | cbradney | 265 | void OutlinePalette::slotRenameItem() |
8241 | fschmid | 266 | { |
11264 | fschmid | 267 | activateWindow(); |
268 | reportDisplay->setFocus(); |
||
269 | reportDisplay->editItem(currentObject); |
||
8241 | fschmid | 270 | } |
271 | |||
10862 | cbradney | 272 | void OutlinePalette::slotDoRename(QTreeWidgetItem *ite , int col) |
265 | Franz | 273 | { |
14755 | jghali | 274 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
265 | Franz | 275 | return; |
11264 | fschmid | 276 | disconnect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int))); |
10066 | cbradney | 277 | OutlineTreeItem *item = (OutlineTreeItem*)ite; |
8233 | fschmid | 278 | if (item != NULL) |
265 | Franz | 279 | { |
8233 | fschmid | 280 | if ((item->type == 1) || (item->type == 3) || (item->type == 4)) |
265 | Franz | 281 | { |
8233 | fschmid | 282 | QString NameOld = item->PageItemObject->itemName(); |
283 | QString NameNew = ite->text(col); |
||
284 | if (NameOld != NameNew) |
||
265 | Franz | 285 | { |
8233 | fschmid | 286 | if (NameNew == "") |
287 | ite->setText(col, NameOld); |
||
288 | else |
||
265 | Franz | 289 | { |
290 | bool found = false; |
||
11264 | fschmid | 291 | for (int b = 0; b < currDoc->Items->count(); ++b) |
265 | Franz | 292 | { |
8233 | fschmid | 293 | if ((NameNew == currDoc->Items->at(b)->itemName()) && (currDoc->Items->at(b) != item->PageItemObject)) |
265 | Franz | 294 | { |
8233 | fschmid | 295 | found = true; |
296 | break; |
||
265 | Franz | 297 | } |
298 | } |
||
299 | if (found) |
||
300 | { |
||
8233 | fschmid | 301 | QMessageBox::warning(this, CommonStrings::trWarning, "<qt>"+ tr("Name \"%1\" isn't unique.<br/>Please choose another.").arg(NameNew)+"</qt>", CommonStrings::tr_OK); |
265 | Franz | 302 | ite->setText(col, NameOld); |
303 | } |
||
304 | else |
||
305 | { |
||
8233 | fschmid | 306 | item->PageItemObject->setItemName(NameNew); |
307 | m_MainWindow->propertiesPalette->SetCurItem(item->PageItemObject); |
||
308 | currDoc->setModified(true); |
||
265 | Franz | 309 | } |
310 | } |
||
311 | } |
||
312 | } |
||
12378 | fschmid | 313 | filterTree(); |
265 | Franz | 314 | } |
11264 | fschmid | 315 | connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int))); |
265 | Franz | 316 | } |
317 | |||
10862 | cbradney | 318 | QTreeWidgetItem* OutlinePalette::getListItem(int SNr, int Nr) |
1427 | fschmid | 319 | { |
10066 | cbradney | 320 | OutlineTreeItem *item = 0; |
8708 | fschmid | 321 | QTreeWidgetItem *retVal = 0; |
3724 | cbradney | 322 | if (currDoc->masterPageMode()) |
1427 | fschmid | 323 | { |
324 | if (Nr == -1) |
||
8217 | fschmid | 325 | { |
8708 | fschmid | 326 | QTreeWidgetItemIterator it( reportDisplay ); |
327 | while ( (*it) ) |
||
8217 | fschmid | 328 | { |
10066 | cbradney | 329 | item = (OutlineTreeItem*)(*it); |
8217 | fschmid | 330 | if ((item->type == 0) && (item->PageObject->pageNr() == SNr)) |
331 | { |
||
8708 | fschmid | 332 | retVal = (*it); |
8217 | fschmid | 333 | break; |
334 | } |
||
335 | ++it; |
||
336 | } |
||
337 | } |
||
1427 | fschmid | 338 | else |
339 | { |
||
8708 | fschmid | 340 | QTreeWidgetItemIterator it( reportDisplay ); |
341 | while ( (*it) ) |
||
1427 | fschmid | 342 | { |
10066 | cbradney | 343 | item = (OutlineTreeItem*)(*it); |
8220 | fschmid | 344 | if ((item->type == 1) && (static_cast<int>(item->PageItemObject->ItemNr) == Nr)) |
4954 | cbradney | 345 | { |
8708 | fschmid | 346 | retVal = (*it); |
8217 | fschmid | 347 | break; |
4954 | cbradney | 348 | } |
8217 | fschmid | 349 | ++it; |
1427 | fschmid | 350 | } |
351 | } |
||
352 | } |
||
353 | else |
||
354 | { |
||
355 | if (Nr == -1) |
||
8217 | fschmid | 356 | { |
8708 | fschmid | 357 | QTreeWidgetItemIterator it( reportDisplay ); |
358 | while ( (*it) ) |
||
8217 | fschmid | 359 | { |
10066 | cbradney | 360 | item = (OutlineTreeItem*)(*it); |
8217 | fschmid | 361 | if ((item->type == 2) && (item->PageObject->pageNr() == SNr)) |
362 | { |
||
8708 | fschmid | 363 | retVal = (*it); |
8217 | fschmid | 364 | break; |
365 | } |
||
366 | ++it; |
||
367 | } |
||
368 | } |
||
1427 | fschmid | 369 | else |
370 | { |
||
8708 | fschmid | 371 | QTreeWidgetItemIterator it( reportDisplay ); |
372 | while ( (*it) ) |
||
1427 | fschmid | 373 | { |
10066 | cbradney | 374 | item = (OutlineTreeItem*)(*it); |
8220 | fschmid | 375 | if (((item->type == 3) || (item->type == 4)) && (static_cast<int>(item->PageItemObject->ItemNr) == Nr)) |
3953 | cbradney | 376 | { |
8708 | fschmid | 377 | retVal = (*it); |
8217 | fschmid | 378 | break; |
3953 | cbradney | 379 | } |
8217 | fschmid | 380 | ++it; |
1427 | fschmid | 381 | } |
382 | } |
||
383 | } |
||
384 | return retVal; |
||
385 | } |
||
386 | |||
10862 | cbradney | 387 | void OutlinePalette::slotShowSelect(uint SNr, int Nr) |
90 | Franz | 388 | { |
14755 | jghali | 389 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
173 | Franz | 390 | return; |
3695 | cbradney | 391 | if (currDoc==NULL) |
392 | return; |
||
3691 | cbradney | 393 | if (currDoc->isLoading()) |
105 | Franz | 394 | return; |
1427 | fschmid | 395 | if (selectionTriggered) |
396 | return; |
||
11264 | fschmid | 397 | disconnect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
1427 | fschmid | 398 | reportDisplay->clearSelection(); |
11264 | fschmid | 399 | if (currDoc->m_Selection->count() > 0) |
400 | { |
||
14404 | jghali | 401 | QList<QTreeWidgetItem*> itemSelection; |
11264 | fschmid | 402 | uint docSelectionCount = currDoc->m_Selection->count(); |
403 | for (uint a = 0; a < docSelectionCount; a++) |
||
404 | { |
||
405 | PageItem *item = currDoc->m_Selection->itemAt(a); |
||
406 | QTreeWidgetItem *retVal = getListItem(item->OwnPage, item->ItemNr); |
||
17269 | jghali | 407 | if (retVal != 0 && !retVal->isHidden()) |
14404 | jghali | 408 | itemSelection.append(retVal); |
11264 | fschmid | 409 | } |
14404 | jghali | 410 | reportDisplay->selectItems(itemSelection); |
11264 | fschmid | 411 | } |
412 | else |
||
413 | { |
||
414 | QTreeWidgetItem *retVal = getListItem(SNr, Nr); |
||
17269 | jghali | 415 | if (retVal != 0 && !retVal->isHidden()) |
11264 | fschmid | 416 | retVal->setSelected(true); |
417 | } |
||
418 | QList<QTreeWidgetItem *> items = reportDisplay->selectedItems(); |
||
419 | if (items.count() > 0) |
||
420 | reportDisplay->scrollToItem(items[0], QAbstractItemView::EnsureVisible); |
||
421 | connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
||
90 | Franz | 422 | } |
423 | |||
10862 | cbradney | 424 | void OutlinePalette::setItemIcon(QTreeWidgetItem *item, PageItem *pgItem) |
1427 | fschmid | 425 | { |
8240 | fschmid | 426 | switch (pgItem->itemType()) |
1427 | fschmid | 427 | { |
1460 | cbradney | 428 | case PageItem::ImageFrame: |
11264 | fschmid | 429 | if (pgItem->asLatexFrame()) |
430 | item->setIcon( 0, latexIcon ); |
||
431 | else |
||
432 | item->setIcon( 0, imageIcon ); |
||
1427 | fschmid | 433 | break; |
1460 | cbradney | 434 | case PageItem::TextFrame: |
8240 | fschmid | 435 | switch (pgItem->annotation().Type()) |
436 | { |
||
437 | case 2: |
||
8708 | fschmid | 438 | item->setIcon( 0, buttonIcon ); |
8240 | fschmid | 439 | break; |
440 | case 3: |
||
8708 | fschmid | 441 | item->setIcon( 0, textFieldIcon ); |
8240 | fschmid | 442 | break; |
443 | case 4: |
||
8708 | fschmid | 444 | item->setIcon( 0, checkBoxIcon ); |
8240 | fschmid | 445 | break; |
446 | case 5: |
||
8708 | fschmid | 447 | item->setIcon( 0, comboBoxIcon ); |
8240 | fschmid | 448 | break; |
449 | case 6: |
||
8708 | fschmid | 450 | item->setIcon( 0, listBoxIcon ); |
8240 | fschmid | 451 | break; |
452 | case 10: |
||
8708 | fschmid | 453 | item->setIcon( 0, annotTextIcon ); |
8240 | fschmid | 454 | break; |
455 | case 11: |
||
8708 | fschmid | 456 | item->setIcon( 0, annotLinkIcon ); |
8240 | fschmid | 457 | break; |
458 | default: |
||
8708 | fschmid | 459 | item->setIcon( 0, textIcon ); |
8240 | fschmid | 460 | break; |
461 | } |
||
1427 | fschmid | 462 | break; |
1460 | cbradney | 463 | case PageItem::Line: |
8708 | fschmid | 464 | item->setIcon( 0, lineIcon ); |
1427 | fschmid | 465 | break; |
1460 | cbradney | 466 | case PageItem::Polygon: |
8708 | fschmid | 467 | item->setIcon( 0, polygonIcon ); |
1427 | fschmid | 468 | break; |
1460 | cbradney | 469 | case PageItem::PolyLine: |
8708 | fschmid | 470 | item->setIcon( 0, polylineIcon ); |
1427 | fschmid | 471 | break; |
1460 | cbradney | 472 | case PageItem::PathText: |
8708 | fschmid | 473 | item->setIcon( 0, textIcon ); |
1427 | fschmid | 474 | break; |
475 | default: |
||
476 | break; |
||
477 | } |
||
478 | } |
||
479 | |||
10862 | cbradney | 480 | void OutlinePalette::reopenTree() |
91 | Franz | 481 | { |
14755 | jghali | 482 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
173 | Franz | 483 | return; |
8220 | fschmid | 484 | if (currDoc->OpenNodes.count() == 0) |
91 | Franz | 485 | return; |
10066 | cbradney | 486 | OutlineTreeItem *item = 0; |
8708 | fschmid | 487 | QTreeWidgetItemIterator it( reportDisplay ); |
488 | while ( (*it) ) |
||
265 | Franz | 489 | { |
10066 | cbradney | 490 | item = (OutlineTreeItem*)(*it); |
8546 | cbradney | 491 | for (int olc = 0; olc < currDoc->OpenNodes.count(); olc++) |
8220 | fschmid | 492 | { |
493 | if (item->type == currDoc->OpenNodes[olc].type) |
||
494 | { |
||
495 | if ((item->type == -3) || (item->type == -2)) |
||
8708 | fschmid | 496 | reportDisplay->expandItem((*it)); |
8220 | fschmid | 497 | else if ((item->type == 0) || (item->type == 2)) |
498 | { |
||
499 | if (item->PageObject == currDoc->OpenNodes[olc].page) |
||
8708 | fschmid | 500 | reportDisplay->expandItem((*it)); |
8220 | fschmid | 501 | } |
502 | else if ((item->type == 2) || (item->type == 3) || (item->type == 4)) |
||
503 | { |
||
504 | if (item->PageItemObject == currDoc->OpenNodes[olc].item) |
||
8708 | fschmid | 505 | reportDisplay->expandItem((*it)); |
8220 | fschmid | 506 | } |
507 | } |
||
508 | } |
||
509 | ++it; |
||
510 | } |
||
91 | Franz | 511 | } |
512 | |||
10862 | cbradney | 513 | void OutlinePalette::buildReopenVals() |
91 | Franz | 514 | { |
8220 | fschmid | 515 | ScribusDoc::OpenNodesList ol; |
8708 | fschmid | 516 | if (reportDisplay->model()->rowCount() == 0) |
8220 | fschmid | 517 | return; |
518 | currDoc->OpenNodes.clear(); |
||
10066 | cbradney | 519 | OutlineTreeItem *item = 0; |
8708 | fschmid | 520 | QTreeWidgetItemIterator it( reportDisplay ); |
521 | while ( (*it) ) |
||
265 | Franz | 522 | { |
10066 | cbradney | 523 | item = (OutlineTreeItem*)(*it); |
8708 | fschmid | 524 | if (item->isExpanded()) |
8220 | fschmid | 525 | { |
526 | ol.type = item->type; |
||
527 | ol.page = item->PageObject; |
||
528 | ol.item = item->PageItemObject; |
||
529 | currDoc->OpenNodes.append(ol); |
||
530 | } |
||
531 | ++it; |
||
532 | } |
||
91 | Franz | 533 | } |
534 | |||
11264 | fschmid | 535 | void OutlinePalette::slotMultiSelect() |
536 | { |
||
14755 | jghali | 537 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
11264 | fschmid | 538 | return; |
539 | if (currDoc==NULL) |
||
540 | return; |
||
541 | disconnect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
||
542 | selectionTriggered = true; |
||
543 | QList<QTreeWidgetItem *> items = reportDisplay->selectedItems(); |
||
544 | if (items.count() != 1) |
||
545 | { |
||
546 | if (currDoc->appMode == modeEditClip) |
||
547 | currDoc->view()->requestMode(submodeEndNodeEdit); |
||
11729 | jghali | 548 | currDoc->m_Selection->delaySignalsOn(); |
11264 | fschmid | 549 | currDoc->view()->Deselect(true); |
550 | for (int a = 0; a < items.count(); a++) |
||
551 | { |
||
552 | QTreeWidgetItem* ite = items[a]; |
||
553 | OutlineTreeItem *item = (OutlineTreeItem*)ite; |
||
554 | PageItem *pgItem = NULL; |
||
555 | switch (item->type) |
||
556 | { |
||
557 | case 0: |
||
558 | case 1: |
||
559 | case 2: |
||
560 | ite->setSelected(false); |
||
561 | break; |
||
562 | case 3: |
||
563 | case 4: |
||
564 | pgItem = item->PageItemObject; |
||
565 | if (!pgItem->isSelected()) |
||
566 | { |
||
567 | m_MainWindow->closeActiveWindowMasterPageEditor(); |
||
11729 | jghali | 568 | //currDoc->m_Selection->setIsGUISelection(false); |
11264 | fschmid | 569 | currDoc->view()->SelectItemNr(pgItem->ItemNr, false, false); |
570 | } |
||
571 | break; |
||
572 | } |
||
573 | } |
||
11729 | jghali | 574 | /*if (currDoc->m_Selection->count() > 0) |
11264 | fschmid | 575 | { |
576 | currDoc->m_Selection->setIsGUISelection(true); |
||
577 | currDoc->m_Selection->connectItemToGUI(); |
||
11729 | jghali | 578 | }*/ |
579 | currDoc->m_Selection->delaySignalsOff(); |
||
11264 | fschmid | 580 | currDoc->view()->DrawNew(); |
581 | } |
||
582 | else |
||
583 | slotSelect(items[0], 0); |
||
584 | selectionTriggered = false; |
||
585 | connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
||
586 | } |
||
587 | |||
10862 | cbradney | 588 | void OutlinePalette::slotSelect(QTreeWidgetItem* ite, int col) |
3 | paul | 589 | { |
14755 | jghali | 590 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
173 | Franz | 591 | return; |
1427 | fschmid | 592 | selectionTriggered = true; |
10066 | cbradney | 593 | OutlineTreeItem *item = (OutlineTreeItem*)ite; |
8233 | fschmid | 594 | uint pg = 0; |
595 | PageItem *pgItem = NULL; |
||
8217 | fschmid | 596 | switch (item->type) |
1395 | fschmid | 597 | { |
8217 | fschmid | 598 | case 0: |
599 | emit selectMasterPage(item->PageObject->pageName()); |
||
600 | break; |
||
601 | case 1: |
||
602 | if (!currDoc->masterPageMode()) |
||
603 | emit selectMasterPage(item->PageItemObject->OnMasterPage); |
||
18129 | jghali | 604 | if (currDoc->activeLayer() != item->PageItemObject->LayerNr) |
605 | { |
||
606 | currDoc->setActiveLayer(item->PageItemObject->LayerNr); |
||
607 | m_MainWindow->changeLayer(currDoc->activeLayer()); |
||
608 | } |
||
8217 | fschmid | 609 | if (item->PageItemObject->Groups.count() == 0) |
610 | emit selectElement(-1, item->PageItemObject->ItemNr, false); |
||
611 | else |
||
612 | { |
||
613 | if (item->PageItemObject->isGroupControl) |
||
614 | emit selectElement(-1, item->PageItemObject->ItemNr, false); |
||
615 | else |
||
616 | emit selectElement(-1, item->PageItemObject->ItemNr, true); |
||
617 | } |
||
618 | break; |
||
619 | case 2: |
||
8233 | fschmid | 620 | pg = item->PageObject->pageNr(); |
8217 | fschmid | 621 | m_MainWindow->closeActiveWindowMasterPageEditor(); |
8233 | fschmid | 622 | emit selectPage(pg); |
8217 | fschmid | 623 | break; |
624 | case 3: |
||
625 | case 4: |
||
8233 | fschmid | 626 | pgItem = item->PageItemObject; |
8217 | fschmid | 627 | m_MainWindow->closeActiveWindowMasterPageEditor(); |
18129 | jghali | 628 | if (currDoc->activeLayer() != pgItem->LayerNr) |
629 | { |
||
630 | currDoc->setActiveLayer(pgItem->LayerNr); |
||
631 | m_MainWindow->changeLayer(currDoc->activeLayer()); |
||
632 | } |
||
8233 | fschmid | 633 | if (pgItem->Groups.count() == 0) |
634 | emit selectElement(pgItem->OwnPage, pgItem->ItemNr, false); |
||
8217 | fschmid | 635 | else |
636 | { |
||
8233 | fschmid | 637 | if (pgItem->isGroupControl) |
638 | emit selectElement(pgItem->OwnPage, pgItem->ItemNr, false); |
||
8217 | fschmid | 639 | else |
8233 | fschmid | 640 | emit selectElement(pgItem->OwnPage, pgItem->ItemNr, true); |
8217 | fschmid | 641 | } |
642 | break; |
||
643 | default: |
||
644 | break; |
||
1395 | fschmid | 645 | } |
1427 | fschmid | 646 | selectionTriggered = false; |
3 | paul | 647 | } |
12378 | fschmid | 648 | /* |
10862 | cbradney | 649 | void OutlinePalette::resizeEvent(QResizeEvent *r) |
3 | paul | 650 | { |
1395 | fschmid | 651 | reportDisplay->resize(r->size()); |
3 | paul | 652 | } |
12378 | fschmid | 653 | */ |
10862 | cbradney | 654 | void OutlinePalette::BuildTree(bool storeVals) |
3 | paul | 655 | { |
14755 | jghali | 656 | if (!m_MainWindow || m_MainWindow->scriptIsRunning()) |
173 | Franz | 657 | return; |
3691 | cbradney | 658 | if (currDoc==NULL) |
659 | return; |
||
8233 | fschmid | 660 | if (selectionTriggered) |
661 | return; |
||
11264 | fschmid | 662 | disconnect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
663 | disconnect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int))); |
||
8220 | fschmid | 664 | setUpdatesEnabled(false); |
665 | if (storeVals) |
||
666 | buildReopenVals(); |
||
667 | clearPalette(); |
||
8708 | fschmid | 668 | QList<PageItem*> subGroupList; |
10066 | cbradney | 669 | OutlineTreeItem * item = new OutlineTreeItem( reportDisplay, 0 ); |
1491 | fschmid | 670 | rootObject = item; |
3691 | cbradney | 671 | item->setText( 0, currDoc->DocName.section( '/', -1 ) ); |
8220 | fschmid | 672 | item->type = -2; |
10066 | cbradney | 673 | OutlineTreeItem * pagep = 0; |
1491 | fschmid | 674 | freeObjects = 0; |
1414 | fschmid | 675 | PageItem* pgItem; |
676 | QString tmp; |
||
9882 | fschmid | 677 | for (int b = 0; b < currDoc->MasterItems.count(); ++b) |
1414 | fschmid | 678 | { |
3691 | cbradney | 679 | currDoc->MasterItems.at(b)->Dirty = false; |
1414 | fschmid | 680 | } |
3691 | cbradney | 681 | for (int a = 0; a < static_cast<int>(currDoc->MasterPages.count()); ++a) |
1395 | fschmid | 682 | { |
10066 | cbradney | 683 | OutlineTreeItem *page = new OutlineTreeItem( item, pagep ); |
8217 | fschmid | 684 | page->PageObject = currDoc->MasterPages.at(a); |
685 | page->type = 0; |
||
5685 | cbradney | 686 | QString pageNam = currDoc->MasterPages.at(a)->pageName(); |
1395 | fschmid | 687 | pagep = page; |
9882 | fschmid | 688 | for (int b = 0; b < currDoc->MasterItems.count(); ++b) |
1395 | fschmid | 689 | { |
3691 | cbradney | 690 | pgItem = currDoc->MasterItems.at(b); |
11264 | fschmid | 691 | if (((pgItem->OwnPage == a) || (pgItem->OnMasterPage == pageNam)) && (!pgItem->Dirty)) |
1395 | fschmid | 692 | { |
1414 | fschmid | 693 | if (pgItem->Groups.count() == 0) |
694 | { |
||
10066 | cbradney | 695 | OutlineTreeItem *object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 696 | object->PageItemObject = pgItem; |
697 | object->type = 1; |
||
1414 | fschmid | 698 | object->setText(0, pgItem->itemName()); |
8240 | fschmid | 699 | setItemIcon(object, pgItem); |
11264 | fschmid | 700 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
1427 | fschmid | 701 | pgItem->Dirty = true; |
1414 | fschmid | 702 | } |
703 | else |
||
704 | { |
||
10066 | cbradney | 705 | OutlineTreeItem * object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 706 | object->PageItemObject = pgItem; |
707 | object->type = 1; |
||
8106 | fschmid | 708 | if (pgItem->isGroupControl) |
709 | object->setText(0, pgItem->itemName()); |
||
710 | else |
||
711 | object->setText(0, tr("Group ")+tmp.setNum(pgItem->Groups.top())); |
||
8708 | fschmid | 712 | object->setIcon( 0, groupIcon ); |
11264 | fschmid | 713 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
8217 | fschmid | 714 | pgItem->Dirty = true; |
1427 | fschmid | 715 | subGroupList.clear(); |
9882 | fschmid | 716 | for (int ga = 0; ga < currDoc->MasterItems.count(); ++ga) |
1427 | fschmid | 717 | { |
3691 | cbradney | 718 | PageItem* pgItem2 = currDoc->MasterItems.at(ga); |
8217 | fschmid | 719 | if ((pgItem2->Groups.count() != 0) && (pgItem2->Groups.top() == pgItem->Groups.top()) && (pgItem2 != pgItem)) |
1427 | fschmid | 720 | subGroupList.append(pgItem2); |
721 | } |
||
8217 | fschmid | 722 | parseSubGroup(1, object, &subGroupList, 1); |
1414 | fschmid | 723 | } |
1395 | fschmid | 724 | } |
725 | } |
||
5685 | cbradney | 726 | page->setText(0, currDoc->MasterPages.at(a)->pageName()); |
1395 | fschmid | 727 | } |
9882 | fschmid | 728 | for (int b = 0; b < currDoc->DocItems.count(); ++b) |
1414 | fschmid | 729 | { |
3691 | cbradney | 730 | currDoc->DocItems.at(b)->Dirty = false; |
1414 | fschmid | 731 | } |
3691 | cbradney | 732 | for (int a = 0; a < static_cast<int>(currDoc->DocPages.count()); ++a) |
1395 | fschmid | 733 | { |
10066 | cbradney | 734 | OutlineTreeItem *page = new OutlineTreeItem( item, pagep ); |
8217 | fschmid | 735 | page->PageObject = currDoc->DocPages.at(a); |
736 | page->type = 2; |
||
1395 | fschmid | 737 | pagep = page; |
9882 | fschmid | 738 | for (int b = 0; b < currDoc->DocItems.count(); ++b) |
1395 | fschmid | 739 | { |
3691 | cbradney | 740 | pgItem = currDoc->DocItems.at(b); |
1414 | fschmid | 741 | if ((pgItem->OwnPage == a) && (!pgItem->Dirty)) |
1395 | fschmid | 742 | { |
1414 | fschmid | 743 | if (pgItem->Groups.count() == 0) |
744 | { |
||
10066 | cbradney | 745 | OutlineTreeItem *object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 746 | object->PageItemObject = pgItem; |
747 | object->type = 3; |
||
1427 | fschmid | 748 | object->setText(0, pgItem->itemName()); |
8240 | fschmid | 749 | setItemIcon(object, pgItem); |
11264 | fschmid | 750 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
1427 | fschmid | 751 | pgItem->Dirty = true; |
1414 | fschmid | 752 | } |
753 | else |
||
754 | { |
||
10066 | cbradney | 755 | OutlineTreeItem *object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 756 | object->PageItemObject = pgItem; |
757 | object->type = 3; |
||
8106 | fschmid | 758 | if (pgItem->isGroupControl) |
759 | object->setText(0, pgItem->itemName()); |
||
760 | else |
||
761 | object->setText(0, tr("Group ")+tmp.setNum(pgItem->Groups.top())); |
||
8708 | fschmid | 762 | object->setIcon( 0, groupIcon ); |
11264 | fschmid | 763 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
8217 | fschmid | 764 | pgItem->Dirty = true; |
1427 | fschmid | 765 | subGroupList.clear(); |
9882 | fschmid | 766 | for (int ga = 0; ga < currDoc->DocItems.count(); ++ga) |
1427 | fschmid | 767 | { |
3691 | cbradney | 768 | PageItem* pgItem2 = currDoc->DocItems.at(ga); |
8217 | fschmid | 769 | if ((pgItem2->Groups.count() != 0) && (pgItem2->Groups.top() == pgItem->Groups.top()) && (pgItem2 != pgItem)) |
1427 | fschmid | 770 | subGroupList.append(pgItem2); |
771 | } |
||
8217 | fschmid | 772 | parseSubGroup(1, object, &subGroupList, 3); |
1414 | fschmid | 773 | } |
1395 | fschmid | 774 | } |
775 | } |
||
776 | page->setText(0, tr("Page ")+tmp.setNum(a+1)); |
||
777 | } |
||
778 | bool hasfreeItems = false; |
||
9882 | fschmid | 779 | for (int b = 0; b < currDoc->DocItems.count(); ++b) |
1395 | fschmid | 780 | { |
3691 | cbradney | 781 | if (currDoc->DocItems.at(b)->OwnPage == -1) |
1395 | fschmid | 782 | { |
783 | hasfreeItems = true; |
||
784 | break; |
||
785 | } |
||
786 | } |
||
787 | if (hasfreeItems) |
||
788 | { |
||
10066 | cbradney | 789 | OutlineTreeItem *page = new OutlineTreeItem( item, pagep ); |
1395 | fschmid | 790 | pagep = page; |
1491 | fschmid | 791 | freeObjects = page; |
8220 | fschmid | 792 | page->type = -3; |
9882 | fschmid | 793 | for (int b = 0; b < currDoc->DocItems.count(); ++b) |
1395 | fschmid | 794 | { |
3691 | cbradney | 795 | pgItem = currDoc->DocItems.at(b); |
1414 | fschmid | 796 | if ((pgItem->OwnPage == -1) && (!pgItem->Dirty)) |
1395 | fschmid | 797 | { |
1414 | fschmid | 798 | if (pgItem->Groups.count() == 0) |
799 | { |
||
10066 | cbradney | 800 | OutlineTreeItem *object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 801 | object->PageItemObject = pgItem; |
802 | object->type = 4; |
||
1414 | fschmid | 803 | object->setText(0, pgItem->itemName()); |
8240 | fschmid | 804 | setItemIcon(object, pgItem); |
11264 | fschmid | 805 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
1427 | fschmid | 806 | pgItem->Dirty = true; |
1414 | fschmid | 807 | } |
808 | else |
||
809 | { |
||
10066 | cbradney | 810 | OutlineTreeItem *object = new OutlineTreeItem( page, 0 ); |
8217 | fschmid | 811 | object->PageItemObject = pgItem; |
812 | object->type = 4; |
||
8106 | fschmid | 813 | if (pgItem->isGroupControl) |
814 | object->setText(0, pgItem->itemName()); |
||
815 | else |
||
816 | object->setText(0, tr("Group ")+tmp.setNum(pgItem->Groups.top())); |
||
8708 | fschmid | 817 | object->setIcon( 0, groupIcon ); |
11264 | fschmid | 818 | object->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
8217 | fschmid | 819 | pgItem->Dirty = true; |
1427 | fschmid | 820 | subGroupList.clear(); |
9882 | fschmid | 821 | for (int ga = 0; ga < currDoc->DocItems.count(); ++ga) |
1427 | fschmid | 822 | { |
3691 | cbradney | 823 | PageItem* pgItem2 = currDoc->DocItems.at(ga); |
8217 | fschmid | 824 | if ((pgItem2->Groups.count() != 0) && (pgItem2->Groups.top() == pgItem->Groups.top()) && (pgItem2 != pgItem)) |
1427 | fschmid | 825 | subGroupList.append(pgItem2); |
826 | } |
||
8217 | fschmid | 827 | parseSubGroup(1, object, &subGroupList, 4); |
1414 | fschmid | 828 | } |
1395 | fschmid | 829 | } |
830 | } |
||
831 | page->setText(0, tr("Free Objects")); |
||
832 | } |
||
8220 | fschmid | 833 | if (storeVals) |
834 | reopenTree(); |
||
835 | setUpdatesEnabled(true); |
||
17269 | jghali | 836 | filterTree(); |
11264 | fschmid | 837 | if (currDoc->m_Selection->count() > 0) |
838 | slotShowSelect(0, -1); |
||
8220 | fschmid | 839 | repaint(); |
11264 | fschmid | 840 | connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect())); |
841 | connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int))); |
||
1414 | fschmid | 842 | } |
843 | |||
12378 | fschmid | 844 | void OutlinePalette::filterTree(const QString& keyword) |
845 | { |
||
846 | OutlineTreeItem *item = NULL; |
||
847 | QTreeWidgetItemIterator it( reportDisplay ); |
||
848 | while ( (*it) ) |
||
849 | { |
||
850 | item = dynamic_cast<OutlineTreeItem*>(*it); |
||
851 | if (item != NULL) |
||
852 | { |
||
853 | if ((item->type == 1) || (item->type == 3) || (item->type == 4)) |
||
854 | { |
||
12501 | jghali | 855 | if (item->PageItemObject->itemName().contains(QRegExp(keyword, Qt::CaseInsensitive))) |
12378 | fschmid | 856 | item->setHidden(false); |
857 | else |
||
858 | item->setHidden(true); |
||
859 | } |
||
860 | else |
||
861 | item->setHidden(false); |
||
862 | } |
||
863 | ++it; |
||
864 | } |
||
865 | } |
||
866 | |||
867 | void OutlinePalette::filterTree() |
||
868 | { |
||
869 | if ( !filterEdit->text().isEmpty() ) |
||
870 | filterTree( filterEdit->text() ); |
||
871 | } |
||
872 | |||
10862 | cbradney | 873 | void OutlinePalette::parseSubGroup(int level, OutlineTreeItem* object, QList<PageItem*> *subGroupList, int itemType) |
1414 | fschmid | 874 | { |
8708 | fschmid | 875 | QList<PageItem*> *subGroup; |
1414 | fschmid | 876 | PageItem *pgItem; |
877 | QString tmp; |
||
8708 | fschmid | 878 | for (int b = 0; b < subGroupList->count(); ++b) |
1414 | fschmid | 879 | { |
880 | pgItem = subGroupList->at(b); |
||
881 | if (!pgItem->Dirty) |
||
882 | { |
||
883 | if (static_cast<int>(pgItem->Groups.count()) <= level) |
||
884 | { |
||
10066 | cbradney | 885 | OutlineTreeItem *grp = new OutlineTreeItem( object, 0 ); |
8217 | fschmid | 886 | grp->PageItemObject = pgItem; |
887 | grp->type = itemType; |
||
1427 | fschmid | 888 | grp->setText(0, pgItem->itemName()); |
8240 | fschmid | 889 | setItemIcon(grp, pgItem); |
11264 | fschmid | 890 | grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
1427 | fschmid | 891 | pgItem->Dirty = true; |
1414 | fschmid | 892 | } |
893 | else |
||
894 | { |
||
10066 | cbradney | 895 | OutlineTreeItem *grp = new OutlineTreeItem( object, 0 ); |
8217 | fschmid | 896 | grp->PageItemObject = pgItem; |
897 | grp->type = itemType; |
||
8106 | fschmid | 898 | if (pgItem->isGroupControl) |
899 | grp->setText(0, pgItem->itemName()); |
||
900 | else |
||
9919 | jghali | 901 | grp->setText(0, tr("Group ")+tmp.setNum(pgItem->Groups.at(pgItem->Groups.count()-level-1))); |
8708 | fschmid | 902 | grp->setIcon( 0, groupIcon ); |
11264 | fschmid | 903 | grp->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); |
8217 | fschmid | 904 | pgItem->Dirty = true; |
8708 | fschmid | 905 | subGroup = new QList<PageItem*>; |
1427 | fschmid | 906 | subGroup->clear(); |
8708 | fschmid | 907 | for (int ga = 0; ga < subGroupList->count(); ++ga) |
1427 | fschmid | 908 | { |
909 | PageItem* pgItem2 = subGroupList->at(ga); |
||
910 | if ((static_cast<int>(pgItem2->Groups.count()) > level) && |
||
9919 | jghali | 911 | ((pgItem2->Groups.at(pgItem2->Groups.count()-level-1)) == (pgItem->Groups.at(pgItem->Groups.count()-level-1))) && (pgItem2 != pgItem)) |
1427 | fschmid | 912 | subGroup->append(pgItem2); |
913 | } |
||
8217 | fschmid | 914 | parseSubGroup(level+1, grp, subGroup, itemType); |
1427 | fschmid | 915 | delete subGroup; |
1414 | fschmid | 916 | } |
917 | } |
||
918 | } |
||
919 | } |
||
920 | |||
10862 | cbradney | 921 | void OutlinePalette::changeEvent(QEvent *e) |
10859 | cbradney | 922 | { |
923 | if (e->type() == QEvent::LanguageChange) |
||
924 | languageChange(); |
||
10903 | cbradney | 925 | else |
926 | QWidget::changeEvent(e); |
||
10859 | cbradney | 927 | } |
928 | |||
929 | |||
10862 | cbradney | 930 | void OutlinePalette::languageChange() |
2194 | cbradney | 931 | { |
10495 | cbradney | 932 | setWindowTitle( tr("Outline")); |
8708 | fschmid | 933 | reportDisplay->setHeaderLabel( tr("Element")); |
12378 | fschmid | 934 | filterLabel->setText( tr("Filter:") ); |
2355 | cbradney | 935 | } |
3691 | cbradney | 936 | |
10862 | cbradney | 937 | void OutlinePalette::clearPalette() |
3691 | cbradney | 938 | { |
939 | reportDisplay->clear(); |
||
940 | } |
||
11405 | cbradney | 941 | |
942 | void OutlinePalette::createContextMenu(PageItem * currItem, double mx, double my) |
||
943 | { |
||
944 | if (m_MainWindow==NULL || currDoc==NULL) |
||
945 | return; |
||
946 | ContextMenu* cmen=NULL; |
||
18921 | jghali | 947 | // qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor)); |
11405 | cbradney | 948 | if(currItem!=NULL) |
949 | cmen = new ContextMenu(*(currDoc->m_Selection), m_MainWindow, currDoc); |
||
950 | else |
||
15043 | fschmid | 951 | cmen = new ContextMenu(m_MainWindow, currDoc, currDoc->currentPage()->xOffset(), currDoc->currentPage()->yOffset()); |
11405 | cbradney | 952 | if (cmen) |
953 | cmen->exec(QCursor::pos()); |
||
954 | delete cmen; |
||
955 | } |