File: imageslistview.h

package info (click to toggle)
kimagemapeditor 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,140 kB
  • sloc: cpp: 6,817; xml: 207; sh: 5; makefile: 3
file content (111 lines) | stat: -rw-r--r-- 2,664 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/***************************************************************************
                          imageslistview.h  -  description
                             -------------------
    begin                : Weg Feb 26 2003
    copyright            : (C) 2003 by Jan Schäfer
    email                : janschaefer@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _IMAGESLISTVIEW_H_
#define _IMAGESLISTVIEW_H_

#include <QTreeWidget>
#include <QUrl>

#include "kimagemapeditor.h"

class ImagesListView;

class ImagesListViewItem : public QTreeWidgetItem
{
  public:
    ImagesListViewItem(ImagesListView*, ImageTag*);
    ImageTag* imageTag();

    /**
     * Re-reads the contents of the ImageTag and updates
     * itself accordingly
     */
    void update();
  protected:
    ImageTag* _imageTag;
};

/**
 * Simple class that shows a list of imagenames with a preview
 * Jan Schaefer
 **/
class ImagesListView : public QTreeWidget
{
  Q_OBJECT

public:
  explicit ImagesListView(QWidget *parent);
  ~ImagesListView() override;

  /**
   * Adds an image
   */
  void addImage(ImageTag*);

  /**
   * Adds images
   */
  void addImages(const QList<ImageTag*> &);

  /**
   * Removes the given image from the list
   */
  void removeImage(ImageTag*);

  /**
   * Updates the listview item with the given ImageTag
   */
  void updateImage(ImageTag *);

  /**
   * Removes all images
   */
  void clear();

  /**
   * Returns the filename of the current selected Image
   */
  ImageTag* selectedImage();

  /**
   * Selects the given image
   */
  void selectImage(ImageTag*);

  /**
   * Sets the base URL of all images
   */
  void setBaseUrl(const QUrl & url) { _baseUrl = url; };

protected slots:
  void slotSelectionChanged();

signals:
  void imageSelected(const QUrl &);

protected:
  QUrl _baseUrl;

  /**
   * Finds the first ImageListViewItem with the given ImageTag
   * Returns 0L if no item was found
   */
  ImagesListViewItem* findListViewItem(ImageTag*);
};

#endif