1/***************************************************************************
2 mapslistview.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 _MAPSLISTVIEW_H_
19#define _MAPSLISTVIEW_H_
20
21#include <kvbox.h>
22
23#include <QTreeWidgetItem>
24#include <QTreeWidget>
25#include <QLinkedList>
26
27#include "kimagemapeditor.h"
28
29/**
30 * Simple class that shows all map tags of the current open html file in a ListView
31 *
32 * Jan Schaefer
33 **/
34class MapsListView : public KVBox
35{
36Q_OBJECT
37public:
38 explicit MapsListView(QWidget *parent);
39 ~MapsListView();
40
41 /**
42 * Adds the given map to the ListView
43 */
44 void addMap(const QString &);
45
46 /**
47 * Adds all maps of the given QList to the ListView
48 */
49 void addMaps(const QList<MapTag*> &);
50
51 /**
52 * Removes the given map from the ListView
53 */
54 void removeMap(const QString &);
55
56 /**
57 * Set to the given map selected in the ListView.
58 * it does not emit mapSelected afterwards.
59 */
60 void selectMap(const QString &);
61
62 /**
63 * Selects the given ListViewItem and deselects the current selected item
64 */
65 void selectMap(QTreeWidgetItem* item);
66
67 /**
68 * Changes the name of the map with the @p oldName to @p newName
69 */
70 void changeMapName(const QString & oldName, const QString & newName);
71
72 /**
73 * Returns the current selected map
74 */
75 QString selectedMap();
76
77
78 /**
79 * Removes all maps from the ListView
80 */
81 void clear();
82
83 /**
84 * Returns a name for a map which is not used yet.
85 * Returns for example Unnamed1
86 */
87 QString getUnusedMapName();
88
89 /**
90 * Whether or not the given map name already exists
91 */
92 bool nameAlreadyExists(const QString &);
93
94 /**
95 * Returns a QStringList of all maps
96 */
97 QStringList getMaps();
98
99 /**
100 * Returns the number of maps
101 */
102 int count();
103
104 QTreeWidget* listView() { return _listView; }
105protected:
106 QTreeWidget* _listView;
107
108protected slots:
109 void slotSelectionChanged();
110 void slotItemRenamed(QTreeWidgetItem*);
111
112signals:
113
114 /**
115 * Gets emitted when the user selects a map in
116 * the ListView
117 */
118 void mapSelected(const QString &);
119
120
121 /**
122 * Emitted when the user has renamed a map in the ListView
123 */
124 void mapRenamed(const QString & newName);
125
126
127};
128
129#endif
130