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

« back to all changes in this revision

Viewing changes to digikam/digikam/imageproperties.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
// Qt includes. 
 
22
 
 
23
#include <qlayout.h>
 
24
#include <qsize.h>
 
25
#include <qrect.h>
 
26
#include <qcheckbox.h>
 
27
 
 
28
// KDE includes.
 
29
 
 
30
#include <klocale.h>
 
31
#include <kapplication.h>
 
32
#include <kcursor.h>
 
33
#include <kglobal.h>
 
34
#include <kdebug.h>
 
35
 
 
36
// Local includes.
 
37
 
 
38
#include "albumiconview.h"
 
39
#include "albumiconitem.h"
 
40
 
 
41
#include "imagepropertiesgeneral.h"
 
42
#include "imagepropertiesexif.h"
 
43
#include "imagepropertieshistogram.h"
 
44
#include "imageproperties.h"
 
45
 
 
46
 
 
47
// Constructor with AlbumIconView and AlbumIconItem instance.
 
48
 
 
49
ImageProperties::ImageProperties(AlbumIconView* view, AlbumIconItem* currItem)
 
50
               : KDialogBase(Tabbed, QString::null, 
 
51
                             Help|User1|User2|Stretch|Close,
 
52
                             Close, view, 0, true, true, 
 
53
                             KStdGuiItem::guiItem(KStdGuiItem::Forward), 
 
54
                             KStdGuiItem::guiItem(KStdGuiItem::Back))
 
55
{
 
56
    m_view     = view; 
 
57
    m_currItem = currItem;
 
58
    m_currURL  = currItem->fileItem()->url();
 
59
    m_mode     = MULTI;
 
60
    
 
61
    m_selectionArea = 0;
 
62
 
 
63
    enableButton(User1, m_currItem->nextItem() != 0);
 
64
    enableButton(User2, m_currItem->prevItem() != 0);
 
65
    
 
66
    setupGui();
 
67
}
 
68
 
 
69
 
 
70
ImageProperties::ImageProperties(QWidget *parent, const KURL& url, QRect *selectionArea)
 
71
               : KDialogBase(Tabbed, QString::null, 
 
72
                             Help|Stretch|Close,
 
73
                             Close, parent, 0, true, true)
 
74
{
 
75
    m_view          = 0L;
 
76
    m_currItem      = 0L;
 
77
    m_currURL       = url;
 
78
    m_mode          = SINGLE;
 
79
                      
 
80
    m_selectionArea = selectionArea;
 
81
    
 
82
    setupGui();
 
83
}
 
84
 
 
85
void ImageProperties::setupGui(void)
 
86
{
 
87
    parentWidget()->setCursor( KCursor::waitCursor() );
 
88
    setHelp("propertiesmetadatahistogram.anchor", "digikam");        
 
89
 
 
90
    m_generalPage   = new ImagePropertiesGeneral(addPage(i18n("&General")));
 
91
    m_exifPage      = new ImagePropertiesEXIF(addPage(i18n("&EXIF")));
 
92
    m_histogramPage = new ImagePropertiesHistogram(addPage(i18n("&Histogram")),
 
93
                                                   m_selectionArea);
 
94
    
 
95
    // Read config.
 
96
    kapp->config()->setGroup("Image Properties Dialog");
 
97
    showPage(kapp->config()->readNumEntry("Tab Active", 0)); 
 
98
 
 
99
    // Init all info data.
 
100
    
 
101
    slotItemChanged();
 
102
    
 
103
    resize(configDialogSize("Image Properties Dialog"));
 
104
    parentWidget()->setCursor( KCursor::arrowCursor() );       
 
105
}
 
106
 
 
107
ImageProperties::~ImageProperties()
 
108
{
 
109
    kapp->config()->setGroup("Image Properties Dialog");
 
110
    kapp->config()->writeEntry("Tab Active", activePageIndex());
 
111
 
 
112
    saveDialogSize("Image Properties Dialog");
 
113
 
 
114
    delete m_generalPage;
 
115
    delete m_exifPage;
 
116
    delete m_histogramPage;
 
117
}
 
118
 
 
119
void ImageProperties::slotUser1()
 
120
{
 
121
    if (m_mode != MULTI)
 
122
        return;
 
123
    
 
124
    if (!m_currItem)
 
125
        return;
 
126
 
 
127
    if (!m_currItem->nextItem())
 
128
    {
 
129
        enableButton(User1, false);
 
130
        return;
 
131
    }
 
132
        
 
133
    m_currItem  = dynamic_cast<AlbumIconItem*>(m_currItem->nextItem());
 
134
    m_currURL   = m_currItem->fileItem()->url();    
 
135
    m_currItem->setSelected(true);
 
136
    m_view->ensureItemVisible(m_currItem);
 
137
    
 
138
    enableButton(User1, m_currItem->nextItem() != 0);
 
139
    enableButton(User2, m_currItem->prevItem() != 0);
 
140
    
 
141
    slotItemChanged();
 
142
}
 
143
 
 
144
void ImageProperties::slotUser2()
 
145
{
 
146
    if (m_mode != MULTI)
 
147
        return;
 
148
    
 
149
    if (!m_currItem)
 
150
        return;
 
151
 
 
152
    if (!m_currItem->prevItem())
 
153
    {
 
154
        enableButton(User2, false);
 
155
        return;
 
156
    }
 
157
    
 
158
    m_currItem    = dynamic_cast<AlbumIconItem*>(m_currItem->prevItem());
 
159
    m_currURL     = m_currItem->fileItem()->url();    
 
160
    m_currItem->setSelected(true);
 
161
    m_view->ensureItemVisible(m_currItem);
 
162
    
 
163
    enableButton(User1, m_currItem->nextItem() != 0);
 
164
    enableButton(User2, m_currItem->prevItem() != 0);
 
165
 
 
166
    slotItemChanged();
 
167
}
 
168
 
 
169
void ImageProperties::slotItemChanged()
 
170
{
 
171
    if (!m_currURL.isValid())
 
172
        return;
 
173
 
 
174
    
 
175
    setCursor(KCursor::waitCursor());
 
176
 
 
177
    setCaption(i18n("Properties for '%1'").arg(m_currURL.fileName()));
 
178
 
 
179
    m_generalPage->setCurrentURL(m_currURL);
 
180
    m_histogramPage->setCurrentURL(m_currURL);
 
181
    m_exifPage->setCurrentURL(m_currURL);
 
182
 
 
183
    setCursor( KCursor::arrowCursor() );
 
184
}
 
185
 
 
186
#include "imageproperties.moc"
 
187