/*************************************************************************** * Copyright (C) 2004 by Johan Maes ON4QZ * * on4qz@telenet.be * * * * http://users.telenet.be/on4qz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef UTILS_H #define UTILS_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** \file */ #define OK TRUE #define NOK FALSE /** get int value from a QLinedit */ bool getValue(int &val, QLineEdit *input); /** get double value from a QLinedit */ bool getValue(double &val, QLineEdit *input); /** get int value from a QString */ bool getValue(int &val, QString input); bool getValue(double &val, QString input); void getValue(bool &val, QCheckBox *input); void getValue(int &val, QSpinBox *input); void getValue(QString &s, QLineEdit *input); void getValue(int &s, QComboBox *input); void getValue(QString &s, QComboBox *input); void getValue(int &s, QButtonGroup *input); void setValue(int val, QLineEdit* output); void setValue(double val, QLineEdit* output); void setValue(bool val, QCheckBox *input); void setValue(int val, QSpinBox *input); void setValue(QString s, QLineEdit *input); void setValue(int s, QComboBox *input); void setValue(QString s, QComboBox *input); void setValue(int s, QButtonGroup *input); bool browseGetFile(QLineEdit *le,QString deflt,const QString &filter="*"); bool browseSaveFile(QLineEdit *le,QString deflt,const QString &filter="*"); bool browseDir(QLineEdit *le,QString deflt,const QString &filter="*"); class PixmapView : public QScrollView { Q_OBJECT public: PixmapView( QWidget *parent ); void setPixmap( const QPixmap &pix ); void drawContents( QPainter *p, int, int, int, int ); private: QPixmap pixmap; }; class preview : public QWidget { public: preview( QWidget *parent ); void previewUrl( const QUrl &u,int &w,int &h ); void resizeEvent(QResizeEvent *); private: PixmapView *pixmap; }; class PreviewWidget : public QVBox, public QFilePreview { Q_OBJECT public: PreviewWidget( QWidget *parent ); void previewUrl( const QUrl &u ); private: preview *Preview; QLabel *infoLabel; }; class dirDialog : public QFileDialog { public: dirDialog(QWidget *parent=0, const char * name=0, bool modal= FALSE); ~dirDialog(); QString openFileName(const QString & startWith, const QString &filter="*",bool single=TRUE); QString openDirName(const QString & startWith, const QString &filter="*"); QString saveFileName(const QString & startWith, const QString &filter,QString extension); }; class logFile { public: logFile(); ~logFile(); void add(const char *fmt, ...); private: QFile lf; QTextStream *ts; }; extern logFile logfile; #endif