~ubuntu-branches/ubuntu/feisty/digikam/feisty

« back to all changes in this revision

Viewing changes to digikam/digikam/imagepropertiesexif.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2005-03-10 02:39:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050310023902-023nymfst5mg696c
Tags: 0.7.2-2
* debian/TODO: clean
* digikam manpage: better --detect-camera description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 * Author: Caulier Gilles <caulier dot gilles at free.fr>
 
3
 * Date  : 2004-11-17
 
4
 * Description :
 
5
 *
 
6
 * Copyright 2004 by Gilles Caulier
 
7
 *
 
8
 * This program is free software; you can redistribute it
 
9
 * and/or modify it under the terms of the GNU General
 
10
 * Public License as published by the Free Software Foundation;
 
11
 * either version 2, or (at your option)
 
12
 * any later version.
 
13
 * 
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 * 
 
19
 * ============================================================ */
 
20
 
 
21
#include <qlayout.h>
 
22
#include <qlabel.h>
 
23
#include <qpixmap.h>
 
24
#include <qcombobox.h>
 
25
#include <qwhatsthis.h>
 
26
 
 
27
#include <klocale.h>
 
28
#include <kurl.h>
 
29
#include <kapplication.h>
 
30
#include <kconfig.h>
 
31
 
 
32
#include <libkexif/kexifwidget.h>
 
33
 
 
34
#include "thumbnailjob.h"
 
35
#include "imagepropertiesexif.h"
 
36
 
 
37
ImagePropertiesEXIF::ImagePropertiesEXIF(QWidget* page)
 
38
{
 
39
    QVBoxLayout* vlay = new QVBoxLayout(page, 5, 5);
 
40
    QHBoxLayout* hlay = new QHBoxLayout(vlay);
 
41
 
 
42
    m_labelThumb = new QLabel( page );
 
43
    m_labelThumb->setFixedHeight( 48 );
 
44
    hlay->addWidget(m_labelThumb);
 
45
    hlay->addStretch();
 
46
 
 
47
    QLabel* levelLabel  = new QLabel(i18n("Select level of detail:"), page);
 
48
    m_levelCombo        = new QComboBox(page);
 
49
    hlay->addWidget(levelLabel);
 
50
    hlay->addWidget(m_levelCombo);
 
51
 
 
52
    QWhatsThis::add( m_levelCombo, i18n("<p>Select here the Exif information level to display<p>"
 
53
                                        "<b>Simple</b>: display general information about the photograph "
 
54
                                        " (default).<p>"
 
55
                                        "<b>Full</b>: display all EXIF sections.") );  
 
56
    
 
57
    m_exifWidget = new KExifWidget(page);
 
58
    vlay->addWidget(m_exifWidget);
 
59
 
 
60
    m_levelCombo->insertItem(i18n("Simple"));
 
61
    m_levelCombo->insertItem(i18n("Full"));
 
62
    connect(m_levelCombo, SIGNAL(activated(int)),
 
63
            SLOT(slotLevelChanged(int)));
 
64
 
 
65
    // -- read config ---------------------------------------------------------
 
66
 
 
67
    KConfig* config = kapp->config();
 
68
    config->setGroup("Image Properties Dialog");
 
69
    m_levelCombo->setCurrentItem(config->readNumEntry("EXIF Level", 0));
 
70
    m_currItem = config->readEntry("Current EXIF Item", QString());
 
71
    slotLevelChanged(0);
 
72
}
 
73
 
 
74
ImagePropertiesEXIF::~ImagePropertiesEXIF()
 
75
{
 
76
    if (!m_thumbJob.isNull())
 
77
        m_thumbJob->kill();
 
78
 
 
79
    KConfig* config = kapp->config();
 
80
    config->setGroup("Image Properties Dialog");
 
81
    config->writeEntry("EXIF Level", m_levelCombo->currentItem());
 
82
    config->writeEntry("Current EXIF Item", m_currItem);
 
83
}
 
84
 
 
85
void ImagePropertiesEXIF::setCurrentURL(const KURL& url)
 
86
{
 
87
 
 
88
    if (!m_thumbJob.isNull())
 
89
        m_thumbJob->kill();
 
90
 
 
91
    m_thumbJob = new ThumbnailJob(url, 48);
 
92
    
 
93
    connect(m_thumbJob, SIGNAL(signalThumbnailMetaInfo(const KURL&,
 
94
                                                       const QPixmap&,
 
95
                                                       const KFileMetaInfo*)),
 
96
            SLOT(slotGotThumbnail(const KURL&,
 
97
                                  const QPixmap&,
 
98
                                  const KFileMetaInfo*)));
 
99
   
 
100
    connect(m_thumbJob, SIGNAL(signalFailed(const KURL&)),
 
101
            SLOT(slotFailedThumbnail(const KURL&)));     
 
102
 
 
103
    // ----------------------------------------------------------------
 
104
 
 
105
    if (!m_exifWidget->getCurrentItemName().isNull())
 
106
        m_currItem = m_exifWidget->getCurrentItemName();
 
107
    
 
108
    m_exifWidget->loadFile(url.path());
 
109
 
 
110
    m_exifWidget->setCurrentItem(m_currItem);
 
111
}
 
112
 
 
113
void ImagePropertiesEXIF::slotLevelChanged(int)
 
114
{
 
115
    if (m_levelCombo->currentText() == i18n("Simple"))
 
116
        m_exifWidget->setMode(KExifWidget::SIMPLE);
 
117
    else
 
118
        m_exifWidget->setMode(KExifWidget::FULL);
 
119
}
 
120
 
 
121
void ImagePropertiesEXIF::slotGotThumbnail(const KURL&, const QPixmap& pix,
 
122
                                           const KFileMetaInfo*)
 
123
{
 
124
    if (!pix.isNull())
 
125
        m_labelThumb->setPixmap(pix);
 
126
    else
 
127
        m_labelThumb->clear();
 
128
}
 
129
 
 
130
void ImagePropertiesEXIF::slotFailedThumbnail(const KURL&)
 
131
{
 
132
    m_labelThumb->clear();
 
133
}
 
134
 
 
135
#include "imagepropertiesexif.moc"