2001-06-14 08:20:41 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \file FileDialog.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-07 14:25:31 +00:00
|
|
|
*
|
|
|
|
* \author unknown
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILEDIALOG_H
|
|
|
|
#define FILEDIALOG_H
|
|
|
|
|
2008-03-15 01:20:36 +00:00
|
|
|
#include "FuncCode.h"
|
2006-10-09 16:33:20 +00:00
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
#include <QString>
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
#include <utility>
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \class FileDialog
|
|
|
|
* \brief GUI-I definition of file dialog interface
|
|
|
|
*/
|
|
|
|
class FileDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// label, directory path button
|
2008-03-05 23:10:53 +00:00
|
|
|
typedef std::pair<QString, QString> Button;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// result type
|
|
|
|
enum ResultType {
|
|
|
|
Later, /**< modeless chooser, no result */
|
|
|
|
Chosen /**< string contains filename */
|
|
|
|
};
|
|
|
|
|
|
|
|
/// result return
|
2008-03-05 23:10:53 +00:00
|
|
|
typedef std::pair<FileDialog::ResultType, QString> Result;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/**
|
2003-02-21 12:22:25 +00:00
|
|
|
* Constructs a file dialog with title \param title.
|
|
|
|
* If \param a is \const LFUN_SELECT_FILE_SYNC then a value
|
|
|
|
* will be returned immediately upon performing a open(),
|
2001-03-07 14:25:31 +00:00
|
|
|
* otherwise a callback Dispatch() will be invoked with the filename as
|
|
|
|
* argument, of action \param a.
|
|
|
|
*
|
2002-01-10 10:05:45 +00:00
|
|
|
* Up to two optional extra buttons are allowed for specifying
|
|
|
|
* additional directories in the navigation (an empty
|
2007-12-16 10:18:00 +00:00
|
|
|
* directory is interpreted as FileName::getcwd())
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
2008-03-15 01:20:36 +00:00
|
|
|
FileDialog(QString const & title, FuncCode a = LFUN_SELECT_FILE_SYNC);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
~FileDialog();
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
void setButton1(QString const & label, QString const & dir);
|
|
|
|
void setButton2(QString const & label, QString const & dir);
|
2007-10-28 16:32:20 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a file for opening, starting in directory \c path.
|
2008-04-20 19:56:01 +00:00
|
|
|
Result open(QString const & path, QStringList const & filters,
|
2008-03-05 23:10:53 +00:00
|
|
|
QString const & suggested = QString());
|
2003-02-25 13:17:01 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a directory, starting in directory \c path.
|
2008-03-05 23:10:53 +00:00
|
|
|
Result opendir(QString const & path = QString(),
|
|
|
|
QString const & suggested = QString());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2004-01-08 10:59:51 +00:00
|
|
|
/// Choose a file for saving, starting in directory \c path.
|
2008-04-20 19:56:01 +00:00
|
|
|
Result save(QString const & path, QStringList const & filters,
|
2008-03-05 23:10:53 +00:00
|
|
|
QString const & suggested = QString());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
2006-07-09 17:27:17 +00:00
|
|
|
private:
|
2001-03-07 14:25:31 +00:00
|
|
|
class Private;
|
|
|
|
friend class Private;
|
|
|
|
Private * private_;
|
|
|
|
|
|
|
|
/// the dialog title
|
2008-03-05 23:10:53 +00:00
|
|
|
QString title_;
|
2001-03-07 14:25:31 +00:00
|
|
|
|
|
|
|
/// success action to perform if not synchronous
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncCode success_;
|
2001-03-07 14:25:31 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
#endif // FILEDIALOG_H
|