File indexing completed on 2024-04-21 04:20:17

0001 /***************************************************************************
0002                           mapslistview.h  -  description
0003                              -------------------
0004     begin                : Weg Feb 26 2003
0005     copyright            : (C) 2003 by Jan Schäfer
0006     email                : janschaefer@users.sourceforge.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #ifndef _MAPSLISTVIEW_H_
0019 #define _MAPSLISTVIEW_H_
0020 
0021 #include <QTreeWidget>
0022 #include <QTreeWidgetItem>
0023 #include <QWidget>
0024 
0025 #include "kimagemapeditor.h"
0026 
0027 /**
0028  * Simple class that shows all map tags of the current open html file in a ListView
0029  *
0030  * Jan Schaefer
0031  **/
0032 class MapsListView : public QWidget
0033 {
0034 Q_OBJECT
0035 public:
0036   explicit MapsListView(QWidget *parent);
0037   ~MapsListView() override;
0038 
0039   /**
0040    * Adds the given map to the ListView
0041    */
0042   void addMap(const QString &);
0043 
0044   /**
0045    * Adds all maps of the given QList to the ListView
0046    */
0047   void addMaps(const QList<MapTag*> &);
0048 
0049   /**
0050    * Removes the given map from the ListView
0051    */
0052   void removeMap(const QString &);
0053 
0054   /**
0055    * Set to the given map selected in the ListView.
0056    * it does not emit mapSelected afterwards.
0057    */
0058   void selectMap(const QString &);
0059 
0060   /**
0061    * Selects the given ListViewItem and deselects the current selected item
0062    */
0063   void selectMap(QTreeWidgetItem* item);
0064 
0065   /**
0066    * Changes the name of the map with the @p oldName to @p newName
0067    */
0068   void changeMapName(const QString & oldName, const QString & newName);
0069 
0070   /**
0071    * Returns the current selected map
0072    */
0073   QString selectedMap();
0074 
0075 
0076   /**
0077    * Removes all maps from the ListView
0078    */
0079   void clear();
0080 
0081   /**
0082    * Returns a name for a map which is not used yet.
0083    * Returns for example Unnamed1
0084    */
0085   QString getUnusedMapName();
0086 
0087   /**
0088    * Whether or not the given map name already exists
0089    */
0090   bool nameAlreadyExists(const QString &);
0091 
0092   /**
0093    * Returns a QStringList of all maps
0094    */
0095   QStringList getMaps();
0096 
0097   /**
0098    * Returns the number of maps
0099    */
0100   int count();
0101 
0102   QTreeWidget* listView() { return _listView; }
0103 protected:
0104   QTreeWidget* _listView;
0105 
0106 protected slots:
0107   void slotSelectionChanged();
0108   void slotItemRenamed(QTreeWidgetItem*);
0109 
0110 signals:
0111 
0112   /**
0113    * Gets emitted when the user selects a map in
0114    * the ListView
0115    */
0116   void mapSelected(const QString &);
0117 
0118 
0119   /**
0120    * Emitted when the user has renamed a map in the ListView
0121    */
0122   void mapRenamed(const QString & newName);
0123 
0124 
0125 };
0126 
0127 #endif