1 /* Copyright (C) 2003-2009 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include "ThumbnailBuilder.h"
21 #include "ImageManager/Manager.h"
22 #include "DB/ImageDB.h"
23 #include "DB/ResultId.h"
25 ThumbnailView::ThumbnailBuilder::ThumbnailBuilder( QWidget
* parent
)
26 :QProgressDialog( parent
)
28 const DB::Result images
= DB::ImageDB::instance()->images();
29 setMaximum( qMax( images
.size() - 1, 0 ) );
30 setLabelText( i18n("Generating thumbnails") );
32 connect( this, SIGNAL( canceled() ), this, SLOT( slotCancelRequests() ) );
34 Q_FOREACH(const DB::ImageInfoPtr info
, images
.fetchInfos()) {
35 ImageManager::ImageRequest
* request
36 = new ImageManager::ImageRequest( info
->fileName(DB::AbsolutePath
),
37 QSize(256,256), info
->angle(),
39 request
->setPriority( ImageManager::BuildThumbnails
);
40 ImageManager::Manager::instance()->load( request
);
44 void ThumbnailView::ThumbnailBuilder::slotCancelRequests()
46 ImageManager::Manager::instance()->stop( this, ImageManager::StopAll
);
47 setValue( maximum() );
50 void ThumbnailView::ThumbnailBuilder::pixmapLoaded( const QString
& fileName
, const QSize
& size
, const QSize
& fullSize
, int, const QImage
&, const bool loadedOK
)
54 if ( fullSize
.width() != -1 ) {
55 DB::ImageInfoPtr info
= DB::ImageDB::instance()->info( fileName
, DB::AbsolutePath
);
56 info
->setSize( fullSize
);
58 setValue( value() + 1 );
61 #include "ThumbnailBuilder.moc"