Toshihiro Shimizu 890ddd
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
Toshihiro Shimizu 890ddd
namespace DVGui
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
/*! \class DVGui::FileField
Toshihiro Shimizu 890ddd
		\brief The FileField class provides an object to manage file browser.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		Inherits \b QWidget.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		The object FileField is composed of two part, a field \b LineEdit and a
Toshihiro Shimizu 890ddd
		button \b QPushButton. Click button to open a directory browser popup
Toshihiro Shimizu 890ddd
		that is used to choose a directory.
Toshihiro Shimizu 890ddd
		You can set in constructor default path.
Toshihiro Shimizu 890ddd
		Maximum height object is fixed to \b DVGui::WidgetHeight.
Toshihiro Shimizu 890ddd
		By default dialog permit user to select only folder, but using setFileMode()
Toshihiro Shimizu 890ddd
		you can indicate what the user may select in the file dialog, folder or file;
Toshihiro Shimizu 890ddd
		you can also set file type using setFilters().
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
class DVAPI FileField : public QWidget
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	LineEdit *m_field;
Toshihiro Shimizu 890ddd
	QStringList m_filters;
Toshihiro Shimizu 890ddd
	QFileDialog::FileMode m_fileMode;
Toshihiro Shimizu 890ddd
	QString m_windowTitle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected: //used in the child class for CleanupSettings
Toshihiro Shimizu 890ddd
	QPushButton *m_fileBrowseButton;
Toshihiro Shimizu 890ddd
	QString m_lastSelectedPath;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	/* N.B. Vedi il commento della classe BrowserPopupController in filebrowserpopup.cpp*/
Toshihiro Shimizu 890ddd
	class BrowserPopupController
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
	public:
Toshihiro Shimizu 890ddd
		BrowserPopupController() {}
Toshihiro Shimizu 890ddd
		virtual ~BrowserPopupController() {}
Toshihiro Shimizu 890ddd
		virtual bool isExecute() { return true; };
Toshihiro Shimizu 890ddd
		virtual QString getPath() { return QString(); };
Toshihiro Shimizu 890ddd
		virtual void openPopup(QStringList, bool, QString){};
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static BrowserPopupController *m_browserPopupController;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FileField(QWidget *parent = 0, QString path = QString(), bool readOnly = false);
Toshihiro Shimizu 890ddd
	~FileField() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*! Set what the user may select in the file dialog:
Toshihiro Shimizu 890ddd
			\li QFileDialog::DirectoryOnly show only directory.
Toshihiro Shimizu 890ddd
			\li QFileDialog::AnyFile, QFileDialog::ExistingFile, QFileDialog::Directory, QFileDialog::ExistingFiles
Toshihiro Shimizu 890ddd
					show directory and file. */
Toshihiro Shimizu 890ddd
	void setFileMode(const QFileDialog::FileMode &fileMode);
Toshihiro Shimizu 890ddd
	/*! Set file type in dialog popup. */
Toshihiro Shimizu 890ddd
	void setFilters(const QStringList &filters);
Toshihiro Shimizu 890ddd
	void setValidator(const QValidator *v) { m_field->setValidator(v); }
Toshihiro Shimizu 890ddd
	QString getPath();
Toshihiro Shimizu 890ddd
	void setPath(const QString &path);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static void setBrowserPopupController(BrowserPopupController *controller);
Toshihiro Shimizu 890ddd
	static BrowserPopupController *getBrowserPopupController();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Toshihiro Shimizu 890ddd
	/*! Open a static file dialog popup to browse and choose directories. If a
Toshihiro Shimizu 890ddd
			directory is seleceted and choose, set field to this directory. */
Toshihiro Shimizu 890ddd
	//reimplemented in the "save in" filefield in CleanupSettings
Toshihiro Shimizu 890ddd
	virtual void browseDirectory();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
	/*!	This signal is emitted when path in field change, or by field edit or by
Toshihiro Shimizu 890ddd
			browse popup. */
Toshihiro Shimizu 890ddd
	void pathChanged();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
} //namespace DVGui
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // FILEFIELD_H