File indexing completed on 2024-03-24 04:22:46

0001 /***************************************************************************
0002                           imageslistview.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 _IMAGESLISTVIEW_H_
0019 #define _IMAGESLISTVIEW_H_
0020 
0021 #include <QTreeWidget>
0022 #include <QUrl>
0023 
0024 #include "kimagemapeditor.h"
0025 
0026 class ImagesListView;
0027 
0028 class ImagesListViewItem : public QTreeWidgetItem
0029 {
0030   public:
0031     ImagesListViewItem(ImagesListView*, ImageTag*);
0032     ImageTag* imageTag();
0033 
0034     /**
0035      * Re-reads the contents of the ImageTag and updates
0036      * itself accordingly
0037      */
0038     void update();
0039   protected:
0040     ImageTag* _imageTag;
0041 };
0042 
0043 /**
0044  * Simple class that shows a list of imagenames with a preview
0045  * Jan Schaefer
0046  **/
0047 class ImagesListView : public QTreeWidget
0048 {
0049   Q_OBJECT
0050 
0051 public:
0052   explicit ImagesListView(QWidget *parent);
0053   ~ImagesListView() override;
0054 
0055   /**
0056    * Adds an image
0057    */
0058   void addImage(ImageTag*);
0059 
0060   /**
0061    * Adds images
0062    */
0063   void addImages(const QList<ImageTag*> &);
0064 
0065   /**
0066    * Removes the given image from the list
0067    */
0068   void removeImage(ImageTag*);
0069 
0070   /**
0071    * Updates the listview item with the given ImageTag
0072    */
0073   void updateImage(ImageTag *);
0074 
0075   /**
0076    * Removes all images
0077    */
0078   void clear();
0079 
0080   /**
0081    * Returns the filename of the current selected Image
0082    */
0083   ImageTag* selectedImage();
0084 
0085   /**
0086    * Selects the given image
0087    */
0088   void selectImage(ImageTag*);
0089 
0090   /**
0091    * Sets the base URL of all images
0092    */
0093   void setBaseUrl(const QUrl & url) { _baseUrl = url; };
0094 
0095 protected slots:
0096   void slotSelectionChanged();
0097 
0098 signals:
0099   void imageSelected(const QUrl &);
0100 
0101 protected:
0102   QUrl _baseUrl;
0103 
0104   /**
0105    * Finds the first ImageListViewItem with the given ImageTag
0106    * Returns 0L if no item was found
0107    */
0108   ImagesListViewItem* findListViewItem(ImageTag*);
0109 };
0110 
0111 #endif