| 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 INPUTSTRLIST_H |
| 14 |
#define INPUTSTRLIST_H |
| 15 |
|
| 16 |
#include "input.h" |
| 17 |
|
| 18 |
#include <QObject> |
| 19 |
#include <QStringList> |
| 20 |
|
| 21 |
class QLabel; |
| 22 |
class QLineEdit; |
| 23 |
class QPushButton; |
| 24 |
class QListWidget; |
| 25 |
class QGridLayout; |
| 26 |
class QAction; |
| 27 |
|
| 28 |
class InputStrList : public QObject, public Input |
| 29 |
{ |
| 30 |
Q_OBJECT |
| 31 |
|
| 32 |
public: |
| 33 |
enum ListMode { ListString = 0, |
| 34 |
ListFile = 1, |
| 35 |
ListDir = 2, |
| 36 |
ListFileDir = ListFile | ListDir |
| 37 |
}; |
| 38 |
|
| 39 |
InputStrList( QGridLayout *layout,int &row, |
| 40 |
const QString &id, const QStringList &sl, |
| 41 |
ListMode v, const QString &docs); |
| 42 |
void setValue(const QStringList &sl); |
| 43 |
|
| 44 |
QVariant &value(); |
| 45 |
void update(); |
| 46 |
Kind kind() const { return StrList; } |
| 47 |
QString docs() const { return m_docs; } |
| 48 |
QString id() const { return m_id; } |
| 49 |
QString templateDocs() const { return m_tdocs; } |
| 50 |
void addDependency(Input *) { Q_ASSERT(false); } |
| 51 |
void setEnabled(bool); |
| 52 |
void updateDependencies() {} |
| 53 |
bool isDefault(); |
| 54 |
void writeValue(QTextStream &t,TextCodecAdapter *codec,bool convert); |
| 55 |
void setTemplateDocs(const QString &docs) { m_tdocs = docs; } |
| 56 |
bool isEmpty(); |
| 57 |
|
| 58 |
public slots: |
| 59 |
void reset(); |
| 60 |
|
| 61 |
signals: |
| 62 |
void changed(); |
| 63 |
void showHelp(Input *); |
| 64 |
|
| 65 |
private slots: |
| 66 |
void addString(); |
| 67 |
void delString(); |
| 68 |
void updateString(); |
| 69 |
void selectText(const QString &s); |
| 70 |
void browseFiles(); |
| 71 |
void browseDir(); |
| 72 |
void help(); |
| 73 |
|
| 74 |
private: |
| 75 |
void updateDefault(); |
| 76 |
QLabel *m_lab; |
| 77 |
QLineEdit *m_le; |
| 78 |
QAction *m_add; |
| 79 |
QAction *m_del; |
| 80 |
QAction *m_upd; |
| 81 |
QAction *m_brFile; |
| 82 |
QAction *m_brDir; |
| 83 |
QListWidget *m_lb; |
| 84 |
QStringList m_default; |
| 85 |
QStringList m_strList; |
| 86 |
QVariant m_value; |
| 87 |
QString m_docs; |
| 88 |
QString m_id; |
| 89 |
QString m_tdocs; |
| 90 |
}; |
| 91 |
|
| 92 |
#endif |