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 <QStringList> 00026 #include <QImage> 00027 00028 #include <mthread.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 ThumbGenEvent : public QEvent 00040 { 00041 public: 00042 ThumbGenEvent(ThumbData *td) : QEvent(kEventType), thumbData(td) {} 00043 ~ThumbGenEvent() {} 00044 00045 ThumbData *thumbData; 00046 00047 static Type kEventType; 00048 }; 00049 00050 class ThumbGenerator : public MThread 00051 { 00052 public: 00053 00054 ThumbGenerator(QObject *parent, int w, int h); 00055 ~ThumbGenerator(); 00056 00057 void setSize(int w, int h); 00058 void setDirectory(const QString& directory, bool isGallery=false); 00059 void addFile(const QString& fileName); 00060 void cancel(); 00061 00062 static QString getThumbcacheDir(const QString& inDir); 00063 00064 protected: 00065 00066 void run(); 00067 00068 private: 00069 00070 bool moreWork(); 00071 bool checkGalleryDir(const QFileInfo& fi); 00072 bool checkGalleryFile(const QFileInfo& fi); 00073 void loadDir(QImage& image, const QFileInfo& fi); 00074 void loadFile(QImage& image, const QFileInfo& fi); 00075 00076 QObject *m_parent; 00077 QString m_directory; 00078 bool m_isGallery; 00079 QStringList m_fileList; 00080 QMutex m_mutex; 00081 int m_width; 00082 int m_height; 00083 bool m_cancel; 00084 }; 00085 00086 #endif /* THUMBGENERATOR_H */
1.6.3