00001 /* ============================================================ 00002 * File : thumbgenerator.h 00003 * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu> 00004 * Date : 2004-01-02 00005 * Description : 00006 * 00007 * Copyright 2004 by Renchi Raju 00008 00009 * This program is free software; you can redistribute it 00010 * and/or modify it under the terms of the GNU General 00011 * Public License as published bythe Free Software Foundation; 00012 * either version 2, or (at your option) 00013 * any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * ============================================================ */ 00021 00022 #ifndef THUMBGENERATOR_H 00023 #define THUMBGENERATOR_H 00024 00025 #include <qthread.h> 00026 #include <qstring.h> 00027 #include <qstringlist.h> 00028 #include <qimage.h> 00029 00030 class QObject; 00031 class QImage; 00032 00033 typedef struct { 00034 QImage thumb; 00035 QString fileName; 00036 QString directory; 00037 } ThumbData; 00038 00039 class ThumbGenerator : public QThread 00040 { 00041 public: 00042 00043 ThumbGenerator(QObject *parent, int w, int h); 00044 ~ThumbGenerator(); 00045 00046 void setSize(int w, int h); 00047 void setDirectory(const QString& directory, bool isGallery=false); 00048 void addFile(const QString& fileName); 00049 void cancel(); 00050 00051 QString getThumbcacheDir(const QString& inDir); 00052 00053 protected: 00054 00055 void run(); 00056 00057 private: 00058 00059 bool moreWork(); 00060 bool checkGalleryDir(const QFileInfo& fi); 00061 bool checkGalleryFile(const QFileInfo& fi); 00062 void loadDir(QImage& image, const QFileInfo& fi); 00063 void loadFile(QImage& image, const QFileInfo& fi); 00064 00065 bool mkpath(const QString& inPath); 00066 00067 QObject *m_parent; 00068 QString m_directory; 00069 bool m_isGallery; 00070 QStringList m_fileList; 00071 QMutex m_mutex; 00072 int m_width, m_height; 00073 00074 }; 00075 00076 #endif /* THUMBGENERATOR_H */
1.5.5