2
* Copyright (c) 2012 Damien Grauser (Damien.Grauser@pev-geneve.ch)
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the Free
6
* Software Foundation; either version 2 of the License, or (at your option)
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc., 51
16
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
#include "IntervalTreeView.h"
20
#include "IntervalItem.h"
21
#include "MainWindow.h"
24
IntervalTreeView::IntervalTreeView(MainWindow *mainWindow) : mainWindow(mainWindow)
26
setDragDropMode(QAbstractItemView::InternalMove);
27
setDragDropOverwriteMode(true);
28
setDropIndicatorShown(true);
30
setAttribute(Qt::WA_MacShowFocusRect, 0);
32
invisibleRootItem()->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
36
IntervalTreeView::dropEvent(QDropEvent* event)
38
IntervalItem* item1 = (IntervalItem *)itemAt(event->pos());
39
QTreeWidget::dropEvent(event);
40
IntervalItem* item2 = (IntervalItem *)itemAt(event->pos());
42
if (item1==topLevelItem(0) || item1 != item2)
43
QTreeWidget::itemChanged(item2, 0);