diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmpui/filedialog.h | 182 | ||||
| -rw-r--r-- | src/qmmpui/filedialogfactory.h | 37 | ||||
| -rw-r--r-- | src/qmmpui/fileloader.h | 30 |
3 files changed, 206 insertions, 43 deletions
diff --git a/src/qmmpui/filedialog.h b/src/qmmpui/filedialog.h index fd87b47fa..3c287fee7 100644 --- a/src/qmmpui/filedialog.h +++ b/src/qmmpui/filedialog.h @@ -1,5 +1,5 @@ /************************************************************************** -* Copyright (C) 2008 by Ilya Kotov * +* Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -30,90 +30,214 @@ #include "filedialogfactory.h" -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> +/*! @brief The FileDialog class is the base interface class of file dialogs. + * @author Vladimir Kuznetsov <vovanec@gmail.com> */ - class FileDialog : public QObject { Q_OBJECT public: - enum Mode{AddFile = 0, AddDir, AddFiles, AddDirs, AddDirsFiles, SaveFile}; - + /*! + * Enum of available file dialog modes + */ + enum Mode + { + AddFile = 0, /*!< Get existing file */ + AddDir, /*!< Get existing directory */ + AddFiles, /*!< Get existing files */ + AddDirs, /*!< Get existing directories */ + AddDirsFiles, /*!< Get existing files and directories */ + SaveFile /*!< Get existing or non-existing file */ + }; + /*! + * This is a static function that will open modal file dialog and + * return an existing directory selected by the user. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + */ static QString getExistingDirectory(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString()); - + /*! + * This is a static function that will open modal file dialog and + * return an existing file selected by the user. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter + */ static QString getOpenFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0); - + /*! + * This is a static function that will open modal file dialog and + * return an existing file selected by the user. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter. + */ static QStringList getOpenFileNames(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0); - + /*! + * This is a static function that will open modal file dialog and + * return a file name selected by the user. The file does not have to exist. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter. + */ static QString getSaveFileName (QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0); - + /*! + * Opens nonmodal file dialog. Selected file dialog should support nonmodal mode. + * Otherwise this function creates modal dialog. + * @param parent Parent widget. + * @param mode File dialog mode. + * @param dir Default directory. + * @param receiver Receiver QObject. + * @param member Receiver slot. + * @param caption Dialog title. + * @param filters Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter. + * + * Usage: FileDialog::popup(this, FileDialog::AddDirs, &m_lastDir, + * m_playListModel, SLOT(addFileList(const QStringList&)), + * tr("Choose a directory")); + */ static void popup(QWidget *parent = 0, - Mode = AddFiles, + Mode mode = AddFiles, QString *dir = 0, QObject *receiver = 0, const char *member = 0, const QString &caption = QString(), const QString &filters = QString()); - + /*! + * Returns a list of registered file dialog factories. + */ static QList <FileDialogFactory*> registeredFactories(); + /*! + * Returns \b true if selected file dialog doesn't support nonmodal mode, otherwise \b false + */ static bool isModal(); + /*! + * Selects current file dialog factory. + */ static void setEnabled(FileDialogFactory *factory); + /*! + * Returns \b true if file dialog \b factory is used by default, otherwise \b false + */ static bool isEnabled(FileDialogFactory *factory); - signals: + /*! + * Emitted when the add button has pressed. Subclass should emit this signal. + */ void filesAdded(const QStringList&); protected: + /*! + * Object constructor. + */ FileDialog(); + /*! + * This is a function that will open modal file dialog and + * return an existing directory selected by the user. + * + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + */ virtual QString existingDirectory(QWidget *parent, const QString &caption, const QString &dir); - + /*! + * This is a function that will open modal file dialog and + * return an existing file selected by the user. + * Subclass should reimplement this function. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter + */ virtual QString openFileName( QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter); - + /*! + * This is a function that will open modal file dialog and + * return an existing files selected by the user. + * Subclass should reimplement this function. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter + */ virtual QStringList openFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter); - + /*! + * This is a function that will open modal file dialog and + * return a file name selected by the user. The file does not have to exist. + * Subclass should reimplement this function. + * @param parent Parent widget. + * @param caption Dialog title. + * @param dir Default directory. + * @param filter Filer used by file dialog + * (example: "Audio (*.mp3 *.ogg);;Text files (*.txt);;XML files (*.xml)"). + * @param selectedFilter Default selected filter. + */ virtual QString saveFileName ( QWidget *parent , const QString &caption, const QString &dir, const QString &filter , QString *selectedFilter); - + /*! + * Returns \b true if file dialog doesn't support nonmodal mode, otherwise \b false + * Subclass should reimplement this function. + */ virtual bool modal()const { return TRUE; }; - + /*! + * Object destructor + */ virtual ~FileDialog() { ; }; - - void init(QObject* receiver, const char* member, QString *dir); - + /*! + * Opens nonmodal file dialog. Selected file dialog should support nonmodal mode. + * Otherwise this function does nothing. + * Nonmodal dialog subclass should reimplement this function. + * @param dir Default directory. + * @param mode File dialog mode. + * @param caption Dialog title. + * @param mask Filer used by file dialog + */ virtual void raise(const QString &dir = QString(), Mode mode = AddFiles, const QString &caption = QString(), @@ -124,17 +248,27 @@ protected: Q_UNUSED(caption); Q_UNUSED(mask); } - + /*! + * Returns a pointer to the selected file dialog instance. + */ static FileDialog* instance(); + /*! + * Returns a pointer to the default file dialog instance. + */ static FileDialog* defaultInstance(); + /*! + * Registers file dialog \b factory + * Returns \b false if \b factory is already registered, otherwise \b true + */ static bool registerFactory(FileDialogFactory *factory); - static void registerBuiltinFactories(); - static void registerExternalFactories(); private slots: void updateLastDir(const QStringList&); private: + void init(QObject* receiver, const char* member, QString *dir); + static void registerBuiltinFactories(); + static void registerExternalFactories(); static QMap <QString,FileDialogFactory*> factories; static FileDialog* _instance; static QString m_current_factory; diff --git a/src/qmmpui/filedialogfactory.h b/src/qmmpui/filedialogfactory.h index 5aaceac1f..115d619d1 100644 --- a/src/qmmpui/filedialogfactory.h +++ b/src/qmmpui/filedialogfactory.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Ilya Kotov * + * Copyright (C) 2008-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -24,30 +24,49 @@ class QObject; class QTranslator; class FileDialog; +/*! @brief Helper class to store file dialog plugin properies. + */ class FileDialogProperties { public: + /*! + * Constructor + */ FileDialogProperties() { hasAbout = FALSE; } - bool hasAbout; - QString name; - QString shortName; + bool hasAbout; /*!< Should be \b true if the file dialog plugin has about dialog, otherwise \b false */ + QString name; /*!< File dialog plugin full name */ + QString shortName; /*!< File dialog short name for internal usage */ }; - - -/** - @author Vladimir Kuznetsov <vovanec@gmail.com> +/*! @brief File dialog plugin interface. + * @author Vladimir Kuznetsov <vovanec@gmail.com> */ - class FileDialogFactory { public: + /*! + * Object destructor. + */ virtual ~FileDialogFactory() {}; + /*! + * Creates file dialog object. + */ virtual FileDialog* create() = 0; + /*! + * Returns file dialog plugin properties. + */ virtual const FileDialogProperties properties() const = 0; + /*! + * Shows about dialog. + * @param parent Parent widget. + */ virtual void showAbout(QWidget *parent) = 0; + /*! + * Creates QTranslator object of the system locale. Should return 0 if translation doesn't exist. + * @param parent Parent object. + */ virtual QTranslator *createTranslator(QObject *parent) = 0; }; diff --git a/src/qmmpui/fileloader.h b/src/qmmpui/fileloader.h index 72ee07a90..c3031b2f7 100644 --- a/src/qmmpui/fileloader.h +++ b/src/qmmpui/fileloader.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2009 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -26,41 +26,51 @@ class PlayListItem; -/*! +/*! @brief File loader class. + * * This class represents fileloader object that * processes file list in separate thread and emits * \b newPlayListItem(PlayListItem*) signal for every newly * created media file. - @author Ilya Kotov <forkotov02@hotmail.ru> -*/ + * @author Ilya Kotov <forkotov02@hotmail.ru> + */ class FileLoader : public QThread { Q_OBJECT public: + /*! + * Constructs FileLoader object. + * @param parent QObject parent + */ FileLoader(QObject *parent = 0); - + /*! + * Object destructor. + */ ~FileLoader(); - virtual void run(); - /*! * Call this method when you want to notify the thread about finishing */ void finish(); - /*! * Sets filelist to load( directory to load will be cleaned ) */ void setFilesToLoad(const QStringList&); - /*! * Sets directory to load( filelist to load will be cleaned ) */ void setDirectoryToLoad(const QString&); signals: - void newPlayListItem(PlayListItem*); + /*! + * Emited when new playlist item is available. + * @param item Pointer of the new PlayListItem object. + */ + void newPlayListItem(PlayListItem *item); + protected: + virtual void run(); void addFiles(const QStringList &files); void addDirectory(const QString& s); + private: QStringList m_filters; QStringList m_files_to_load; |
