Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

launcherview.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef LAUNCHERVIEW_H
00021 #define LAUNCHERVIEW_H
00022 
00023 #include <qtopia/storage.h>
00024 #include <qtopia/applnk.h>
00025 
00026 #include <qvbox.h>
00027 #include <qiconview.h>
00028 #include <qtimer.h>
00029 #include <qmap.h>
00030 
00031 class CategorySelect;
00032 class LauncherIconView;
00033 class LauncherItem;
00034 class QIconViewItem;
00035 class QLabel;
00036 class QWidgetStack;
00037 class MenuButton;
00038 class QComboBox;
00039 
00040 enum BusyIndicatorType {
00041     BIT_Normal = 0,
00042     BIT_Animated
00043 };
00044 
00045 class LauncherView : public QVBox
00046 {
00047     Q_OBJECT
00048 
00049 public:
00050     LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
00051     ~LauncherView();
00052 
00053     void hideIcons();
00054 
00055     bool removeLink(const QString& linkfile);
00056     void addItem(AppLnk* app, bool resort=TRUE);
00057     void changeItem(const AppLnk&old,AppLnk*nlink);
00058 
00059     void removeAllItems();
00060     void setSortEnabled(bool);
00061     void setUpdatesEnabled(bool);
00062     void sort();
00063 
00064     void setToolsEnabled(bool);
00065     void updateTools();
00066 
00067     void setBusy(bool);
00068     void setBusyIndicatorType( const QString& );
00069 
00070     enum ViewMode { Icon, List };
00071     void setViewMode( ViewMode m );
00072     ViewMode viewMode() const { return vmode; }
00073 
00074     enum BackgroundType { Ruled, SolidColor, Image };
00075     void setBackgroundType( BackgroundType t, const QString & );
00076     BackgroundType backgroundType() const { return bgType; }
00077 
00078     void setTextColor( const QColor & );
00079     QColor textColor() const { return textCol; }
00080 
00081     void setViewFont( const QFont & );
00082     void clearViewFont();
00083 
00084     void setColNumber( int );
00085     void relayout(void);
00086     LauncherIconView* iconView() { return icons; };
00087 
00088 signals:
00089     void clicked( const AppLnk * );
00090     void rightPressed( AppLnk * );
00091 
00092 protected slots:
00093     void selectionChanged();
00094     void returnPressed( QIconViewItem *item );
00095     void itemClicked( int, QIconViewItem * );
00096     void itemPressed( int, QIconViewItem * );
00097     void sortBy(int);
00098     void showType(int);
00099     void showCategory( int );
00100     void resizeEvent(QResizeEvent *);
00101     void flushBgCache();
00102 
00103 protected:
00104     void paletteChange( const QPalette & );
00105 
00106     void fontChanged(const QFont &);
00107 
00108 private:
00109     static bool bsy;
00110     QWidget* tools;
00111     LauncherIconView* icons;
00112     QComboBox *typemb;
00113     QStringList typelist;
00114     CategorySelect *catmb;
00115     ViewMode vmode;
00116     BackgroundType bgType;
00117     QString bgName;
00118     QColor textCol;
00119 
00120     QImage loadBackgroundImage(QString &fname);
00121 
00122 };
00123 
00124 /* from opie-eye */
00125 struct PixmapInfo {
00126     PixmapInfo() : width( -1 ), height( -1 ) {}
00127     bool operator==( const PixmapInfo& r ) {
00128         if ( width  != r.width  ) return false;
00129         if ( height != r.height ) return false;
00130         if ( file   != r.file   ) return false;
00131         return true;
00132     }
00133     int width, height;
00134     QString file;
00135     QPixmap pixmap;
00136 };
00137 
00138 class LauncherThumbReceiver:public QObject
00139 {
00140     Q_OBJECT
00141     typedef QValueList<PixmapInfo> PixmapInfos;
00142 public:
00143     LauncherThumbReceiver();
00144     ~LauncherThumbReceiver();
00145     void requestThumb(const QString&file,int width,int height);
00146 
00147 public slots:
00148     void recieve( const QCString&, const QByteArray& );
00149 protected slots:
00150     virtual void sendRequest();
00151 
00152 signals:
00153     void sig_Thumbnail(const QPixmap&,const QString&,int);
00154 
00155 protected:
00156     QTimer requestTimer;
00157     PixmapInfos m_inThumbNail;
00158 };
00159 
00160 class LauncherIconView : public QIconView {
00161     Q_OBJECT
00162 public:
00163     LauncherIconView( QWidget* parent, const char* name=0 );
00164     ~LauncherIconView();
00165     QIconViewItem* busyItem() const;
00166 
00167 #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
00168     QPixmap busyPixmap() const { return busyPix; }
00169 #endif
00170     void setBigIcons( bool bi );
00171     void updateCategoriesAndMimeTypes();
00172     void setBusyIndicatorType ( BusyIndicatorType t );
00173     void setStaticBackgroundPicture( bool enable );
00174     void doAutoScroll()
00175     {
00176     // We don't want rubberbanding (yet)
00177     }
00178 
00179     void setBusy(bool on);
00180     bool inKeyEvent() const { return ike; }
00181 
00182     void addItem(AppLnk* app, bool resort=TRUE);
00183     bool removeLink(const QString& linkfile,bool removeCache = true);
00184     void changeItem(const AppLnk&old,AppLnk*nlink);
00185 
00186     QStringList mimeTypes() const;
00187     QStringList categories() const;
00188     void clear();
00189     void addCatsAndMimes(AppLnk* app);
00190 
00191     void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
00192 
00193     void setBackgroundPixmap( const QPixmap &pm ) {
00194         bgPixmap = pm;
00195     }
00196 
00197     void setBackgroundColor( const QColor &c ) {
00198         bgColor = c;
00199     }
00200 
00201     void setColNumber( int );
00202 
00203     void drawBackground( QPainter *p, const QRect &r );
00204     void setItemTextPos( ItemTextPos pos );
00205     void hideOrShowItems(bool resort);
00206 
00207     void setTypeFilter(const QString& typefilter, bool resort);
00208     void setCategoryFilter( int catfilter, bool resort );
00209 
00210     enum SortMethod { Name, Date, Type };
00211 
00212     void setSortMethod( SortMethod m );
00213     int compare(const AppLnk* a, const AppLnk* b);
00214     void requestEyePix(const LauncherItem*which);
00215 
00216     static QMap<QString,QPixmap>* sm_EyeCache;
00217 
00218     virtual void setPalette(const QPalette & palette);
00219     virtual void unsetPalette();
00220 
00221 protected:
00222     virtual void timerEvent( QTimerEvent *te );
00223     void styleChange( QStyle &old );
00224     void calculateGrid( ItemTextPos pos );
00225     void focusInEvent( QFocusEvent * ) {}
00226     void focusOutEvent( QFocusEvent * ) {}
00227     LauncherItem*findDocItem(const QString&);
00228     void addCheckItem(AppLnk* app);
00229     void checkCallback();
00230     virtual void keyPressEvent(QKeyEvent* e);
00231 
00232 protected slots:
00233     void setEyePixmap(const QPixmap&,const QString&,int width);
00234     void stopEyeTimer();
00235 
00236 private:
00237     QList<AppLnk> hidden;
00238     QDict<void> mimes;
00239     QDict<void> cats;
00240     SortMethod sortmeth;
00241     QRegExp tf;
00242     int cf;
00243     LauncherItem* bsy;
00244     int busyTimer;
00245     bool ike;
00246     bool bigIcns;
00247     QPixmap bgPixmap;
00248     QColor bgColor;
00249     LauncherThumbReceiver*m_EyeCallBack;
00250 #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
00251     QPixmap busyPix;
00252 #endif
00253     BusyIndicatorType busyType;
00254     QTimer m_eyeTimer;
00255     int numColumns;
00256     bool staticBackground;
00257 };
00258 
00259 #endif // LAUNCHERVIEW_H

Generated on Sat Nov 5 16:15:31 2005 for OPIE by  doxygen 1.4.2