File indexing completed on 2024-05-12 04:20:01
0001 /*************************************************************************** 0002 * Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 ***************************************************************************/ 0009 0010 #include "mobithumbnail.h" 0011 #include <qmobipocket/mobipocket.h> 0012 #include <qmobipocket/qfilestream.h> 0013 0014 #include <QFile> 0015 0016 #include <KPluginFactory> 0017 0018 K_PLUGIN_CLASS_WITH_JSON(MobiThumbnail, "mobithumbnail.json") 0019 0020 MobiThumbnail::MobiThumbnail(QObject *parent, const QVariantList &args) 0021 : KIO::ThumbnailCreator(parent, args) 0022 { 0023 } 0024 0025 KIO::ThumbnailResult MobiThumbnail::create(const KIO::ThumbnailRequest &request) 0026 { 0027 Mobipocket::QFileStream f(request.url().toLocalFile()); 0028 Mobipocket::Document doc(&f); 0029 if (!doc.isValid()) { 0030 return KIO::ThumbnailResult::fail(); 0031 } 0032 QImage img = doc.thumbnail(); 0033 return !img.isNull() ? KIO::ThumbnailResult::pass(img) : KIO::ThumbnailResult::fail(); 0034 } 0035 0036 #include "mobithumbnail.moc"