Back to index

texmacs  1.0.7.15
QTMFileDialog.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : QTMFileDialog.hpp
00004 * DESCRIPTION: QT file choosers
00005 * COPYRIGHT  : (C) 2009 David MICHEL
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef QTMFILEDIALOG_HPP
00013 #define QTMFILEDIALOG_HPP
00014 
00015 #include <QFileDialog>
00016 #include <QLabel>
00017 #include <QLineEdit>
00018 #include <QHBoxLayout>
00019 #include "string.hpp"
00020 
00021 class QMyFileDialog : public QFileDialog
00022 {
00023   Q_OBJECT
00024 public:
00025   QMyFileDialog (QWidget* parent= 0, const QString & caption = QString(),
00026                  const QString & directory = QString(), const QString & filter = QString()) 
00027   : QFileDialog(parent, caption, directory, filter) {}
00028 };
00029 
00030 class QTMFileDialog : public QDialog
00031 {
00032   Q_OBJECT
00033 
00034 protected:
00035   QHBoxLayout* hbox;
00036   QFileDialog *file;
00037   void dragEnterEvent(QDragEnterEvent *event);
00038   void dragMoveEvent(QDragMoveEvent *event);
00039   void dragLeaveEvent(QDragLeaveEvent *event);
00040   void dropEvent(QDropEvent *event);      
00041 
00042 public:
00043   QTMFileDialog (QWidget* parent= 0, const QString & caption = QString(),
00044       const QString & directory = QString(), const QString & filter = QString());
00045   QStringList selectedFiles () { return file->selectedFiles (); };
00046 #if (defined(Q_WS_MAC) && (QT_VERSION >= 0x040500))
00047   void setOptions (QFileDialog::Options opts) { return file->setOptions (opts); };
00048 #endif
00049   void setViewMode (QFileDialog::ViewMode mode) { return file->setViewMode (mode); };
00050   void setFileMode (QFileDialog::FileMode mode) { return file->setFileMode (mode); };
00051 #if (QT_VERSION >= 0x040400)
00052   void setNameFilter (const QString & filter) { return file->setNameFilter (filter);}
00053 #endif
00054   void setDefaultSuffix (const QString & suffix) { return file->setDefaultSuffix (suffix);}
00055   void setLabelText (QFileDialog::DialogLabel label, const QString& text) { return file->setLabelText (label, text); };
00056 };
00057 
00058 class QTMImagePreview : public QWidget
00059 {
00060   Q_OBJECT
00061 
00062   QLabel *image;
00063 
00064 public:
00065   QLineEdit* wid;
00066   QLineEdit* hei;
00067   QLineEdit* xps;
00068   QLineEdit* yps;
00069 
00070 public slots:
00071   void setImage (const QString&);
00072 
00073 public:
00074   QTMImagePreview (QWidget* parent= 0);
00075 };
00076 
00077 class QTMImageDialog : public QTMFileDialog
00078 {
00079   Q_OBJECT
00080 
00081   QTMImagePreview* preview;
00082 
00083 public:
00084   QTMImageDialog (QWidget* parent= 0, const QString& caption= QString (),
00085       const QString& directory= QString (), const QString& filter= QString ());
00086   string getParamsAsString ();
00087 };
00088 
00089 #endif // defined QTMFILEDIALOG_HPP
00090