bRestore::~bRestore()
{
}
+
+void bRestoreTable::mousePressEvent(QMouseEvent *event)
+{
+ QTableWidget::mousePressEvent(event);
+
+ if (event->button() == Qt::LeftButton) {
+ dragStartPosition = event->pos();
+ }
+}
+
+void bRestoreTable::mouseMoveEvent(QMouseEvent *event)
+{
+ if (!(event->buttons() & Qt::LeftButton)) {
+ QTableWidget::mouseMoveEvent(event);
+ return;
+ }
+ if ((event->pos() - dragStartPosition).manhattanLength()
+ < QApplication::startDragDistance())
+ {
+ QTableWidget::mouseMoveEvent(event);
+ return;
+ }
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(QString("test"));
+ qDebug() << "1 ========" << mimeData->formats() << "========";
+ drag->setMimeData(mimeData);
+ drag->exec(Qt::CopyAction | Qt::MoveAction);
+}
+
+void bRestoreTable::dragEnterEvent(QDragEnterEvent *event)
+{
+ Pmsg0(0, "dragEnterEvent\n");
+ qDebug() << "2 ========" << event->mimeData()->formats() << "========";
+
+ if (event->mimeData()->hasText()) {
+ qDebug() << event->mimeData()->text();
+ event->acceptProposedAction();
+ } else {
+ event->ignore();
+ }
+}
+
+// void bRestoreTable::dragMoveEvent(QDragMoveEvent *event)
+// {
+// Pmsg0(0, "dragMoveEvent\n");
+// if (event->mimeData()->hasText()) {
+// event->acceptProposedAction();
+// } else {
+// event->ignore();
+// }
+// }
+//
+void bRestoreTable::dropEvent(QDropEvent *event)
+{
+ Pmsg0(0, "dropEvent\n");
+ qDebug() << "3 ========" << event->mimeData()->formats() << "========";
+ if (event->mimeData()->hasText()) {
+ qDebug() << event->mimeData()->text();
+ event->acceptProposedAction();
+ } else {
+ event->ignore();
+ }
+}
+
<number>9</number>
</property>
<item>
- <widget class="QTableWidget" name="FileList">
+ <widget class="bRestoreTable" name="FileList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>5</horstretch>
<number>9</number>
</property>
<item>
- <widget class="QTableWidget" name="FileRevisions">
+ <widget class="bRestoreTable" name="FileRevisions">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
</layout>
</item>
<item>
- <widget class="QTableWidget" name="RestoreList">
+ <widget class="bRestoreTable" name="RestoreList">
<property name="acceptDrops">
<bool>true</bool>
</property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::DropOnly</enum>
+ </property>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
<column>
<property name="text">
<string>Data</string>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>bRestoreTable</class>
+ <extends>QTableWidget</extends>
+ <header>restore.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
#include <QtGui>
#include "pages.h"
+
+
+class bRestoreTable : public QTableWidget
+{
+ Q_OBJECT
+private:
+ QPoint dragStartPosition;
+public:
+ bRestoreTable(QWidget *parent)
+ : QTableWidget(parent)
+ {
+ }
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ void dragEnterEvent(QDragEnterEvent *event);
+// void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
+};
+
#include "ui_brestore.h"
#include "ui_restore.h"
#include "ui_prerestore.h"
QString m_splitText;
};
-
class bRestore : public Pages, public Ui::bRestoreForm
{
Q_OBJECT