00001 #ifndef TEMPLATESMODEL_H 00002 #define TEMPLATESMODEL_H 00003 00004 #include "database.h" 00005 00011 class TemplatesModel : public SqlQueryModel 00012 { 00013 public: 00014 enum TemplateComponents { 00015 TemplateName = Qt::UserRole + 700, 00016 TemplateDefinition, 00017 TemplateArgCount, 00018 TemplateArgNames 00019 }; 00020 00021 TemplatesModel(QObject *parent = 0); 00022 QVariant data(const QModelIndex &item, int role) const; 00023 00024 private: 00025 QString convToNr(const TemplatesModel::TemplateComponents &component) const; 00026 }; 00027 00028 #include <QDialog> 00029 00030 class QLabel; 00031 class QLineEdit; 00032 class QDialogButtonBox; 00033 00037 class TemplateSaveDialog : public QDialog 00038 { 00039 Q_OBJECT 00040 public: 00041 TemplateSaveDialog(TemplatesModel *spModel, const QString &defaultName, QWidget *parent = 0); 00042 QString templateName() const; 00043 bool templateExists(); 00044 00045 private: 00046 QString adjustName(const QString &input); 00047 void showInfo(const QString &name); 00048 void paintPalette(const QString &name); 00049 void toggleSaveButton(const QString &name); 00050 00051 private slots: 00052 void slot_inputTextChanged(const QString &input); 00053 00054 private: 00055 QLabel *info; 00056 QLineEdit *inputEditor; 00057 QLabel *inputDesc; 00058 QString redText; 00059 QString greenText; 00060 QDialogButtonBox *buttonBox; 00061 TemplatesModel *spModel; 00062 QString saveName; 00063 }; 00064 00065 #include <QListView> 00066 00070 class TemplatesView : public QListView 00071 { 00072 Q_OBJECT 00073 public: 00074 TemplatesView(QWidget *parent = 0); 00075 void setModel(TemplatesModel *model); 00076 TemplatesModel *model(); 00077 00078 private slots: 00079 void deleteSelected(); 00080 void slot_itemActivated(QModelIndex index); 00081 }; 00082 00083 #endif // TEMPLATESMODEL_H