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

« back to all changes in this revision

Viewing changes to digikam/libs/dialogs/rawcameradlg.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:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2008-04-07
 
7
 * Description : Raw camera list dialog
 
8
 *
 
9
 * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option)
 
15
 * any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
// Qt includes
 
25
 
 
26
#include <qlayout.h>
 
27
#include <qstringlist.h>
 
28
#include <qstring.h>
 
29
#include <qlabel.h>
 
30
#include <qlistview.h>
 
31
#include <qheader.h>
 
32
 
 
33
// KDElib includes
 
34
 
 
35
#include <klocale.h>
 
36
#include <kiconloader.h>
 
37
#include <kapplication.h>
 
38
#include <kaboutdata.h>
 
39
 
 
40
// LibKDcraw includes.
 
41
 
 
42
#include <libkdcraw/kdcraw.h>
 
43
#include <libkdcraw/dcrawbinary.h>
 
44
 
 
45
// Local includes.
 
46
 
 
47
#include "searchtextbar.h"
 
48
#include "rawcameradlg.h"
 
49
#include "rawcameradlg.moc"
 
50
 
 
51
namespace Digikam
 
52
{
 
53
 
 
54
class RawCameraDlgPriv
 
55
{
 
56
public:
 
57
 
 
58
    RawCameraDlgPriv()
 
59
    {
 
60
        listView  = 0;
 
61
        searchBar = 0;
 
62
    }
 
63
 
 
64
    QListView     *listView;
 
65
 
 
66
    SearchTextBar *searchBar;
 
67
};
 
68
 
 
69
RawCameraDlg::RawCameraDlg(QWidget *parent)
 
70
            : KDialogBase(parent, 0, true, QString(), Help|Ok, Ok, true)
 
71
{
 
72
    setHelp("digitalstillcamera.anchor", "digikam");
 
73
    setCaption(i18n("List of supported RAW camera"));
 
74
 
 
75
    d = new RawCameraDlgPriv;
 
76
 
 
77
    QWidget *page     = makeMainWidget();
 
78
    QGridLayout* grid = new QGridLayout(page, 2, 2, 0, spacingHint());
 
79
 
 
80
    QStringList list      = KDcrawIface::DcrawBinary::instance()->supportedCamera();
 
81
    QString     dcrawVer  = KDcrawIface::DcrawBinary::instance()->internalVersion();
 
82
    QString     KDcrawVer = KDcrawIface::KDcraw::version();
 
83
 
 
84
    // --------------------------------------------------------
 
85
 
 
86
    QLabel *logo            = new QLabel(page);
 
87
    KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
 
88
 
 
89
    if (KApplication::kApplication()->aboutData()->appName() == QString("digikam"))
 
90
        logo->setPixmap(iconLoader->loadIcon("digikam", KIcon::NoGroup, 96, KIcon::DefaultState, 0, true));
 
91
    else
 
92
        logo->setPixmap(iconLoader->loadIcon("showfoto", KIcon::NoGroup, 96, KIcon::DefaultState, 0, true));
 
93
 
 
94
    // --------------------------------------------------------
 
95
 
 
96
    QLabel *header = new QLabel(page);
 
97
    header->setText(i18n("<p>Using KDcraw library version %1"
 
98
                         "<p>Using Dcraw program version %2"
 
99
                         "<p>%3 models in the list")
 
100
                         .arg(KDcrawVer).arg(dcrawVer).arg(list.count()));
 
101
 
 
102
    // --------------------------------------------------------
 
103
 
 
104
    d->searchBar = new SearchTextBar(page, "RawCameraDlgSearchBar");
 
105
    d->listView  = new QListView(page);
 
106
    d->listView->addColumn("Camera Model");       // Header is hiden. No i18n here.
 
107
    d->listView->setSorting(1);
 
108
    d->listView->header()->hide();
 
109
    d->listView->setResizeMode(QListView::LastColumn);
 
110
 
 
111
    for (QStringList::Iterator it = list.begin() ; it != list.end() ; ++it)
 
112
        new QListViewItem(d->listView, *it);
 
113
 
 
114
    // --------------------------------------------------------
 
115
 
 
116
 
 
117
    grid->addMultiCellWidget(logo,         0, 0, 0, 0);
 
118
    grid->addMultiCellWidget(header,       0, 0, 1, 2);
 
119
    grid->addMultiCellWidget(d->listView,  1, 1, 0, 2);
 
120
    grid->addMultiCellWidget(d->searchBar, 2, 2, 0, 2);
 
121
    grid->setColStretch(1, 10);
 
122
    grid->setRowStretch(1, 10);
 
123
 
 
124
    // --------------------------------------------------------
 
125
 
 
126
    connect(d->searchBar, SIGNAL(signalTextChanged(const QString&)),
 
127
            this, SLOT(slotSearchTextChanged(const QString&)));
 
128
 
 
129
    resize(500, 500);
 
130
}
 
131
 
 
132
RawCameraDlg::~RawCameraDlg()
 
133
{
 
134
    delete d;
 
135
}
 
136
 
 
137
void RawCameraDlg::slotSearchTextChanged(const QString& filter)
 
138
{
 
139
    bool query     = false;
 
140
    QString search = filter.lower();
 
141
 
 
142
    QListViewItemIterator it(d->listView);
 
143
 
 
144
    for ( ; it.current(); ++it ) 
 
145
    {
 
146
        QListViewItem *item  = it.current();
 
147
 
 
148
        if (item->text(0).lower().contains(search))
 
149
        {
 
150
            query = true;
 
151
            item->setVisible(true);
 
152
        }
 
153
        else
 
154
        {
 
155
            item->setVisible(false);
 
156
        }
 
157
    }
 
158
 
 
159
    d->searchBar->slotSearchResult(query);
 
160
}
 
161
 
 
162
}  // NameSpace Digikam