{
public slots:
void saveToXml();
public:
ModelBookNodeDescModel
(std
::string full_path,
QObject *parent
= 0);
~ModelBookNodeDescModel();
void setRootNode(ut::types::tModelBookNodeDesc *node);
static void setParentOfAllNodes(ut::types::tModelBookNodeDesc *node);
QModelIndex createQModelIndex
(ut
::types::tModelBookNodeDesc &item
);
QVariant headerData
(int section, Qt
::Orientation orientation,
int role
) const;
bool insertRows
(int position,
int rows, std
::vector<ut
::types::tModelBookNodeDesc*>
&tab ,
const QModelIndex &parent
= QModelIndex());
bool setData
(const QModelIndex &index,
const ut
::types::_tModelDesc
&value,
int role = Qt::EditRole);
static bool parentHasChild(ut::types::tModelBookNodeDesc *&parent,
ut::types::tModelBookNodeDesc *&resultParent,
ut::types::tModelBookNodeDesc *&child,
int& recurse);
void addChild(ut::types::tModelBookNodeDesc* parent, ut::types::tModelBookNodeDesc child);
void deleteItem(ut::types::tModelBookNodeDesc *item);
void insertParent(ut::types::tModelBookNodeDesc *child, ut::types::tModelBookNodeDesc parent);
void setSelectedItem(ut::types::tModelBookNodeDesc *item);
protected:
ut
::types::tModelBookNodeDesc *nodeFromIndex
(const QModelIndex &index
) const;
ut::types::tModelBookNodeDesc *rootNode;
ut::types::tModelBookNodeDesc *parentRootNode;
ut::types::tModelBookNodeDesc *grandParentRootNode;
public:
ut::types::tModelBookNodeDesc *selectedItem;
};
class DragDropModel : public ModelBookNodeDescModel
{
Q_OBJECT
public:
bool dropMimeData
(const QMimeData *data, Qt
::DropAction action,
QMimeData *mimeData
(const QModelIndexList
&indexes
) const;
Qt::DropActions supportedDropActions() const;
void removeSelectedIndex();
public slots:
void markIndex(const QModelIndex& index);
protected:
mutable std::vector<ut::types::tModelBookNodeDesc *> nodesToDelete;
mutable ut::types::tModelBookNodeDesc *newParent;
};
class ModelBookNodeDescModel: public QAbstractItemModel
{
public slots:
void saveToXml();
public:
ModelBookNodeDescModel(std::string full_path, QObject *parent = 0);
~ModelBookNodeDescModel();
void setRootNode(ut::types::tModelBookNodeDesc *node);
QModelIndex exportRootIndex();
static void setParentOfAllNodes(ut::types::tModelBookNodeDesc *node);
QModelIndex createQModelIndex(ut::types::tModelBookNodeDesc &item);
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
bool insertRows(int position, int rows, std::vector<ut::types::tModelBookNodeDesc*> &tab ,const QModelIndex &parent = QModelIndex());
bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
bool setData(const QModelIndex &index, const ut::types::_tModelDesc &value,
int role = Qt::EditRole);
static bool parentHasChild(ut::types::tModelBookNodeDesc *&parent,
ut::types::tModelBookNodeDesc *&resultParent,
ut::types::tModelBookNodeDesc *&child,
int& recurse);
void addChild(ut::types::tModelBookNodeDesc* parent, ut::types::tModelBookNodeDesc child);
void deleteItem(ut::types::tModelBookNodeDesc *item);
void insertParent(ut::types::tModelBookNodeDesc *child, ut::types::tModelBookNodeDesc parent);
void setSelectedItem(ut::types::tModelBookNodeDesc *item);
protected:
ut::types::tModelBookNodeDesc *nodeFromIndex(const QModelIndex &index) const;
ut::types::tModelBookNodeDesc *rootNode;
ut::types::tModelBookNodeDesc *parentRootNode;
ut::types::tModelBookNodeDesc *grandParentRootNode;
public:
mutable QTreeView* m_view;
ut::types::tModelBookNodeDesc *selectedItem;
};
class DragDropModel : public ModelBookNodeDescModel
{
Q_OBJECT
public:
DragDropModel(const QString &full_path, QObject *parent = 0);
Qt::ItemFlags flags(const QModelIndex &index) const;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent);
QMimeData *mimeData(const QModelIndexList &indexes) const;
QStringList mimeTypes() const;
Qt::DropActions supportedDropActions() const;
void removeSelectedIndex();
public slots:
void markIndex(const QModelIndex& index);
protected:
QModelIndex *selectedIndex;
mutable std::vector<ut::types::tModelBookNodeDesc *> nodesToDelete;
mutable ut::types::tModelBookNodeDesc *newParent;
};
To copy to clipboard, switch view to plain text mode
class DragableDoubleTreeView
: public QTreeView{
Q_OBJECT
public:
DragableDoubleTreeView
(QWidget *parent
= 0);
void setDoubleTreeView(DoubleTreeView* view);
public slots:
protected:
DoubleTreeView *m_doubleTreeView;
private:
void startDrag();
};
this portion of code interact negatively with the preceding drag and drop model and it does permit to had an element
to the list but not an element into a parent element of the list.
class DragableDoubleTreeView : public QTreeView
{
Q_OBJECT
public:
DragableDoubleTreeView(QWidget *parent = 0);
void setDoubleTreeView(DoubleTreeView* view);
public slots:
void setSelected(const QModelIndex &index);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
DoubleTreeView *m_doubleTreeView;
private:
void startDrag();
QModelIndex *m_modelIndex;
QPoint startPos;
};
this portion of code interact negatively with the preceding drag and drop model and it does permit to had an element
to the list but not an element into a parent element of the list.
To copy to clipboard, switch view to plain text mode
Bookmarks