MagicSmoke  $VERSION$
flagedit.h
Go to the documentation of this file.
1 //
2 // C++ Interface: flagedit
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2011
8 //
9 // Copyright: See COPYING.GPL file that comes with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_FLAGEDIT_H
14 #define MAGICSMOKE_FLAGEDIT_H
15 
16 #include <QDialog>
17 #include <QStringList>
18 
19 #include "MOFlag"
20 
21 class QLabel;
22 class QStandardItemModel;
23 class QTableView;
24 class QLineEdit;
25 class QAbstractButton;
26 
28 class MFlagEditor:public QDialog
29 {
30  Q_OBJECT
31  public:
33  static QString edit(QWidget*parent,QString flags,QString label=QString());
34 
36  MFlagEditor(QWidget*parent,QString flags,QString label=QString());
37 
39  QString currentFlags()const;
41  QString originalFlags()const;
42 
43  private:
44  friend class MFlagEditorDelegate;
45  QList<MOFlag>allflags;
46  QStringList flags;
47  QStandardItemModel*model;
48  QTableView*table;
49  private slots:
51  void reset();
52 };
53 
55 class MFlagWidget:public QWidget
56 {
57  Q_OBJECT
58  public:
60  MFlagWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
62  MFlagWidget(QString flags,QWidget* parent = 0, Qt::WindowFlags f = 0);
64  MFlagWidget(QStringList flags,QWidget* parent = 0, Qt::WindowFlags f = 0);
65 
67  QString flags()const{return m_flags;}
69  QString text()const{return m_flags;}
70 
72  QString editorLabel()const{return m_label;}
73  public slots:
75  void setFlags(QString);
77  void setFlags(QStringList);
79  void setText(QString);
80 
82  void setEditorLabel(QString e);
83 
85  void setEditable(bool e=true);
87  void setReadonly(bool ro=true);
88 
89  private slots:
91  void doedit();
92  private:
93  QString m_flags,m_label;
94  QLabel*m_line;
95  QAbstractButton*m_btn;
96 
98  void init();
99 };
100 
101 #endif
void setEditable(bool e=true)
makes the widget editable (this is the default)
Definition: flagedit.cpp:194
QString editorLabel() const
returns the label that will be used for the flag editor
Definition: flagedit.h:72
void setReadonly(bool ro=true)
makes the widget readonly (per default it is editable)
Definition: flagedit.cpp:215
QString text() const
alias for flags() (for compatibility with other widgets)
Definition: flagedit.h:69
QString originalFlags() const
returns the original string with which the editor was initialized
Definition: flagedit.cpp:137
simple widget that displays flags and allows to edit them
Definition: flagedit.h:55
Definition: flagedit.cpp:40
MFlagEditor(QWidget *parent, QString flags, QString label=QString())
creates an editor window
Definition: flagedit.cpp:78
enables the user to edit flags attached to an entity as defined by MagicSmoke
Definition: flagedit.h:28
MFlagWidget(QWidget *parent=0, Qt::WindowFlags f=0)
creates a flag widget with no flags set, per default it is editable
Definition: flagedit.cpp:167
static QString edit(QWidget *parent, QString flags, QString label=QString())
convenience function: opens a flag editor and returns the result or the original string if unchanged ...
Definition: flagedit.cpp:69
void setEditorLabel(QString e)
sets the label for the flag editor when the user changes flags
Definition: flagedit.cpp:241
QString flags() const
returns the currently displayed flags as string
Definition: flagedit.h:67
void setFlags(QString)
sets the flags displayed in this widget
Definition: flagedit.cpp:220
QString currentFlags() const
returns the flag string corresponding to the current state of the editor
Definition: flagedit.cpp:118
void setText(QString)
sets the flags displayed in this widget (alias for compatibility with other widgets) ...
Definition: flagedit.cpp:236