| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Copyright (C) 1997-2019 by Dimitri van Heesch. |
| 4 |
* |
| 5 |
* Permission to use, copy, modify, and distribute this software and its |
| 6 |
* documentation under the terms of the GNU General Public License is hereby |
| 7 |
* granted. No representations are made about the suitability of this software |
| 8 |
* for any purpose. It is provided "as is" without express or implied warranty. |
| 9 |
* See the GNU General Public License for more details. |
| 10 |
* |
| 11 |
*/ |
| 12 |
|
| 13 |
#ifndef INPUTSTRING_H |
| 14 |
#define INPUTSTRING_H |
| 15 |
|
| 16 |
#include "input.h" |
| 17 |
|
| 18 |
#include <QObject> |
| 19 |
#include <QMap> |
| 20 |
#include <QStringList> |
| 21 |
|
| 22 |
class QLabel; |
| 23 |
class QLineEdit; |
| 24 |
class QToolBar; |
| 25 |
class QComboBox; |
| 26 |
class QGridLayout; |
| 27 |
class QAction; |
| 28 |
|
| 29 |
class InputString : public QObject, public Input |
| 30 |
{ |
| 31 |
Q_OBJECT |
| 32 |
|
| 33 |
public: |
| 34 |
enum StringMode { StringFree=0, |
| 35 |
StringFile=1, |
| 36 |
StringDir=2, |
| 37 |
StringFixed=3, |
| 38 |
StringImage=4, |
| 39 |
StringFileDir=5 |
| 40 |
}; |
| 41 |
|
| 42 |
InputString( QGridLayout *layout,int &row, |
| 43 |
const QString &id, const QString &s, |
| 44 |
StringMode m, |
| 45 |
const QString &docs, |
| 46 |
const QString &absPath = QString() ); |
| 47 |
~InputString(); |
| 48 |
void addValue(QString s); |
| 49 |
void setDefault(); |
| 50 |
|
| 51 |
// Input |
| 52 |
QVariant &value(); |
| 53 |
void update(); |
| 54 |
Kind kind() const { return String; } |
| 55 |
StringMode stringMode() const { return m_sm; } |
| 56 |
QString docs() const { return m_docs; } |
| 57 |
QString id() const { return m_id; } |
| 58 |
QString templateDocs() const { return m_tdocs; } |
| 59 |
void addDependency(Input *) { Q_ASSERT(false); } |
| 60 |
void setEnabled(bool); |
| 61 |
void updateDependencies() {} |
| 62 |
bool isDefault(); |
| 63 |
void writeValue(QTextStream &t,TextCodecAdapter *codec,bool convert); |
| 64 |
void setTemplateDocs(const QString &docs) { m_tdocs = docs; } |
| 65 |
bool isEmpty() { return m_str.isEmpty(); } |
| 66 |
QString checkEnumVal(const QString &value); |
| 67 |
|
| 68 |
public slots: |
| 69 |
void reset(); |
| 70 |
void setValue(const QString&); |
| 71 |
|
| 72 |
signals: |
| 73 |
void changed(); |
| 74 |
void showHelp(Input *); |
| 75 |
|
| 76 |
private slots: |
| 77 |
void browseFile(); |
| 78 |
void browseDir(); |
| 79 |
void clear(); |
| 80 |
void help(); |
| 81 |
|
| 82 |
private: |
| 83 |
void updateDefault(); |
| 84 |
QLabel *m_lab; |
| 85 |
QLineEdit *m_le; |
| 86 |
QLabel *m_im; |
| 87 |
QToolBar *m_br; |
| 88 |
QAction *m_brFile; |
| 89 |
QAction *m_brDir; |
| 90 |
QComboBox *m_com; |
| 91 |
QString m_str; |
| 92 |
QString m_default; |
| 93 |
StringMode m_sm; |
| 94 |
QStringList m_values; |
| 95 |
int m_index; |
| 96 |
QVariant m_value; |
| 97 |
QString m_docs; |
| 98 |
QString m_id; |
| 99 |
bool m_absPath; |
| 100 |
QString m_tdocs; |
| 101 |
}; |
| 102 |
|
| 103 |
#endif |