inputstring.h 2.13 KB
Newer Older
dimitri's avatar
dimitri committed
1 2
/******************************************************************************
 *
dimitri's avatar
dimitri committed
3
 * 
dimitri's avatar
dimitri committed
4
 *
dimitri's avatar
dimitri committed
5
 * Copyright (C) 1997-2007 by Dimitri van Heesch.
dimitri's avatar
dimitri committed
6 7 8 9 10 11 12 13 14 15 16 17
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 */

#ifndef _INPUTSTRING_H
#define _INPUTSTRING_H

dimitri's avatar
dimitri committed
18 19
#include "input.h"

dimitri's avatar
dimitri committed
20 21 22 23
#include <QObject>
#include <QMap>
#include <QStringList>

dimitri's avatar
dimitri committed
24 25
class QLabel;
class QLineEdit;
dimitri's avatar
dimitri committed
26
class QToolBar;
dimitri's avatar
dimitri committed
27
class QComboBox;
dimitri's avatar
dimitri committed
28
class QGridLayout;
dimitri's avatar
dimitri committed
29

dimitri's avatar
dimitri committed
30
class InputString : public QObject, public Input
dimitri's avatar
dimitri committed
31 32 33 34 35 36 37 38 39 40
{
  Q_OBJECT

  public:
    enum StringMode { StringFree=0, 
                      StringFile=1, 
                      StringDir=2, 
                      StringFixed=3
                    };

dimitri's avatar
dimitri committed
41 42 43
    InputString( QGridLayout *layout,int &row,
                 const QString &id, const QString &s, 
                 StringMode m,
dimitri's avatar
dimitri committed
44 45
                 const QString &docs,
                 const QString &absPath = QString() );
dimitri's avatar
dimitri committed
46
    ~InputString();
dimitri's avatar
dimitri committed
47 48 49 50 51 52 53 54 55 56
    void addValue(QString s);
    void setDefault();

    // Input
    QVariant &value();
    void update();
    Kind kind() const { return String; }
    QString docs() const { return m_docs; }
    QString id() const { return m_id; }
    void addDependency(Input *) { Q_ASSERT(false); }
dimitri's avatar
dimitri committed
57
    void setEnabled(bool);
dimitri's avatar
dimitri committed
58 59
    void updateDependencies() {}
    void writeValue(QTextStream &t,QTextCodec *codec);
dimitri's avatar
dimitri committed
60

dimitri's avatar
dimitri committed
61 62 63
  public slots:
    void reset();
    void setValue(const QString&);
dimitri's avatar
dimitri committed
64 65 66

  signals:
    void changed();
dimitri's avatar
dimitri committed
67
    void showHelp(Input *);
dimitri's avatar
dimitri committed
68 69 70 71

  private slots:
    void browse();
    void clear();
dimitri's avatar
dimitri committed
72
    void help();
dimitri's avatar
dimitri committed
73

dimitri's avatar
dimitri committed
74 75 76 77 78 79 80 81 82 83 84 85 86
  private:
    QLabel       *m_lab;
    QLineEdit    *m_le;
    QToolBar     *m_br;
    QComboBox    *m_com;
    QString       m_str;
    QString       m_default;
    StringMode    m_sm;
    QStringList   m_values;
    int           m_index; 
    QVariant      m_value;
    QString       m_docs;
    QString       m_id;
dimitri's avatar
dimitri committed
87
    bool          m_absPath;
dimitri's avatar
dimitri committed
88 89 90
};

#endif