2025-06-17 17:20:54 +08:00
|
|
|
#include "cusTableWidget.h"
|
2025-06-18 10:19:54 +08:00
|
|
|
|
2025-06-18 14:53:56 +08:00
|
|
|
#include <InfoDirFile.h>
|
|
|
|
|
#include <InfoPack.hpp>
|
2025-06-18 10:19:54 +08:00
|
|
|
#include <QApplication>
|
2025-06-17 17:20:54 +08:00
|
|
|
#include <QDrag>
|
|
|
|
|
#include <QMimeData>
|
|
|
|
|
#include <QPainter>
|
2025-06-18 17:22:15 +08:00
|
|
|
|
2025-06-18 14:53:56 +08:00
|
|
|
#include "FileControl.h"
|
2025-06-17 17:20:54 +08:00
|
|
|
|
2025-06-18 10:19:54 +08:00
|
|
|
CustomTableWidget::CustomTableWidget(QWidget* parent) : QTableWidget(parent)
|
2025-06-17 17:20:54 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomTableWidget::~CustomTableWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-18 14:53:56 +08:00
|
|
|
void CustomTableWidget::setIsRemote(bool isRemote)
|
|
|
|
|
{
|
|
|
|
|
isRemote_ = isRemote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomTableWidget::setBasePathCall(const std::function<QString()>& call)
|
|
|
|
|
{
|
|
|
|
|
basePathCall_ = call;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString FileManager::GetCurRoot()
|
|
|
|
|
{
|
|
|
|
|
return curRoot_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomTableWidget::setOwnIDCall(const std::function<QString()>& call)
|
|
|
|
|
{
|
|
|
|
|
oidCall_ = call;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomTableWidget::setRemoteIDCall(const std::function<QString()>& call)
|
|
|
|
|
{
|
|
|
|
|
ridCall_ = call;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-17 17:20:54 +08:00
|
|
|
void CustomTableWidget::dropEvent(QDropEvent* event)
|
|
|
|
|
{
|
2025-06-18 17:22:15 +08:00
|
|
|
if (!event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
2025-06-17 17:20:54 +08:00
|
|
|
event->ignore();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-18 17:22:15 +08:00
|
|
|
QByteArray encoded = event->mimeData()->data("application/x-qabstractitemmodeldatalist");
|
|
|
|
|
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
|
|
|
|
|
|
|
|
|
QList<QTableWidgetItem*> draggedItems;
|
|
|
|
|
while (!stream.atEnd()) {
|
|
|
|
|
int row, col;
|
|
|
|
|
QMap<int, QVariant> roleData;
|
|
|
|
|
stream >> row >> col >> roleData;
|
|
|
|
|
}
|
2025-06-17 17:20:54 +08:00
|
|
|
}
|
|
|
|
|
|
2025-06-18 10:19:54 +08:00
|
|
|
void CustomTableWidget::dragEnterEvent(QDragEnterEvent* event)
|
2025-06-17 17:20:54 +08:00
|
|
|
{
|
|
|
|
|
const QTableWidget* source = qobject_cast<const QTableWidget*>(event->source());
|
|
|
|
|
if (source == this) {
|
|
|
|
|
event->ignore();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-06-18 17:22:15 +08:00
|
|
|
if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
2025-06-17 17:20:54 +08:00
|
|
|
event->acceptProposedAction();
|
|
|
|
|
} else {
|
|
|
|
|
event->ignore();
|
|
|
|
|
}
|
2025-06-18 17:22:15 +08:00
|
|
|
}
|