mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
Fixup Compare Drag-N-Drop
We have two new mime data types; application/x-gc-intervals application/x-gc-seasons With packing routines into QMimeData declared in IntervalTreeView and SeasonTreeView. To get around an issue with overwrite mode on drag and drop from the seasons / interval trees we DO NOT ACCEPT the drop (even though we do actually process the data). All we need to do now is unpack the QMimeData in ComparePane and then add the GUI elements to it etc.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
IntervalTreeView::IntervalTreeView(Context *context) : context(context)
|
||||
{
|
||||
setDragDropMode(QAbstractItemView::InternalMove);
|
||||
setDragDropOverwriteMode(true);
|
||||
setDragDropOverwriteMode(false);
|
||||
setDropIndicatorShown(true);
|
||||
#ifdef Q_OS_MAC
|
||||
setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
@@ -35,7 +35,7 @@ IntervalTreeView::IntervalTreeView(Context *context) : context(context)
|
||||
void
|
||||
IntervalTreeView::dropEvent(QDropEvent* event)
|
||||
{
|
||||
qDebug()<<"interval tree drop event!!";
|
||||
qDebug()<<"interval tree drop event!!"<<event->mimeData()->urls();
|
||||
|
||||
IntervalItem* item1 = (IntervalItem *)itemAt(event->pos());
|
||||
QTreeWidget::dropEvent(event);
|
||||
@@ -44,3 +44,43 @@ qDebug()<<"interval tree drop event!!";
|
||||
if (item1==topLevelItem(0) || item1 != item2)
|
||||
QTreeWidget::itemChanged(item2, 0);
|
||||
}
|
||||
|
||||
QStringList
|
||||
IntervalTreeView::mimeTypes() const
|
||||
{
|
||||
QStringList returning;
|
||||
returning << "application/x-gc-intervals";
|
||||
|
||||
return returning;
|
||||
}
|
||||
|
||||
QMimeData *
|
||||
IntervalTreeView::mimeData (const QList<QTreeWidgetItem *> items) const
|
||||
{
|
||||
QMimeData *returning = new QMimeData;
|
||||
|
||||
// we need to pack into a byte array
|
||||
QByteArray rawData;
|
||||
QDataStream stream(&rawData, QIODevice::WriteOnly);
|
||||
stream.setVersion(QDataStream::Qt_4_6);
|
||||
|
||||
// pack data
|
||||
stream << items.count();
|
||||
foreach (QTreeWidgetItem *p, items) {
|
||||
|
||||
// convert to one of ours
|
||||
IntervalItem *i = static_cast<IntervalItem*>(p);
|
||||
|
||||
// serialize
|
||||
stream << p->text(0); // name
|
||||
stream << static_cast<const void*>(i->ride);
|
||||
stream << i->start << i->stop; // start and stop in secs
|
||||
stream << i->startKM << i->stopKM; // start and stop km
|
||||
stream << i->displaySequence;
|
||||
|
||||
}
|
||||
|
||||
// and return as mime data
|
||||
returning->setData("application/x-gc-intervals", rawData);
|
||||
return returning;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user