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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/***************************************************************************
imageslistview.cpp - 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. *
* *
***************************************************************************/
// QT
#include <tqptrlist.h>
// KDE
#include <tdelocale.h>
#include <kdebug.h>
// locale
#include "imageslistview.h"
ImagesListViewItem::ImagesListViewItem(ImagesListView* parent, ImageTag* tag)
: TQListViewItem(parent)
{
_imageTag = tag;
update();
}
void ImagesListViewItem::update() {
TQString src="";
TQString usemap="";
if (_imageTag->find("src"))
src=*_imageTag->find("src");
if (_imageTag->find("usemap"))
usemap=*_imageTag->find("usemap");
setText(0,src);
setText(1,usemap);
}
ImageTag* ImagesListViewItem::imageTag() {
return _imageTag;
}
ImagesListView::ImagesListView(TQWidget *parent, const char *name)
: TDEListView(parent, name)
{
addColumn(i18n("Images"));
addColumn(i18n("Usemap"));
//addColumn(i18n("Preview"));
setFullWidth(true);
connect( this, TQ_SIGNAL( selectionChanged(TQListViewItem*)),
this, TQ_SLOT( slotSelectionChanged(TQListViewItem*)));
}
ImagesListView::~ImagesListView()
{
}
void ImagesListView::addImage(ImageTag* tag)
{
if (!tag) {
kdDebug() << "ImageListView::addImage: Parameter is null !" << endl;
return;
}
new ImagesListViewItem(this, tag);
}
void ImagesListView::addImages(TQPtrList<ImageTag> * images)
{
for (ImageTag *tag = images->first(); tag!=0L; tag=images->next()) {
addImage(tag);
}
}
void ImagesListView::clear() {
TQListView::clear();
}
void ImagesListView::removeImage(ImageTag* tag) {
ImagesListViewItem *item = findListViewItem(tag);
if (item) {
takeItem(item);
setSelected(currentItem(),true);
}
else {
kdDebug() << "ImageListView::removeImage: ListViewItem was not found !" << endl;
}
}
void ImagesListView::updateImage(ImageTag* tag) {
ImagesListViewItem *item = findListViewItem(tag);
if (item)
item->update();
else {
kdDebug() << "ImageListView::updateImage: ListViewItem was not found !" << endl;
}
}
ImagesListViewItem* ImagesListView::findListViewItem(ImageTag* tag) {
kdDebug() << "ImageListView::findListViewItem: start searching ... " << endl;
for (TQListViewItem* item = firstChild(); item ; item = item->nextSibling()) {
ImagesListViewItem *imageItem = static_cast<ImagesListViewItem*>(item);
if (imageItem->imageTag() == tag) {
kdDebug() << "ImageListView::findListViewItem: found it " << endl;
return imageItem;
}
}
kdDebug() << "ImageListView::findListViewItem: found nothing " << endl;
return 0L;
}
void ImagesListView::slotSelectionChanged(TQListViewItem* item) {
TQString src = item->text(0);
emit imageSelected(KURL(_baseUrl,src));
}
ImageTag* ImagesListView::selectedImage() {
ImagesListViewItem* item = static_cast<ImagesListViewItem*>(selectedItem());
if ( ! item) {
kdDebug() << "ImagesListView::selectedImage: No Image is selected !" << endl;
return 0L;
}
return item->imageTag();
}
void ImagesListView::selectImage(ImageTag* tag) {
ImagesListViewItem* item = findListViewItem(tag);
if (item) {
setSelected(item, true);
}
}
#include "imageslistview.moc"
|