MagicSmoke  $VERSION$
ticketedit.h
Go to the documentation of this file.
1 //
2 // C++ Interface: ticket template editor
3 //
4 // Description:
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2011
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_TICKETEDIT_H
14 #define MAGICSMOKE_TICKETEDIT_H
15 
16 #include <QMainWindow>
17 #include <QMap>
18 #include <QItemDelegate>
19 
20 #include <DPtrBase>
21 
22 class QFile;
23 class QIODevice;
25 class MTicketEditor:public QMainWindow
26 {
27  Q_OBJECT
28  DECLARE_DPTR(d);
29  friend class MTELabelDelegate;
30  public:
32  MTicketEditor(QWidget* parent = 0, Qt::WindowFlags f = 0);
33 
34  public slots:
36  void loadFile(QString);
38  void openFile();
40  void saveFile();
42  void saveFileAs();
44  void saveFile(QString);
45  private slots:
47  void rerender();
49  void parseTemplate(QByteArray);
51  void updateDisplay();
53  void addItem(int);
55  void delItem();
57  void upItem();
59  void downItem();
61  void addFile();
63  void delFile();
65  void loadExampleData();
67  void saveTemplate(QFile&);
69  void saveXmlPart(QIODevice&);
70 };
71 
73 class MTELabelDelegate:public QItemDelegate
74 {
75  Q_OBJECT
76  MTicketEditor*mParent;
77  public:
78  MTELabelDelegate(MTicketEditor *parent):QItemDelegate(parent)
79  {mParent=parent;}
80  QWidget *createEditor(QWidget *, const QStyleOptionViewItem &,
81  const QModelIndex &) const;
82  void setEditorData(QWidget *, const QModelIndex &) const;
83  void setModelData(QWidget *, QAbstractItemModel *,
84  const QModelIndex &) const ;
85  void updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem &option,
86  const QModelIndex &) const {editor->setGeometry(option.rect);}
87 };
88 
89 #endif
void openFile()
shows a file open dialog and then opens the selected file
Definition: ticketedit.cpp:425
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
Definition: ticketedit.h:85
QWidget * createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
Definition: ticketedit.cpp:536
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const
Definition: ticketedit.cpp:640
An editor for ticket templates.
Definition: ticketedit.h:25
void loadFile(QString)
loads a template file, this is a helper for openFile and download
Definition: ticketedit.cpp:290
Definition: ticketedit.h:73
void setEditorData(QWidget *, const QModelIndex &) const
Definition: ticketedit.cpp:573
MTicketEditor(QWidget *parent=0, Qt::WindowFlags f=0)
instantiates the editor
Definition: ticketedit.cpp:149
void saveFileAs()
asks for a new file name
Definition: ticketedit.cpp:452
MTELabelDelegate(MTicketEditor *parent)
Definition: ticketedit.h:78
void saveFile()
saves the file - if it is local, otherwise calls saveFileAs
Definition: ticketedit.cpp:435