Qmmp
/usr/src/RPM/BUILD/qmmp-0.11-svn/src/qmmpui/filedialog.h
00001 /**************************************************************************
00002 *   Copyright (C) 2008-2016 by Ilya Kotov                                 *
00003 *   forkotov02@hotmail.ru                                                 *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU General Public License as published by  *
00007 *   the Free Software Foundation; either version 2 of the License, or     *
00008 *   (at your option) any later version.                                   *
00009 *                                                                         *
00010 *   This program is distributed in the hope that it will be useful,       *
00011 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013 *   GNU General Public License for more details.                          *
00014 *                                                                         *
00015 *   You should have received a copy of the GNU General Public License     *
00016 *   along with this program; if not, write to the                         *
00017 *   Free Software Foundation, Inc.,                                       *
00018 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
00019 ***************************************************************************/
00020 
00021 #ifndef FILEDIALOG_H
00022 #define FILEDIALOG_H
00023 
00024 #include <QString>
00025 #include <QStringList>
00026 #include <QFileDialog>
00027 #include <QHash>
00028 #include "filedialogfactory.h"
00029 
00030 class QmmpUiPluginCache;
00031 
00035 class FileDialog : public QObject
00036 {
00037     Q_OBJECT
00038 public:
00042     static QList <FileDialogFactory*> factories();
00046     static void setEnabled(FileDialogFactory *factory);
00050     static bool isEnabled(FileDialogFactory *factory);
00055     static QString file(FileDialogFactory *factory);
00059     enum Mode
00060     {
00061         AddFile = 0,   
00062         AddDir,        
00063         AddFiles,      
00064         AddDirs,       
00065         AddDirsFiles,  
00066         PlayDirsFiles, 
00067         SaveFile       
00068     };
00076     static QString getExistingDirectory(QWidget *parent = 0,
00077                                         const QString &caption = QString(),
00078                                         const QString &dir = QString());
00089     static QString getOpenFileName(QWidget *parent = 0,
00090                                    const QString &caption = QString(),
00091                                    const QString &dir = QString(),
00092                                    const QString &filter = QString(),
00093                                    QString *selectedFilter = 0);
00104     static QStringList getOpenFileNames(QWidget *parent = 0,
00105                                         const QString &caption = QString(),
00106                                         const QString &dir = QString(),
00107                                         const QString &filter = QString(),
00108                                         QString *selectedFilter = 0);
00119     static QString getSaveFileName (QWidget *parent = 0,
00120                                     const QString &caption = QString(),
00121                                     const QString &dir = QString(),
00122                                     const QString &filter = QString(),
00123                                     QString *selectedFilter = 0);
00140     static void popup(QWidget *parent = 0,
00141                       Mode mode = AddFiles,
00142                       QString *dir = 0,
00143                       QObject *receiver = 0,
00144                       const char *member = 0,
00145                       const QString &caption = QString(),
00146                       const QString &filters = QString());
00147 
00148 signals:
00152     void filesSelected(const QStringList &selected, bool play = false);
00153 
00154 protected:
00158     FileDialog();
00162     virtual ~FileDialog();
00172     virtual void raise(const QString &dir, Mode mode,
00173                        const QString &caption, const QStringList &mask);
00186     virtual QStringList exec(QWidget *parent, const QString &dir, Mode mode,
00187                              const QString &caption, const QString &filter = QString(),
00188                              QString *selectedFilter = 0) = 0;
00189 
00190 private slots:
00191     void updateLastDir(const QStringList&);
00192 
00193 private:
00194     static void loadPlugins();
00195     static FileDialog* instance();
00196     static FileDialogFactory *m_currentFactory;
00197     static FileDialog* m_instance;
00198     static QList<QmmpUiPluginCache*> *m_cache;
00199 
00200     void init(QObject* receiver, const char* member, QString *dir);
00201     bool m_initialized;
00202     QString *m_lastDir;
00203 };
00204 
00205 #endif
 All Classes Functions Variables Enumerations Enumerator