1
0
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:
Sam Hellawell 2024-03-16 07:45:52 +00:00
parent 2a41811c83
commit aa0c9fb4cb
2 changed files with 19 additions and 1 deletions

View File

@ -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;

View File

@ -59,6 +59,8 @@ namespace CSVWorld
void mouseMoveEvent(QMouseEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dropEvent(QDropEvent* event) override;
public: