~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/dialogs/imagedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Date        : 2008-03-13
7
7
 * Description : image files selector dialog.
8
8
 *
9
 
 * Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
9
 * Copyright (C) 2008-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
10
 *
11
11
 * This program is free software; you can redistribute it
12
12
 * and/or modify it under the terms of the GNU General
53
53
namespace Digikam
54
54
{
55
55
 
56
 
class ImageDialogPreviewPrivate
 
56
class ImageDialogPreview::ImageDialogPreviewPrivate
57
57
{
58
58
 
59
59
public:
60
60
 
61
 
    ImageDialogPreviewPrivate()
 
61
    ImageDialogPreviewPrivate() :
 
62
        imageLabel(0),
 
63
        infoLabel(0),
 
64
        thumbLoadThread(0)
62
65
    {
63
 
        imageLabel      = 0;
64
 
        infoLabel       = 0;
65
 
        thumbLoadThread = 0;
66
66
    }
67
67
 
68
 
    QLabel              *imageLabel;
69
 
    QLabel              *infoLabel;
 
68
    QLabel*              imageLabel;
 
69
    QLabel*              infoLabel;
70
70
 
71
71
    KUrl                 currentURL;
72
72
 
73
73
    DMetadata            metaIface;
74
74
 
75
 
    ThumbnailLoadThread *thumbLoadThread;
 
75
    ThumbnailLoadThread* thumbLoadThread;
76
76
};
77
77
 
78
 
ImageDialogPreview::ImageDialogPreview(QWidget *parent)
79
 
                  : KPreviewWidgetBase(parent),
80
 
                    d(new ImageDialogPreviewPrivate)
 
78
ImageDialogPreview::ImageDialogPreview(QWidget* parent)
 
79
    : KPreviewWidgetBase(parent),
 
80
      d(new ImageDialogPreviewPrivate)
81
81
{
82
82
    d->thumbLoadThread = ThumbnailLoadThread::defaultThread();
83
83
 
84
 
    QVBoxLayout *vlay  = new QVBoxLayout(this);
 
84
    QVBoxLayout* vlay  = new QVBoxLayout(this);
85
85
    d->imageLabel      = new QLabel(this);
86
86
    d->imageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
87
87
    d->imageLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
93
93
    vlay->setSpacing(KDialog::spacingHint());
94
94
    vlay->addWidget(d->imageLabel);
95
95
    vlay->addWidget(d->infoLabel);
 
96
    vlay->addStretch();
96
97
 
97
98
    setSupportedMimeTypes(KImageIO::mimeTypes());
98
99
 
110
111
    return QSize(256, 256);
111
112
}
112
113
 
113
 
void ImageDialogPreview::resizeEvent(QResizeEvent *)
 
114
void ImageDialogPreview::resizeEvent(QResizeEvent*)
114
115
{
115
116
    QMetaObject::invokeMethod(this, "showPreview", Qt::QueuedConnection);
116
117
}
138
139
 
139
140
        d->metaIface.load(d->currentURL.toLocalFile());
140
141
        PhotoInfoContainer info = d->metaIface.getPhotographInformation();
 
142
 
141
143
        if (!info.isEmpty())
142
144
        {
143
145
            DToolTipStyleSheet cnt;
144
146
            QString identify("<qt><center>");
145
147
            QString make, model, dateTime, aperture, focalLength, exposureTime, sensitivity;
146
148
 
147
 
            if (info.make.isEmpty()) make = cnt.unavailable;
148
 
            else make = info.make;
149
 
 
150
 
            if (info.model.isEmpty()) model = cnt.unavailable;
151
 
            else model = info.model;
152
 
 
153
 
            if (!info.dateTime.isValid()) dateTime = cnt.unavailable;
154
 
            else dateTime = KGlobal::locale()->formatDateTime(info.dateTime, KLocale::ShortDate, true);
155
 
 
156
 
            if (info.aperture.isEmpty()) aperture = cnt.unavailable;
157
 
            else aperture = info.aperture;
158
 
 
159
 
            if (info.focalLength.isEmpty()) focalLength = cnt.unavailable;
160
 
            else focalLength = info.focalLength;
161
 
 
162
 
            if (info.exposureTime.isEmpty()) exposureTime = cnt.unavailable;
163
 
            else exposureTime = info.exposureTime;
164
 
 
165
 
            if (info.sensitivity.isEmpty()) sensitivity = cnt.unavailable;
166
 
            else sensitivity = i18n("%1 ISO", info.sensitivity);
 
149
            if (info.make.isEmpty())
 
150
            {
 
151
                make = cnt.unavailable;
 
152
            }
 
153
            else
 
154
            {
 
155
                make = info.make;
 
156
            }
 
157
 
 
158
            if (info.model.isEmpty())
 
159
            {
 
160
                model = cnt.unavailable;
 
161
            }
 
162
            else
 
163
            {
 
164
                model = info.model;
 
165
            }
 
166
 
 
167
            if (!info.dateTime.isValid())
 
168
            {
 
169
                dateTime = cnt.unavailable;
 
170
            }
 
171
            else
 
172
            {
 
173
                dateTime = KGlobal::locale()->formatDateTime(info.dateTime, KLocale::ShortDate, true);
 
174
            }
 
175
 
 
176
            if (info.aperture.isEmpty())
 
177
            {
 
178
                aperture = cnt.unavailable;
 
179
            }
 
180
            else
 
181
            {
 
182
                aperture = info.aperture;
 
183
            }
 
184
 
 
185
            if (info.focalLength.isEmpty())
 
186
            {
 
187
                focalLength = cnt.unavailable;
 
188
            }
 
189
            else
 
190
            {
 
191
                focalLength = info.focalLength;
 
192
            }
 
193
 
 
194
            if (info.exposureTime.isEmpty())
 
195
            {
 
196
                exposureTime = cnt.unavailable;
 
197
            }
 
198
            else
 
199
            {
 
200
                exposureTime = info.exposureTime;
 
201
            }
 
202
 
 
203
            if (info.sensitivity.isEmpty())
 
204
            {
 
205
                sensitivity = cnt.unavailable;
 
206
            }
 
207
            else
 
208
            {
 
209
                sensitivity = i18n("%1 ISO", info.sensitivity);
 
210
            }
167
211
 
168
212
            identify += "<table cellspacing=0 cellpadding=0>";
169
213
            identify += cnt.cellBeg + i18n("<i>Make:</i>")        + cnt.cellMid + make         + cnt.cellEnd;
192
236
        QSize s = d->imageLabel->contentsRect().size();
193
237
 
194
238
        if (s.width() < pix.width() || s.height() < pix.height())
 
239
        {
195
240
            pixmap = pix.scaled(s, Qt::KeepAspectRatio);
 
241
        }
196
242
        else
 
243
        {
197
244
            pixmap = pix;
 
245
        }
198
246
 
199
247
        d->imageLabel->setPixmap(pixmap);
200
248
    }
209
257
 
210
258
// ------------------------------------------------------------------------
211
259
 
212
 
class ImageDialogPrivate
 
260
class ImageDialog::ImageDialogPrivate
213
261
{
214
262
 
215
263
public:
216
264
 
217
 
    ImageDialogPrivate()
 
265
    ImageDialogPrivate() :
 
266
        singleSelect(false)
218
267
    {
219
 
        singleSelect = false;
220
268
    }
221
269
 
222
270
    bool       singleSelect;
228
276
};
229
277
 
230
278
ImageDialog::ImageDialog(QWidget* parent, const KUrl& url, bool singleSelect, const QString& caption)
231
 
           : d(new ImageDialogPrivate)
 
279
    : d(new ImageDialogPrivate)
232
280
{
233
281
    d->singleSelect = singleSelect;
234
282
 
251
299
    kDebug() << "file formats=" << d->fileFormats;
252
300
 
253
301
    QPointer<KFileDialog> dlg   = new KFileDialog(url, d->fileFormats, parent);
254
 
    ImageDialogPreview *preview = new ImageDialogPreview(dlg);
 
302
    ImageDialogPreview* preview = new ImageDialogPreview(dlg);
255
303
    dlg->setPreviewWidget(preview);
256
304
    dlg->setOperationMode(KFileDialog::Opening);
257
305
 
258
306
    if (d->singleSelect)
259
307
    {
260
308
        dlg->setMode(KFile::File);
261
 
        if (caption.isEmpty()) dlg->setCaption(i18n("Select an Image"));
262
 
        else dlg->setWindowTitle(caption);
 
309
 
 
310
        if (caption.isEmpty())
 
311
        {
 
312
            dlg->setCaption(i18n("Select an Image"));
 
313
        }
 
314
        else
 
315
        {
 
316
            dlg->setWindowTitle(caption);
 
317
        }
 
318
 
263
319
        dlg->exec();
264
320
        d->url = dlg->selectedUrl();
265
321
    }
266
322
    else
267
323
    {
268
324
        dlg->setMode(KFile::Files);
269
 
        if (caption.isEmpty()) dlg->setCaption(i18n("Select Images"));
270
 
        else dlg->setWindowTitle(caption);
 
325
 
 
326
        if (caption.isEmpty())
 
327
        {
 
328
            dlg->setCaption(i18n("Select Images"));
 
329
        }
 
330
        else
 
331
        {
 
332
            dlg->setWindowTitle(caption);
 
333
        }
 
334
 
271
335
        dlg->exec();
272
336
        d->urls = dlg->selectedUrls();
273
337
    }
 
338
 
274
339
    delete dlg;
275
340
}
276
341
 
302
367
KUrl::List ImageDialog::getImageURLs(QWidget* parent, const KUrl& url, const QString& caption)
303
368
{
304
369
    ImageDialog dlg(parent, url, false, caption);
 
370
 
305
371
    if (!dlg.urls().isEmpty())
 
372
    {
306
373
        return dlg.urls();
 
374
    }
307
375
    else
 
376
    {
308
377
        return KUrl::List();
 
378
    }
309
379
}
310
380
 
311
 
 
312
381
KUrl ImageDialog::getImageURL(QWidget* parent, const KUrl& url, const QString& caption)
313
382
{
314
383
    ImageDialog dlg(parent, url, true, caption);
 
384
 
315
385
    if (dlg.url() != KUrl())
 
386
    {
316
387
        return dlg.url();
 
388
    }
317
389
    else
 
390
    {
318
391
        return KUrl();
 
392
    }
319
393
}
320
394
 
321
395
} // namespace Digikam