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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2004-11-17
* Description : image properties side bar using data from
* digiKam database.
*
* Copyright (C) 2004-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// TQt includes.
#include <tqrect.h>
#include <tqcolor.h>
#include <tqsplitter.h>
// KDE includes.
#include <tdelocale.h>
#include <tdeconfig.h>
#include <tdeapplication.h>
#include <kcursor.h>
#include <tdeglobal.h>
#include <kiconloader.h>
// Local includes.
#include "ddebug.h"
#include "dimg.h"
#include "imageinfo.h"
#include "imagedescedittab.h"
#include "imageattributeswatch.h"
#include "imagepropertiestab.h"
#include "imagepropertiesmetadatatab.h"
#include "imagepropertiescolorstab.h"
#include "imagepropertiessidebardb.h"
#include "imagepropertiessidebardb.moc"
namespace Digikam
{
class ImagePropertiesSideBarDBPriv
{
public:
ImagePropertiesSideBarDBPriv()
{
desceditTab = 0;
dirtyDesceditTab = false;
hasPrevious = false;
hasNext = false;
hasImageInfoOwnership = false;
}
bool dirtyDesceditTab;
TQPtrList<ImageInfo> currentInfos;
ImageDescEditTab *desceditTab;
bool hasPrevious;
bool hasNext;
bool hasImageInfoOwnership;
};
ImagePropertiesSideBarDB::ImagePropertiesSideBarDB(TQWidget *parent, const char *name, TQSplitter *splitter,
Side side, bool mimimizedDefault)
: ImagePropertiesSideBar(parent, name, splitter, side, mimimizedDefault, false)
{
// Navigate bar is disabled by passing false to parent class constructor, and tab constructors
d = new ImagePropertiesSideBarDBPriv;
d->desceditTab = new ImageDescEditTab(parent, false);
appendTab(d->desceditTab, SmallIcon("imagecomment"), i18n("Captions/Tags"));
// ----------------------------------------------------------
connect(this, TQ_SIGNAL(signalChangedTab(TQWidget*)),
this, TQ_SLOT(slotChangedTab(TQWidget*)));
connect(d->desceditTab, TQ_SIGNAL(signalProgressBarMode(int, const TQString&)),
this, TQ_SIGNAL(signalProgressBarMode(int, const TQString&)));
connect(d->desceditTab, TQ_SIGNAL(signalProgressValue(int)),
this, TQ_SIGNAL(signalProgressValue(int)));
ImageAttributesWatch *watch = ImageAttributesWatch::instance();
connect(watch, TQ_SIGNAL(signalFileMetadataChanged(const KURL &)),
this, TQ_SLOT(slotFileMetadataChanged(const KURL &)));
}
ImagePropertiesSideBarDB::~ImagePropertiesSideBarDB()
{
delete d;
}
void ImagePropertiesSideBarDB::itemChanged(ImageInfo *info,
const TQRect &rect, DImg *img)
{
itemChanged(info->kurl(), info, rect, img);
}
void ImagePropertiesSideBarDB::itemChanged(const KURL& url, const TQRect &rect, DImg *img)
{
itemChanged(url, 0, rect, img);
}
void ImagePropertiesSideBarDB::itemChanged(const KURL& url, ImageInfo *info,
const TQRect &rect, DImg *img)
{
if ( !url.isValid() )
return;
m_currentURL = url;
TQPtrList<ImageInfo> list;
if (info)
list.append(info);
itemChanged(list, rect, img);
}
void ImagePropertiesSideBarDB::itemChanged(TQPtrList<ImageInfo> infos)
{
if (infos.isEmpty())
return;
m_currentURL = infos.first()->kurl();
itemChanged(infos, TQRect(), 0);
}
void ImagePropertiesSideBarDB::itemChanged(TQPtrList<ImageInfo> infos,
const TQRect &rect, DImg *img)
{
m_currentRect = rect;
m_image = img;
// The list _may_ have autoDelete set to true.
// Keep old ImageInfo objects from being deleted
// until the tab has had the chance to save changes and clear lists.
TQPtrList<ImageInfo> temporaryList;
if (d->hasImageInfoOwnership)
{
temporaryList = d->currentInfos;
d->hasImageInfoOwnership = false;
}
d->currentInfos = infos;
m_dirtyPropertiesTab = false;
m_dirtyMetadataTab = false;
m_dirtyColorTab = false;
d->dirtyDesceditTab = false;
// All tabs that store the ImageInfo list and access it after selection change
// must release the image info here. slotChangedTab only handles the active tab!
d->desceditTab->setItem();
slotChangedTab( getActiveTab() );
// now delete old objects, after slotChangedTab
for (ImageInfo *info = temporaryList.first(); info; info = temporaryList.next())
{
delete info;
}
}
void ImagePropertiesSideBarDB::takeImageInfoOwnership(bool takeOwnership)
{
d->hasImageInfoOwnership = takeOwnership;
}
void ImagePropertiesSideBarDB::slotNoCurrentItem(void)
{
ImagePropertiesSideBar::slotNoCurrentItem();
// All tabs that store the ImageInfo list and access it after selection change
// must release the image info here. slotChangedTab only handles the active tab!
d->desceditTab->setItem();
if (d->hasImageInfoOwnership)
{
for (ImageInfo *info = d->currentInfos.first(); info; info = d->currentInfos.next())
{
delete info;
}
d->hasImageInfoOwnership = false;
}
d->currentInfos.clear();
d->desceditTab->setItem();
d->dirtyDesceditTab = false;
}
void ImagePropertiesSideBarDB::populateTags(void)
{
d->desceditTab->populateTags();
}
void ImagePropertiesSideBarDB::slotChangedTab(TQWidget* tab)
{
setCursor(KCursor::waitCursor());
// No database data available, for example in the case of image editor is
// started from camera GUI.
if (d->currentInfos.isEmpty())
{
if (tab == m_propertiesTab && !m_dirtyPropertiesTab)
{
m_propertiesTab->setCurrentURL(m_currentURL);
m_dirtyPropertiesTab = true;
}
else if (tab == m_metadataTab && !m_dirtyMetadataTab)
{
if (m_image)
m_metadataTab->setCurrentData(m_image->getExif(), m_image->getIptc(),
m_currentURL.fileName());
else
m_metadataTab->setCurrentURL(m_currentURL);
m_dirtyMetadataTab = true;
}
else if (tab == m_colorTab && !m_dirtyColorTab)
{
m_colorTab->setData(m_currentURL, m_currentRect, m_image);
m_dirtyColorTab = true;
}
else if (tab == d->desceditTab && !d->dirtyDesceditTab)
{
// Do nothing here. We cannot get data from database !
d->desceditTab->setItem();
d->dirtyDesceditTab = true;
}
}
else if (d->currentInfos.count() == 1) // Data from database available...
{
if (tab == m_propertiesTab && !m_dirtyPropertiesTab)
{
m_propertiesTab->setCurrentURL(m_currentURL);
m_dirtyPropertiesTab = true;
}
else if (tab == m_metadataTab && !m_dirtyMetadataTab)
{
if (m_image)
m_metadataTab->setCurrentData(m_image->getExif(), m_image->getIptc(),
m_currentURL.fileName());
else
m_metadataTab->setCurrentURL(m_currentURL);
m_dirtyMetadataTab = true;
}
else if (tab == m_colorTab && !m_dirtyColorTab)
{
m_colorTab->setData(m_currentURL, m_currentRect, m_image);
m_dirtyColorTab = true;
}
else if (tab == d->desceditTab && !d->dirtyDesceditTab)
{
d->desceditTab->setItem(d->currentInfos.first());
d->dirtyDesceditTab = true;
}
}
else // Data from database available, multiple selection
{
if (tab == m_propertiesTab && !m_dirtyPropertiesTab)
{
//TODO
m_propertiesTab->setCurrentURL(m_currentURL);
m_dirtyPropertiesTab = true;
}
else if (tab == m_metadataTab && !m_dirtyMetadataTab)
{
// any ideas?
m_metadataTab->setCurrentURL();
m_dirtyMetadataTab = true;
}
else if (tab == m_colorTab && !m_dirtyColorTab)
{
// any ideas?
m_colorTab->setData();
m_dirtyColorTab = true;
}
else if (tab == d->desceditTab && !d->dirtyDesceditTab)
{
d->desceditTab->setItems(d->currentInfos);
d->dirtyDesceditTab = true;
}
}
unsetCursor();
}
void ImagePropertiesSideBarDB::slotFileMetadataChanged(const KURL &url)
{
if (url == m_currentURL)
{
// trigger an update
m_dirtyMetadataTab = false;
if (getActiveTab() == m_metadataTab)
{
// update now - reuse code form slotChangedTab
slotChangedTab( getActiveTab() );
}
}
}
void ImagePropertiesSideBarDB::slotAssignRating(int rating)
{
d->desceditTab->assignRating(rating);
}
void ImagePropertiesSideBarDB::slotAssignRatingNoStar()
{
d->desceditTab->assignRating(0);
}
void ImagePropertiesSideBarDB::slotAssignRatingOneStar()
{
d->desceditTab->assignRating(1);
}
void ImagePropertiesSideBarDB::slotAssignRatingTwoStar()
{
d->desceditTab->assignRating(2);
}
void ImagePropertiesSideBarDB::slotAssignRatingThreeStar()
{
d->desceditTab->assignRating(3);
}
void ImagePropertiesSideBarDB::slotAssignRatingFourStar()
{
d->desceditTab->assignRating(4);
}
void ImagePropertiesSideBarDB::slotAssignRatingFiveStar()
{
d->desceditTab->assignRating(5);
}
void ImagePropertiesSideBarDB::refreshTagsView()
{
d->desceditTab->refreshTagsView();
}
} // NameSpace Digikam
|