Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FILEFIELD_H
Toshihiro Shimizu 890ddd
#define FILEFIELD_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
#include <qfiledialog></qfiledialog>
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/lineedit.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class QPushButton;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace DVGui {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*! \class DVGui::FileField
Shinya Kitaoka 120a6e
                \brief The FileField class provides an object to manage file
Shinya Kitaoka 120a6e
   browser.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                Inherits \b QWidget.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
                The object FileField is composed of two part, a field \b
Shinya Kitaoka 120a6e
   LineEdit and a
Shinya Kitaoka 120a6e
                button \b QPushButton. Click button to open a directory browser
Shinya Kitaoka 120a6e
   popup
Shinya Kitaoka 120a6e
                that is used to choose a directory.
Shinya Kitaoka 120a6e
                You can set in constructor default path.
Shinya Kitaoka 120a6e
                Maximum height object is fixed to \b DVGui::WidgetHeight.
Shinya Kitaoka 120a6e
                By default dialog permit user to select only folder, but using
Shinya Kitaoka 120a6e
   setFileMode()
Shinya Kitaoka 120a6e
                you can indicate what the user may select in the file dialog,
Shinya Kitaoka 120a6e
   folder or file;
Shinya Kitaoka 120a6e
                you can also set file type using setFilters().
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
class DVAPI FileField : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  LineEdit *m_field;
Shinya Kitaoka 120a6e
  QStringList m_filters;
Shinya Kitaoka 120a6e
  QFileDialog::FileMode m_fileMode;
Shinya Kitaoka 120a6e
  QString m_windowTitle;
shun_iwasawa 754d45
  QString m_descriptionText;  // if the initial text is not path, set the string
shun_iwasawa 754d45
                              // here and prevent browsing
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
protected:  // used in the child class for CleanupSettings
Shinya Kitaoka 120a6e
  QPushButton *m_fileBrowseButton;
Shinya Kitaoka 120a6e
  QString m_lastSelectedPath;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /* N.B. Vedi il commento della classe BrowserPopupController in
Shinya Kitaoka 120a6e
   * filebrowserpopup.cpp*/
Shinya Kitaoka 120a6e
  class BrowserPopupController {
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    BrowserPopupController() {}
Shinya Kitaoka 120a6e
    virtual ~BrowserPopupController() {}
Shinya Kitaoka 120a6e
    virtual bool isExecute() { return true; };
Shinya Kitaoka 120a6e
    virtual QString getPath() { return QString(); };
shun_iwasawa 135173
    virtual void openPopup(QStringList, bool, QString,
shun_iwasawa 135173
                           const QWidget * = NULL){};
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static BrowserPopupController *m_browserPopupController;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  FileField(QWidget *parent = 0, QString path = QString(),
shun_iwasawa 754d45
            bool readOnly = false, bool doNotBrowseInitialPath = false);
Shinya Kitaoka 120a6e
  ~FileField() {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*! Set what the user may select in the file dialog:
Shinya Kitaoka 120a6e
                  \li QFileDialog::DirectoryOnly show only directory.
Shinya Kitaoka 120a6e
                  \li QFileDialog::AnyFile, QFileDialog::ExistingFile,
Shinya Kitaoka 120a6e
     QFileDialog::Directory, QFileDialog::ExistingFiles
Shinya Kitaoka 120a6e
                                  show directory and file. */
Shinya Kitaoka 120a6e
  void setFileMode(const QFileDialog::FileMode &fileMode);
Shinya Kitaoka 120a6e
  /*! Set file type in dialog popup. */
Shinya Kitaoka 120a6e
  void setFilters(const QStringList &filters);
Shinya Kitaoka 120a6e
  void setValidator(const QValidator *v) { m_field->setValidator(v); }
Shinya Kitaoka 120a6e
  QString getPath();
Shinya Kitaoka 120a6e
  void setPath(const QString &path);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static void setBrowserPopupController(BrowserPopupController *controller);
Shinya Kitaoka 120a6e
  static BrowserPopupController *getBrowserPopupController();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Shinya Kitaoka 120a6e
  /*! Open a static file dialog popup to browse and choose directories. If a
Shinya Kitaoka 120a6e
                  directory is seleceted and choose, set field to this
Shinya Kitaoka 120a6e
     directory. */
Shinya Kitaoka 120a6e
  // reimplemented in the "save in" filefield in CleanupSettings
Shinya Kitaoka 120a6e
  virtual void browseDirectory();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Shinya Kitaoka 120a6e
  /*!	This signal is emitted when path in field change, or by field edit or by
Shinya Kitaoka 120a6e
                  browse popup. */
Shinya Kitaoka 120a6e
  void pathChanged();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
}  // namespace DVGui
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // FILEFIELD_H