inputstring.h 2.36 KB
Newer Older
1 2
/******************************************************************************
 *
3
 * 
4
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
5
 * Copyright (C) 1997-2014 by Dimitri van Heesch.
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

18 19
#include "input.h"

20 21 22 23
#include <QObject>
#include <QMap>
#include <QStringList>

24 25
class QLabel;
class QLineEdit;
26
class QToolBar;
27
class QComboBox;
28
class QGridLayout;
29

30
class InputString : public QObject, public Input
31 32 33 34 35 36 37
{
  Q_OBJECT

  public:
    enum StringMode { StringFree=0, 
                      StringFile=1, 
                      StringDir=2, 
38 39
                      StringFixed=3,
                      StringImage=4
40 41
                    };

42 43 44
    InputString( QGridLayout *layout,int &row,
                 const QString &id, const QString &s, 
                 StringMode m,
45 46
                 const QString &docs,
                 const QString &absPath = QString() );
47
    ~InputString();
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; }
57
    QString templateDocs() const { return m_tdocs; }
58
    void addDependency(Input *) { Q_ASSERT(false); }
59
    void setEnabled(bool);
60 61
    void updateDependencies() {}
    void writeValue(QTextStream &t,QTextCodec *codec);
62
    void setTemplateDocs(const QString &docs) { m_tdocs = docs; }
63

64 65 66
  public slots:
    void reset();
    void setValue(const QString&);
67 68 69

  signals:
    void changed();
70
    void showHelp(Input *);
71 72 73 74

  private slots:
    void browse();
    void clear();
75
    void help();
76

77
  private:
78
    void updateDefault();
79 80
    QLabel       *m_lab;
    QLineEdit    *m_le;
81
    QLabel       *m_im;
82 83 84 85 86 87 88 89 90 91
    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;
92
    bool          m_absPath;
93
    QString       m_tdocs;
94 95 96
};

#endif