Rev 138 |
Rev 180 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
#ifndef DELEGATE_H
#define DELEGATE_H
#include <QItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QSize>
#include <QSpinBox>
#include <QSqlQuery>
#include <QtSql>
#include <QtGui>
#include <QSqlDatabase>
#include <QMessageBox>
//#include <QMainWindow>
//! [0]
class SpinBoxDelegate : public QItemDelegate
{
Q_OBJECT
public:
SpinBoxDelegate(QObject *parent = 0);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setInctance(QString newInctance);
void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
private:
QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
};
//! [0]
class MyDEDelegate : public QItemDelegate {
Q_OBJECT
public:
MyDEDelegate(bool calpopup = true,
QObject *parent = 0);
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor,
const QModelIndex &index) const;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const;
void updateEditorGeometry(
QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
private:
bool m_calpopup;
};
class CPictureDelegate : public QItemDelegate
{
mutable QPixmap m_pxPicture;
public:
CPictureDelegate( QObject *parent );
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
//QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
class TimeEditDelegate : public QItemDelegate
{
Q_OBJECT
public:
TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;};
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
private:
QString timeformat;
};
#endif // DELEGATE_H