Files
qglengine/widgets/treewidget_p.h
2020-08-25 21:57:31 +03:00

52 lines
1.4 KiB
C++

/*
QGL SceneTree
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TREEWIDGET_H
#define TREEWIDGET_H
#include <QTreeWidget>
#include <QDropEvent>
#include <QDebug>
#include <QTimer>
class InternalMoveTreeWidget: public QTreeWidget
{
Q_OBJECT
public:
InternalMoveTreeWidget(QWidget * parent = 0): QTreeWidget(parent) {}
protected:
virtual void dropEvent(QDropEvent * e) {
QList<QTreeWidgetItem*> sil = selectedItems();
if (sil.isEmpty()) return;
QTreeWidget::dropEvent(e);
foreach (QTreeWidgetItem * ti, sil) {
QTreeWidgetItem * ti_p = ti->parent();
if (!ti_p) ti_p = invisibleRootItem();
int ti_ppos = ti_p->indexOfChild(ti);
emit itemMoved(ti, ti_p, ti_ppos);
}
}
signals:
void itemMoved(QTreeWidgetItem * item, QTreeWidgetItem * new_parent, int new_index);
};
#endif // TREEWIDGET_H