1
1
/* ============================================================
2
* Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : search results view.
6
* Copyright 2005 by Renchi Raju
9
* Copyright (C) 2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
10
* Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
8
12
* This program is free software; you can redistribute it
9
13
* and/or modify it under the terms of the GNU General
10
14
* Public License as published by the Free Software Foundation;
19
23
* ============================================================ */
21
27
#include <qdatastream.h>
29
#include <qguardedptr.h>
23
33
#include <kio/job.h>
24
34
#include <kfileitem.h>
39
#include "thumbnailjob.h"
27
40
#include "albummanager.h"
28
41
#include "albumsettings.h"
29
42
#include "searchresultsitem.h"
30
43
#include "searchresultsview.h"
44
#include "searchresultsview.moc"
49
class SearchResultsViewPriv
53
SearchResultsViewPriv()
62
QDict<QIconViewItem> itemDict;
64
QGuardedPtr<ThumbnailJob> thumbJob;
66
KIO::TransferJob* listJob;
32
69
SearchResultsView::SearchResultsView(QWidget* parent)
38
m_libraryPath = AlbumManager::instance()->getLibraryPath();
39
m_filter = AlbumSettings::instance()->getAllFileFilter();
72
d = new SearchResultsViewPriv;
73
d->libraryPath = AlbumManager::instance()->getLibraryPath();
74
d->filter = AlbumSettings::instance()->getAllFileFilter();
41
76
setAutoArrange(true);
42
77
setResizeMode(QIconView::Adjust);
45
80
SearchResultsView::~SearchResultsView()
47
if (!m_thumbJob.isNull())
82
if (!d->thumbJob.isNull())
53
90
void SearchResultsView::openURL(const KURL& url)
59
if (!m_thumbJob.isNull())
96
if (!d->thumbJob.isNull())
64
101
QDataStream ds(ba, IO_WriteOnly);
102
ds << d->libraryPath;
68
105
ds << 0; // getting dimensions (not needed here)
106
ds << 0; // recursive sub-album (not needed here)
107
ds << 0; // recursive sub-tags (not needed here)
69
108
ds << 2; // miniListing (Use 1 for full listing)
71
m_listJob = new KIO::TransferJob(url, KIO::CMD_SPECIAL,
72
ba, QByteArray(), false);
73
connect(m_listJob, SIGNAL(result(KIO::Job*)),
74
SLOT(slotResult(KIO::Job*)));
75
connect(m_listJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
76
SLOT(slotData(KIO::Job*, const QByteArray&)));
110
d->listJob = new KIO::TransferJob(url, KIO::CMD_SPECIAL,
111
ba, QByteArray(), false);
113
connect(d->listJob, SIGNAL(result(KIO::Job*)),
114
this, SLOT(slotResult(KIO::Job*)));
116
connect(d->listJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
117
this, SLOT(slotData(KIO::Job*, const QByteArray&)));
79
120
void SearchResultsView::clear()
85
if (!m_thumbJob.isNull())
126
if (!d->thumbJob.isNull())
90
131
QIconView::clear();
113
154
SearchResultsItem* item = new SearchResultsItem(this, path);
114
m_itemDict.insert(path, item);
155
d->itemDict.insert(path, item);
116
157
ulist.append(KURL(path));
123
164
nextItem = item->nextItem();
124
165
if (!item->m_marked)
126
m_itemDict.remove(item->m_path);
167
d->itemDict.remove(item->m_path);
129
170
item = (SearchResultsItem*)nextItem;
131
172
arrangeItemsInGrid();
174
bool match = !ulist.isEmpty();
176
emit signalSearchResultsMatch(match);
134
if (!ulist.isEmpty())
136
m_thumbJob = new ThumbnailJob(ulist, 128, true, true);
180
d->thumbJob = new ThumbnailJob(ulist, 128, true, true);
138
connect(m_thumbJob, SIGNAL(signalThumbnail(const KURL&, const QPixmap&)),
182
connect(d->thumbJob, SIGNAL(signalThumbnail(const KURL&, const QPixmap&)),
139
183
this, SLOT(slotGotThumbnail(const KURL&, const QPixmap&)));
141
connect(m_thumbJob, SIGNAL(signalFailed(const KURL&)),
185
connect(d->thumbJob, SIGNAL(signalFailed(const KURL&)),
142
186
this, SLOT(slotFailedThumbnail(const KURL&)));
148
192
if (job->error())
149
193
job->showErrorDialog(this);
154
197
void SearchResultsView::slotGotThumbnail(const KURL& url, const QPixmap& pix)
156
QIconViewItem* i = m_itemDict.find(url.path());
199
QIconViewItem* i = d->itemDict.find(url.path());
158
201
i->setPixmap(pix);
163
206
void SearchResultsView::slotFailedThumbnail(const KURL&)
168
#include "searchresultsview.moc"
211
} // namespace Digikam