summaryrefslogtreecommitdiffstats
path: root/kimagemapeditor/imageslistview.h
blob: fe2784ecf23bed428d11c63ad8d2c75fed0b6066 (plain)
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
112
/***************************************************************************
                          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 <klistview.h>
#include <kurl.h>

#include "kimagemapeditor.h"

class ImagesListView;

class ImagesListViewItem : public TQListViewItem
{
  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 KListView
{
  Q_OBJECT
  

public:
  ImagesListView(TQWidget *parent, const char *name);
  virtual ~ImagesListView();
  
  /**
   * Adds an image
   */
  void addImage(ImageTag*);
  
  /**
   * Adds images
   */
  void addImages(TQPtrList<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 KURL & url) { _baseUrl = url; };
  
protected slots:
  void slotSelectionChanged(TQListViewItem*);  
    
signals:
  void imageSelected(const KURL &);  
  
protected:
  KURL _baseUrl;  
  
  /**
   * Finds the first ImageListViewItem with the given ImageTag
   * Returns 0L if no item was found
   */
  ImagesListViewItem* findListViewItem(ImageTag*);
};

#endif