SKGQueryDelegate
::SKGQueryDelegate(QObject* parent, SKGDocument
* iDoc,
bool iModeUpdate
):{
}
SKGQueryDelegate::~SKGQueryDelegate()
{
document=NULL;
}
{
SKGTRACEIN(1, "SKGQueryDelegate::createEditor");
QString attname
=it_h
->data
(Qt
::UserRole).
toString();
SKGPredicatCreator* editor=new SKGPredicatCreator(parent, document, attname, updateMode);
return editor;
}
void SKGQueryDelegate
::setEditorData ( QWidget * editor,
const QModelIndex & index
) const {
SKGTRACEIN(1, "SKGQueryDelegate::setEditorData");
SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
if (pred) {
pred->setXmlDescription(index.model()->data(index, Qt::UserRole).toString());
}
{
SKGTRACEIN(1, "SKGQueryDelegate::setModelData");
SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
if (pred && model) {
QString xml
=pred
->xmlDescription
();
model->setData(index, pred->text(), Qt::DisplayRole);
model->setData(index, xml, Qt::UserRole);
}
SKGQueryDelegate::SKGQueryDelegate(QObject* parent, SKGDocument* iDoc, bool iModeUpdate):
QItemDelegate(parent), document(iDoc), updateMode(iModeUpdate)
{
}
SKGQueryDelegate::~SKGQueryDelegate()
{
document=NULL;
}
QWidget* SKGQueryDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem & option ,
const QModelIndex & index ) const
{
SKGTRACEIN(1, "SKGQueryDelegate::createEditor");
QTableWidgetItem* it_h=((QTableWidget*) this->parent())->horizontalHeaderItem(index.column());
QString attname=it_h->data(Qt::UserRole).toString();
SKGPredicatCreator* editor=new SKGPredicatCreator(parent, document, attname, updateMode);
return editor;
}
void SKGQueryDelegate::setEditorData ( QWidget * editor, const QModelIndex & index ) const
{
SKGTRACEIN(1, "SKGQueryDelegate::setEditorData");
SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
if (pred) {
pred->setXmlDescription(index.model()->data(index, Qt::UserRole).toString());
} else QItemDelegate::setEditorData (editor, index);
}
void SKGQueryDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
SKGTRACEIN(1, "SKGQueryDelegate::setModelData");
SKGPredicatCreator *pred = dynamic_cast<SKGPredicatCreator*>(editor);
if (pred && model) {
QString xml=pred->xmlDescription();
model->setData(index, pred->text(), Qt::DisplayRole);
model->setData(index, xml, Qt::UserRole);
} else QItemDelegate::setModelData (editor, model, index);
}
To copy to clipboard, switch view to plain text mode
class SKGBANKGUI_EXPORT SKGPredicatCreator
: public QWidget{
Q_OBJECT
Q_PROPERTY( QString test READ text USER
true) Q_PROPERTY( QString xmlDescription READ xmlDescription WRITE setXmlDescription
)
public:
/**
* Default Constructor
* @param parent the parent
* @param document the document
* @param attribute name of the attribute
*/
explicit SKGPredicatCreator
(QWidget *parent
= 0, SKGDocument
* document
=NULL,
const QString
& attribute
="",
bool iSQL
=false);
/**
* Default Destructor
*/
virtual ~SKGPredicatCreator();
/**
* Get text
* @return text
*/
/**
* Get Text from XML description
* @param iXML the description
*/
static QString getTextFromXml
(const QString
& iXML
);
/**
* Get XML description
* @return description
*/
/**
* Set XML description
* @param iText the description
*/
virtual void setXmlDescription(const QString& iXML);
signals:
public slots:
private slots:
void onOperatorChanged();
private:
Q_DISABLE_COPY(SKGPredicatCreator);
bool updateMode;
SKGComboBox* kOperator;
};
class SKGBANKGUI_EXPORT SKGPredicatCreator : public QWidget
{
Q_OBJECT
Q_PROPERTY( QString test READ text USER true)
Q_PROPERTY( QString xmlDescription READ xmlDescription WRITE setXmlDescription)
public:
/**
* Default Constructor
* @param parent the parent
* @param document the document
* @param attribute name of the attribute
*/
explicit SKGPredicatCreator(QWidget *parent = 0, SKGDocument* document=NULL, const QString& attribute="", bool iSQL=false);
/**
* Default Destructor
*/
virtual ~SKGPredicatCreator();
/**
* Get text
* @return text
*/
virtual QString text();
/**
* Get Text from XML description
* @param iXML the description
*/
static QString getTextFromXml(const QString& iXML);
/**
* Get XML description
* @return description
*/
virtual QString xmlDescription();
/**
* Set XML description
* @param iText the description
*/
virtual void setXmlDescription(const QString& iXML);
signals:
public slots:
private slots:
void onOperatorChanged();
private:
Q_DISABLE_COPY(SKGPredicatCreator);
bool updateMode;
SKGComboBox* kOperator;
QWidget* kValue1;
QWidget* kValue2;
};
To copy to clipboard, switch view to plain text mode
Bookmarks