mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-01 03:21:41 +00:00
Fix: cannot drag region into map, map columns are rectangular
This commit is contained in:
parent
2a41811c83
commit
aa0c9fb4cb
@ -224,6 +224,10 @@ CSVWorld::RegionMap::RegionMap(const CSMWorld::UniversalId& universalId, CSMDoc:
|
||||
addAction(mViewInTableAction);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
// Make columns square incase QSizeHint doesnt apply
|
||||
for (int column = 0; column < this->model()->columnCount(); ++column)
|
||||
this->setColumnWidth(column, this->rowHeight(0));
|
||||
}
|
||||
|
||||
void CSVWorld::RegionMap::selectAll()
|
||||
@ -358,12 +362,24 @@ std::vector<CSMWorld::UniversalId> CSVWorld::RegionMap::getDraggedRecords() cons
|
||||
return ids;
|
||||
}
|
||||
|
||||
void CSVWorld::RegionMap::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*>(event->mimeData());
|
||||
if (mime != nullptr && (mime->holdsType(CSMWorld::UniversalId::Type_Region)))
|
||||
{
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void CSVWorld::RegionMap::dropEvent(QDropEvent* event)
|
||||
{
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
|
||||
bool exists = QTableView::model()->data(index, Qt::BackgroundRole) != QBrush(Qt::DiagCrossPattern);
|
||||
|
||||
if (!index.isValid() || !exists)
|
||||
{
|
||||
return;
|
||||
|
@ -59,6 +59,8 @@ namespace CSVWorld
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user