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 */
7 /***************************************************************************
8                           bookmwin.h  -  description
9                              -------------------
10     begin                : Mon Feb 11 2002
11     copyright            : (C) 2002 by Franz Schmid
12     email                : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  *                                                                         *
17  *   This program is free software; you can redistribute it and/or modify  *
18  *   it under the terms of the GNU General Public License as published by  *
19  *   the Free Software Foundation; either version 2 of the License, or     *
20  *   (at your option) any later version.                                   *
21  *                                                                         *
22  ***************************************************************************/
23 
24 #ifndef BOOKMWIN_H
25 #define BOOKMWIN_H
26 
27 #include <QTreeWidget>
28 
29 class PageItem;
30 #include "scribusapi.h"
31 #include "scribusdoc.h"
32 
33 /*! \brief Tree widget item for PDF Bookmarks.
34 Secret items like Pare, First, Last etc. are PDF Outlines
35 attributes. See PDF specification for more info.
36 These attrs are recomputed in the BookmarkView::rebuildTree()
37 method.
38 @author Franz Schmid
39 */
40 class SCRIBUS_API BookMItem : public QTreeWidgetItem
41 {
42 public:
43 	BookMItem(QTreeWidgetItem* parent, struct ScribusDoc::BookMa *Bm);
44 	BookMItem(QTreeWidgetItem* parent, QTreeWidgetItem* after, struct ScribusDoc::BookMa *Bm);
45 	BookMItem(QTreeWidget* parent, QTreeWidgetItem* after, struct ScribusDoc::BookMa *Bm);
46 	BookMItem(QTreeWidget* parent, struct ScribusDoc::BookMa *Bm);
47 	BookMItem(QTreeWidget* parent, QTreeWidgetItem* after, int nr, PageItem *PObject);
48 	BookMItem(QTreeWidget* parent, int nr, PageItem *PObject);
~BookMItem()49 	~BookMItem() {};
50 
51 	int level();
52 	void setup(struct ScribusDoc::BookMa *Bm);
53 	virtual QString key(int, bool) const;
54 
55 	PageItem *PageObject;
56 	int ItemNr;
57 	QString Action;
58 	QString Title;
59 	int First;
60 	int Last;
61 	int Prev;
62 	int Next;
63 	int Pare;
64 };
65 
66 
67 /*! \brief Tree widget for PDF Bookmarks.
68 It's a minimal tree implementation with D'n'D handled
69 in Qt4 itself. It could be rewritten into M/V/C stuff
70 later, but it looks it's simpler and quicker now.
71 MarkMoved() signal stores bookmarks in the ScribusDoc.
72 @author Franz Schmid
73 \author Petr Vanek <petr@scribus.info>
74 */
75 class SCRIBUS_API BookmarkView : public QTreeWidget
76 {
77 	Q_OBJECT
78 
79 public:
80 	BookmarkView(QWidget* parent);
~BookmarkView()81 	~BookmarkView() {};
82 
83 	void addItem(const QString& text, const QString& Tit, PageItem *PageObject);
84 	void deleteItem(PageItem *PageObject);
85 	void setAction(PageItem *currItem, const QString& Act);
86 
87 	int NrItems;
88 	int First;
89 	int Last;
90 
91 	/*! \brief Build scribus bookmark structure from tree items.
92 	It looks horrible as it performs full rescan of the tree, but
93 	it's pretty fast at all.
94 	\author Petr vanek <petr@scribus.info>
95 	*/
96 	void rebuildTree();
97 
98 public slots:
99 	void addPageItem(PageItem* ite);
100 	void changeText(PageItem *currItem);
101 
102 signals:
103 	void changed();
104 	void markMoved();
105 	void selectElement(PageItem *, bool);
106 
107 protected:
108 	void dropEvent(QDropEvent *e);
109 	void getTextAndTitle(PageItem* item, QString& text, QString& title);
110 
111 private slots:
112 	void selectPageItem(QTreeWidgetItem * current, int column);
113 };
114 
115 #endif
116