[Qt-interest] Custom Data by subclassing the QMimeData
Sajjad
dosto.walla at gmail.com
Mon Nov 8 22:17:14 CET 2010
Hello forum,
I have customized the QMimeData by sub classing it and the customized class
contains QHash<QString,QString> to contain those information. While reading
the database the node name, its field name and type are loaded into each of
the customized mime object. I have re-implemented the following functions
and they are as follows:
*************************************************
QStringList H3DNodeData::formats() const
{
return QMimeData::formats() << "NodeData/Node-Properties";
}
bool H3DNodeData::hasFormat(const QString &mimetype) const
{
return formats().contains(mimetype);
}
QVariant H3DNodeData::retrieveData(const QString &mimetype,
QVariant::Type preferredType) const
{
//not sure what this function should contain
}
************************************************
And the class has the following structure:
*************************************************
class NodeData : public QMimeData
{
Q_OBJECT
public:
NodeData();
~NodeData();
QStringList formats() const;
bool hasFormat(const QString &mimetype) const;
/////////////////////////////////////////////////////////////
inline QString getNodeStr() const
{
return m_nodeName;
}
inline QHash<QString,QString> getFieldAndTypeStr() const
{
return m_fieldAndTypeName;
}
inline bool getAbstract() const
{
return m_isAbstract;
}
inline void setNodeStr(const QString &_l_nodeStr)
{
m_nodeName = _l_nodeStr;
}
inline void setFieldAndTypeStr(const QHash<QString,QString>
&_l_fieldAndTypeStr)
{
m_fieldAndTypeName = _l_fieldAndTypeStr;
}
inline void setAbstract(bool abs)
{
m_isAbstract = abs;
}
/////////////////////////////////////////////////////////////
protected:
QVariant retrieveData(const QString &mimetype, QVariant::Type
preferredType) const;
private:
//the string contains the node name
QString m_nodeName;
//each node contains fields and its type
//and they are stored in the hash table
QHash<QString,QString> m_fieldAndTypeName;
//a boolean flag to mention
//if the node is an abstract one or not
bool m_isAbstract;
};
*************************************************
Any hint on the retrieveData(...) function ?
Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101108/bfe35600/attachment.html
More information about the Qt-interest-old
mailing list