1 | /*************************************************************************** |
2 | imageslistview.h - description |
3 | ------------------- |
4 | begin : Weg Feb 26 2003 |
5 | copyright : (C) 2003 by Jan Schäfer |
6 | email : janschaefer@users.sourceforge.net |
7 | ***************************************************************************/ |
8 | |
9 | /*************************************************************************** |
10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * |
15 | * * |
16 | ***************************************************************************/ |
17 | |
18 | #ifndef _IMAGESLISTVIEW_H_ |
19 | #define _IMAGESLISTVIEW_H_ |
20 | |
21 | #include <QTreeWidget> |
22 | #include <QLinkedList> |
23 | |
24 | #include <kurl.h> |
25 | |
26 | #include "kimagemapeditor.h" |
27 | |
28 | class ImagesListView; |
29 | |
30 | class ImagesListViewItem : public QTreeWidgetItem |
31 | { |
32 | public: |
33 | ImagesListViewItem(ImagesListView*, ImageTag*); |
34 | ImageTag* imageTag(); |
35 | |
36 | /** |
37 | * Re-reads the contents of the ImageTag and updates |
38 | * itself accordingly |
39 | */ |
40 | void update(); |
41 | protected: |
42 | ImageTag* _imageTag; |
43 | }; |
44 | |
45 | /** |
46 | * Simple class that shows a list of imagenames with a preview |
47 | * Jan Schaefer |
48 | **/ |
49 | class ImagesListView : public QTreeWidget |
50 | { |
51 | Q_OBJECT |
52 | |
53 | public: |
54 | ImagesListView(QWidget *parent); |
55 | virtual ~ImagesListView(); |
56 | |
57 | /** |
58 | * Adds an image |
59 | */ |
60 | void addImage(ImageTag*); |
61 | |
62 | /** |
63 | * Adds images |
64 | */ |
65 | void addImages(const QList<ImageTag*> &); |
66 | |
67 | /** |
68 | * Removes the given image from the list |
69 | */ |
70 | void removeImage(ImageTag*); |
71 | |
72 | /** |
73 | * Updates the listview item with the given ImageTag |
74 | */ |
75 | void updateImage(ImageTag *); |
76 | |
77 | /** |
78 | * Removes all images |
79 | */ |
80 | void clear(); |
81 | |
82 | /** |
83 | * Returns the filename of the current selected Image |
84 | */ |
85 | ImageTag* selectedImage(); |
86 | |
87 | /** |
88 | * Selects the given image |
89 | */ |
90 | void selectImage(ImageTag*); |
91 | |
92 | /** |
93 | * Sets the base URL of all images |
94 | */ |
95 | void setBaseUrl(const KUrl & url) { _baseUrl = url; }; |
96 | |
97 | protected slots: |
98 | void slotSelectionChanged(); |
99 | |
100 | signals: |
101 | void imageSelected(const KUrl &); |
102 | |
103 | protected: |
104 | KUrl _baseUrl; |
105 | |
106 | /** |
107 | * Finds the first ImageListViewItem with the given ImageTag |
108 | * Returns 0L if no item was found |
109 | */ |
110 | ImagesListViewItem* findListViewItem(ImageTag*); |
111 | }; |
112 | |
113 | #endif |
114 | |