~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/libs/widgets/metadata/metadatawidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.2.15 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080717202539-6n7dtirbkoo7qvhd
Tags: 2:0.9.4-1
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Date        : 2006-02-22
7
7
 * Description : a generic widget to display metadata
8
8
 *
9
 
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
9
 * Copyright (C) 2006-2008 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
38
38
#include <qsimplerichtext.h>
39
39
#include <qpaintdevicemetrics.h>
40
40
#include <qstylesheet.h>
 
41
#include <qlistview.h>
 
42
#include <qtooltip.h>
41
43
 
42
44
// KDE includes.
43
45
 
44
46
#include <kdialogbase.h>
45
 
#include <klistview.h>
46
47
#include <klocale.h>
47
48
#include <kfiledialog.h>
48
49
#include <kglobalsettings.h>
56
57
#include "ddebug.h"
57
58
#include "metadatalistview.h"
58
59
#include "mdkeylistviewitem.h"
 
60
#include "searchtextbar.h"
59
61
#include "metadatawidget.h"
60
62
#include "metadatawidget.moc"
61
63
 
73
75
        levelButtons = 0;
74
76
        view         = 0;
75
77
        mainLayout   = 0;
 
78
        searchBar    = 0;
76
79
    }
77
80
 
78
81
    QGridLayout            *mainLayout;
86
89
 
87
90
    MetadataListView       *view;
88
91
 
 
92
    SearchTextBar          *searchBar;
 
93
 
89
94
    DMetadata::MetaDataMap  metaDataMap;
90
95
};
91
96
 
94
99
{
95
100
    d = new MetadataWidgetPriv;
96
101
 
97
 
    d->mainLayout = new QGridLayout(this, 2, 4, KDialog::spacingHint(), KDialog::spacingHint());
 
102
    d->mainLayout = new QGridLayout(this, 3, 4, KDialog::spacingHint(), KDialog::spacingHint());
98
103
    KIconLoader *iconLoader = KApplication::kApplication()->iconLoader();
99
104
 
100
105
    d->levelButtons = new QHButtonGroup(this);
105
110
    QPushButton *simpleLevel = new QPushButton( d->levelButtons );
106
111
    simpleLevel->setPixmap( iconLoader->loadIcon( "ascii", (KIcon::Group)KIcon::Toolbar ) );
107
112
    simpleLevel->setToggleButton(true);
108
 
    QWhatsThis::add( simpleLevel, i18n( "Toggle tags view to a simple human-readable list" ) );
 
113
    QWhatsThis::add( simpleLevel, i18n( "Switch the tags view to a simple human-readable list" ) );
 
114
    QToolTip::add( simpleLevel, i18n( "Simple list" ));
109
115
    d->levelButtons->insert(simpleLevel, SIMPLE);
110
116
 
111
117
    QPushButton *fullLevel = new QPushButton( d->levelButtons );
112
118
    fullLevel->setPixmap( iconLoader->loadIcon( "document", (KIcon::Group)KIcon::Toolbar ) );
113
119
    fullLevel->setToggleButton(true);
114
 
    QWhatsThis::add( fullLevel, i18n( "Toggle tags view to a full list" ) );
 
120
    QWhatsThis::add( fullLevel, i18n( "Switch the tags view to a full list" ) );
 
121
    QToolTip::add( fullLevel, i18n( "Full list" ));
115
122
    d->levelButtons->insert(fullLevel, FULL);
116
123
 
117
124
    d->toolButtons = new QHButtonGroup(this);
120
127
 
121
128
    QPushButton *saveMetadata = new QPushButton( d->toolButtons );
122
129
    saveMetadata->setPixmap( iconLoader->loadIcon( "filesave", (KIcon::Group)KIcon::Toolbar ) );
123
 
    QWhatsThis::add( saveMetadata, i18n( "Save meta-data to a binary file" ) );
 
130
    QWhatsThis::add( saveMetadata, i18n( "Save metadata to a binary file" ) );
 
131
    QToolTip::add( saveMetadata, i18n( "Save metadata" ));
124
132
    d->toolButtons->insert(saveMetadata);
125
133
    
126
134
    QPushButton *printMetadata = new QPushButton( d->toolButtons );
127
135
    printMetadata->setPixmap( iconLoader->loadIcon( "fileprint", (KIcon::Group)KIcon::Toolbar ) );
128
 
    QWhatsThis::add( printMetadata, i18n( "Print meta-data to printer" ) );
 
136
    QWhatsThis::add( printMetadata, i18n( "Print metadata to printer" ) );
 
137
    QToolTip::add( printMetadata, i18n( "Print metadata" ));
129
138
    d->toolButtons->insert(printMetadata);
130
139
 
131
140
    QPushButton *copy2ClipBoard = new QPushButton( d->toolButtons );
132
141
    copy2ClipBoard->setPixmap( iconLoader->loadIcon( "editcopy", (KIcon::Group)KIcon::Toolbar ) );
133
 
    QWhatsThis::add( copy2ClipBoard, i18n( "Copy meta-data to clipboard" ) );
 
142
    QWhatsThis::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" ) );
 
143
    QToolTip::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" ));
134
144
    d->toolButtons->insert(copy2ClipBoard);
135
145
 
 
146
    d->view         = new MetadataListView(this);
 
147
    QString barName = QString(name) + "SearchBar";
 
148
    d->searchBar    = new SearchTextBar(this, barName.ascii());
 
149
 
 
150
    // -----------------------------------------------------------------
 
151
 
136
152
    d->mainLayout->addMultiCellWidget(d->levelButtons, 0, 0, 0, 1);
 
153
    d->mainLayout->addMultiCellWidget(d->toolButtons,  0, 0, 4, 4);
 
154
    d->mainLayout->addMultiCellWidget(d->view,         1, 1, 0, 4);
 
155
    d->mainLayout->addMultiCellWidget(d->searchBar,    2, 2, 0, 4);
 
156
    d->mainLayout->setRowStretch(1, 10);
137
157
    d->mainLayout->setColStretch(3, 10);
138
 
    d->mainLayout->addMultiCellWidget(d->toolButtons, 0, 0, 4, 4);
139
 
 
140
 
    d->view = new MetadataListView(this);
141
 
    d->mainLayout->addMultiCellWidget(d->view, 1, 1, 0, 4);
142
158
 
143
159
    // -----------------------------------------------------------------
144
160
    
152
168
            this, SLOT(slotPrintMetadata()));
153
169
 
154
170
    connect(saveMetadata, SIGNAL(clicked()),
155
 
            this, SLOT(slotSaveMetadataToFile()));                        
 
171
            this, SLOT(slotSaveMetadataToFile()));     
 
172
 
 
173
    connect(d->searchBar, SIGNAL(signalTextChanged(const QString&)),
 
174
            d->view, SLOT(slotSearchTextChanged(const QString&)));
 
175
 
 
176
    connect(d->view, SIGNAL(signalTextFilterMatch(bool)),
 
177
            d->searchBar, SLOT(slotSearchResult(bool)));                   
156
178
}
157
179
 
158
180
MetadataWidget::~MetadataWidget()
160
182
    delete d;
161
183
}
162
184
 
163
 
MetadataListView* MetadataWidget::view(void)
 
185
MetadataListView* MetadataWidget::view()
164
186
{
165
187
    return d->view;
166
188
}
247
269
    buildView();
248
270
}
249
271
 
250
 
void MetadataWidget::slotCopy2Clipboard(void)
 
272
void MetadataWidget::slotCopy2Clipboard()
251
273
{
252
274
    QString textmetadata = i18n("File name: %1 (%2)").arg(d->fileName).arg(getMetadataTitle());
253
275
    QListViewItemIterator it( d->view );
276
298
    QApplication::clipboard()->setData(new QTextDrag(textmetadata), QClipboard::Clipboard);
277
299
}
278
300
 
279
 
void MetadataWidget::slotPrintMetadata(void)
 
301
void MetadataWidget::slotPrintMetadata()
280
302
{
281
303
    QString textmetadata = i18n("<p><big><big><b>File name: %1 (%2)</b></big></big>")
282
304
                           .arg(d->fileName)
379
401
    buildView();
380
402
}
381
403
 
382
 
int MetadataWidget::getMode(void)
 
404
int MetadataWidget::getMode()
383
405
{
384
406
    int level = d->levelButtons->selectedId();
385
407
    return level;
395
417
    d->view->setCurrentItemByKey(itemKey);
396
418
}
397
419
 
398
 
bool MetadataWidget::loadFromData(QString fileName, const QByteArray& data)
 
420
bool MetadataWidget::loadFromData(const QString& fileName, const QByteArray& data)
399
421
{
400
422
    setFileName(fileName);
401
423
    return(setMetadata(data));
411
433
    return QString();
412
434
}
413
435
 
414
 
void MetadataWidget::setFileName(QString fileName)
 
436
void MetadataWidget::setFileName(const QString& fileName)
415
437
{
416
438
    d->fileName = fileName;
417
439
}
421
443
    QVBoxLayout *vLayout = new QVBoxLayout( KDialog::spacingHint() ); 
422
444
    vLayout->addWidget(w);
423
445
    vLayout->addStretch();
424
 
    d->mainLayout->addMultiCellLayout(vLayout, 2, 2, 0, 4);
 
446
    d->mainLayout->addMultiCellLayout(vLayout, 3, 3, 0, 4);
 
447
}
 
448
 
 
449
void MetadataWidget::buildView()
 
450
{
 
451
    d->view->slotSearchTextChanged(d->searchBar->text());
425
452
}
426
453
 
427
454
}  // namespace Digikam
428