ZFileDialog.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 * ZFileDialog.h
00003 * 
00004 * The code of this class is borrowed from zfiledialog.h (rev. 1.5) found in 
00005 * ZBEDic project.
00006 * Copyright (C) 2004 Rafal Mantiuk <rafm@users.sourceforge.org>
00007 ****************************************************************************/
00008 
00009 #ifndef ZFILE_DIALOG_H
00010 #define ZFILE_DIALOG_H
00011 
00012 #include <qdialog.h>
00013 #include <qdir.h>
00014 #include <qpixmap.h>
00015 
00016 class QListView;
00017 class QComboBox;
00018 class QListViewItem;
00019 class QLineEdit;
00020 
00021 class ZFileCustomFilter {
00022 
00023 public:
00024 
00025     virtual void filter( QStringList &fileList ) = 0;
00026 
00027 };
00028 
00029 
00030 class ZFileDialog : public QDialog {
00031 
00032     Q_OBJECT
00033 
00034 public:
00035 
00036     enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
00037     ZFileDialog( const QString title, const QString &path, Mode mode, QWidget *parent );
00038   
00039     const QDir* dir() const {
00040       return &currentDir;
00041     }
00042 
00043     void setFilters( const QStringList &filters );
00044   
00045     QStringList selectedFiles() const;
00046     QString selectedFile() const;
00047 
00048     void setSelection( const QString &name );
00049 
00050     void setCustomFilter( ZFileCustomFilter *filter ) {
00051         customFilter = filter;
00052     }
00053 
00054     virtual void show();
00055 
00056 protected:
00057 
00058     QDir currentDir;
00059     QListView *fileLV;
00060     QComboBox *fstabCB;
00061 
00062     QStringList dir_list;
00063     QStringList filters;
00064 
00065     QLineEdit *selection;
00066 
00067     Mode mode;
00068 
00069     ZFileCustomFilter *customFilter;
00070 
00071 private:
00072 
00073     void insertDirEntry( const QString &label, const QString &path, QPixmap *pixmap = NULL );
00074 
00075 protected:
00076 
00077     void setDir( QString path );
00078     void refreshFileList();
00079     int insertDirTree( const QString &label, QString basePath, const QString &path, bool subCheck,
00080     QPixmap *pixmap = NULL );
00081 
00082 protected slots:
00083 
00084     void dirSelected( int idx );
00085     void fileClicked( QListViewItem *it );
00086     void parentDirClicked();
00087     void itemSelected();
00088 
00089 };
00090 
00091 #endif

Generated on Sun Mar 1 17:30:47 2009 for toMOTko by  doxygen 1.5.6