Scribus
Open source desktop publishing at your fingertips
picturebrowser.h
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 #ifndef PICTUREBROWSER_H
8 #define PICTUREBROWSER_H
9 
10 #include <QCloseEvent>
11 #include <QDirModel>
12 #include "ui_picturebrowser.h"
13 
14 //previewicon class
15 #include <QPixmap>
16 #include "scimage.h"
17 #include "scribusstructs.h"
18 #include "cmsettings.h"
19 #include "scribusdoc.h"
20 
21 #include "imagedialog.h"
22 
23 //previewImagesModel class
24 #include <QAbstractListModel>
25 #include <QtAlgorithms>
26 
27 //threads support
28 #include <QThread>
29 
30 //documentbrowser
31 #include "pageitem.h"
32 
33 //xml support for collections
34 #include <QtXml>
35 #include <QXmlStreamReader>
36 
37 //scribuspaths
38 #include "scpaths.h"
39 #include "scribuscore.h"
40 
41 //colorspace related things
42 #include "util_color.h"
43 
44 //open/savefile dialog
45 #include <QFileDialog>
46 
47 //settings class
48 #include <prefsfile.h>
49 #include <prefscontext.h>
50 
52 class ImageInformation;
53 class previewImage;
54 class previewImages;
55 class PreviewImagesModel;
56 class imageCollection;
57 class collections;
62 class loadImagesThread;
63 class loadImagesThreadInstance;
64 class findImagesThread;
65 class QImage;
66 class imageFilters;
67 
68 
69 
71 {
72  public:
74 
75  void load();
76  void save();
77  void reset();
78 
79  //save settings?
80  bool saveSettings;
81  //tells if dialog is enlarged
82  bool showMore;
83  //the sortorder, false for ascending, true for descending
84  bool sortOrder;
85  //sorting, 0 for name, 1 for date, 2 for size, 3 for type
86  int sortSetting;
87  //previewmode, 0 for "previewimages only", 1 for "preview with information"
88  int previewMode;
89  //the size of the icons
90  int previewIconSize;
91  //tells if always-on-top is enabled
92  bool alwaysOnTop;
93 };
94 
95 
96 //central class, manages gui
97 class PictureBrowser : public QDialog, Ui::PictureBrowser
98 {
99  Q_OBJECT
100 
101  public:
102  PictureBrowser ( ScribusDoc* doc, QWidget *parent = 0 );
103  ~PictureBrowser();
104  void closeEvent(QCloseEvent *e);
105  void changedDocument ( ScribusDoc* doc );
106  void closedDocument();
107 
108  //posts an image which should be loaded to the imageloading thread
109  void callLoadImageThread ( int row, int pId );
110  picturebrowserSettings pbSettings;
111 
112  //for statusinfo, contains how many images are currently displayed/filtered
113  int imagesDisplayed, imagesFiltered;
114  //contains how many icons are visible at once, is calculated from QListView height/width and previewIconSize
115  int previewIconsVisible;
116  int currentRow;
117  bool saveSettings;
118 
119  signals:
120  //signal which posts a new job to the imageloading thread
121  //parameters:
122  //previewImage* imageToLoad: pointer to identify the previewimage
123  //QString path: path to the image
124  //int size: size of the icon, the returned QImage will be resized according to this
125  //int pId: a unique id to check wether the pointer is valid or a different set of images has been chosen while thread was executed
126  void loadImageJob ( int, QString, int, int );
127  //signals for selecting a page in the current document
128  void selectPage ( int );
129  void selectMasterPage ( QString );
130 
131  private slots:
132  //slot for the navigation combobox, sets current browsingmode (folderbrowser, collectionsbrowser, documentbrowser)
133  void navigate ( int index );
134  //called when a previewicon was clicked
135  void previewIconClicked ( const QModelIndex &index );
136  void previewIconDoubleClicked ( const QModelIndex &index );
137  //called when sorting was changed, re-sorts images and refreshes view
138  void sortChanged ( int index );
139  //called when previewmode was changed, changes previewmode
140  void previewModeChanged ( int index );
141  //called when more button was clicked, enlarges dialog
142  void moreButtonClicked();
143  void resetSettingsButtonClicked();
144  //called when an action was selected
145  void actionsGoButtonClicked();
146  //called when sortorder was changed, updates view
147  void sortOrderButtonClicked();
148  //called when zoombutton + was clicked, enlarges previewicons
149  void zoomPlusButtonClicked();
150  //called when zoombutton - was clicked, scales down previewicons
151  void zoomMinusButtonClicked();
152  void tabWidgetCurrentChanged ( int index );
153  //called when "Goto page" in documentbrowser was clicked
154  void gotoPageButtonClicked();
155  //called when always-on-top checkbox was clicked, toggles always-on-top-feature
156  void alwaysOnTopCheckboxStateChanged();
157  void saveSettingsCheckboxStateChanged();
158  //called when "include subdirs" checkbox in folderbrowser was clicked, toggles recursive folderbrowsing on/off
159  void subdirsCheckboxStateChanged();
160  //called when a dir is clicked in the folderbrowser, calls thread to find images
161  void dirChosen ( const QModelIndex &index );
162  //called when a selection is made in the documentbrowser, lists the images and displays them
163  void documentChosen ( QTreeWidgetItem * item, int column );
164  //called when a collection is selected in the collectionsbrowser, reads the images from the file and displays them
165  void collectionChosen ( QTreeWidgetItem * item, int column );
166  void collectionsWidgetItemEdited ( QTreeWidgetItem * item, int column );
167  //called when the thread has finished browsing a folder for images, displays the images
168  void findImagesThreadFinished();
169  //called when the collectionreaderthread has finished reading a file, displays the images
170  void collectionReaderThreadFinished();
171  void collectionListReaderThreadFinished();
172  void collectionReaderThreadListFinishedSave();
173  void collectionsDbWriterThreadFinished();
174  void collectionWriterThreadListFinished();
175  //called when entries have been selected from insertPagesCombobox
176  void insertPagesComboboxCheckstateChanged ( int row );
177  void insertImageButtonClicked();
178  void insertPositionComboboxChanged ( int index );
179  void insertSizeComboboxChanged ( int index );
180  void filterCriteriaComboboxChanged ( int index );
181  void filterTargetComboboxChanged ( int index );
182  void filterFilterButtonClicked();
183  void filterClearButtonClicked();
184  void filterAddCriterionButtonClicked();
185  void filterSearchDirButtonClicked();
186  void collectionsNewCategoryButtonClicked();
187  void collectionsNewButtonClicked();
188  void collectionsImportButtonClicked();
189  void collectionsExportButtonClicked();
190  void collectionsDeleteButtonClicked();
191  void collectionsRenameButtonClicked();
192  void collectionsAddImagesButtonClicked();
193  void collectionsRemoveImagesButtonClicked();
194  void collectionsTagImagesButtonClicked();
195  void collectionsAddImagesOkButtonClicked();
196  void collectionsAddImagesCancelButtonClicked();
197  void previewImageSelectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
198  void collectionsSetTagsButtonClicked();
199  void collectionsAddNewTagButtonClicked();
200  void jumpToImageFolder();
201 
202  private:
203  //updates the QListView when the set of previewimages was changed (new images, zoom, previewmode changed etc)
204  void loadIcons();
205  void setSettings();
206  void updateDocumentbrowser();
207  void updateBrowser ( bool filter, bool sort, bool reload );
208  void updateInformationTab ( int index );
209  void updateCollectionsWidget ( bool addImages );
210  void updateCollectionsAddImagesCombobox();
211  //expands/shrinks dialog
212  void expandDialog ( bool expand );
213  void setAlwaysOnTop ( bool alwaysOnTop );
214  void saveCollectionsDb();
215  void applyFilters();
216  void updateTagImagesTab();
217 
218  //current document
219  ScribusDoc* m_Doc;
220  // Main window
221  ScribusMainWindow* m_ScMW;
222 
223  //the dirmodel for the folderbrowser
224  QDirModel folderModel;
225  //model for QListView containing the previewimages
226  PreviewImagesModel *pModel;
227  //contains the currently selected index in folderModel
228  QModelIndex tmpindex;
229  //tells if thread searches dirs recursively
230  bool folderBrowserIncludeSubdirs;
231  //index of the previewicon currently selected
232  int previewIconIndex;
233  //a list containing the items in the documentbrowser treewidget
234  QList<QTreeWidgetItem *> documentItems;
235  //contain the icons needed
236  QIcon *iconArrowUp, *iconArrowDown, *iconFolderBrowser, *iconCollectionsBrowser, *iconDocumentBrowser, *iconDocument, *iconCollection, *iconZoomPlus, *iconZoomMinus, *iconOk, *iconClose, *iconNew, *iconNew2, *iconEdit, *iconRemove, *iconLoad, *iconSave, *iconPlus, *iconMinus, *iconPen;
237  //thread for searching dirs
238  findImagesThread *fit;
239  //the current set of previewimages
240  previewImages *pImages;
241  //the path currently selected in folderbrowser
242  QString currPath;
243  //a thread for loading images
244  loadImagesThread *lit;
245  //a thread for reading a collectionsfile
247  QList<collectionReaderThread *> crtList;
248  //the collection currently selected
249  QString currCollectionFile;
250  imageCollection *currCollection;
251  //a list of threads for saving a collection
252  QList<collectionWriterThread *> cwtList;
255  //custom position for inserting image enabled/disabled
256  bool insertCustomPosition;
257  bool insertCustomSize;
258  QStringList nameFilters;
259  imageFilters *filters;
260  QString cdbFile;
261  QList<int> selectedIndexes;
262 
263  //contains the hierarchy for the collectionsbrowser treewidget
264  QList<collections *> collectionsDb;
265 
266  bool documentChanged;
267 };
268 
269 
271 {
272  public:
273  imageFilters();
274 
275  QList<int> filterMap;
276  QList<int> filterMap2;
277 
278  QStringList nameFilters;
279  QList<bool> nameInverts;
280 
281  QList<QDateTime> dateFilters;
282  QList<bool> dateInverts;
283 
284  QList<qint64> sizeFilters;
285  QList<bool> sizeInverts;
286 
287  QList<QStringList> tagFilters;
288 
289  QList<QStringList> typeFilters;
290 };
291 
292 
293 #endif
Definition: previewimage.h:42
Definition: previewimage.h:97
Definition: previewimage.h:140
Definition: collection.h:63
Definition: picturebrowser.h:70
Definition: findimage.h:28
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
Definition: collection.h:145
Definition: collection.h:48
the Document Class
Definition: scribusdoc.h:90
Definition: picturebrowser.h:270
Definition: loadimage.h:34
Definition: collection.h:29
Definition: collection.h:179
Definition: previewimage.h:59
Definition: collection.h:115