|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <qt4/QtCore/qabstractitemmodel.h>
|
|
|
|
|
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
@ -224,6 +225,8 @@ CSVWorld::RegionMap::RegionMap (const CSMWorld::UniversalId& universalId,
|
|
|
|
|
mViewInTableAction = new QAction (tr ("View Cells in Table"), this);
|
|
|
|
|
connect (mViewInTableAction, SIGNAL (triggered()), this, SLOT (viewInTable()));
|
|
|
|
|
addAction (mViewInTableAction);
|
|
|
|
|
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::RegionMap::selectAll()
|
|
|
|
@ -367,3 +370,37 @@ std::vector< CSMWorld::UniversalId > CSVWorld::RegionMap::getDragedRecords() con
|
|
|
|
|
}
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
|
|
|
|
if (mime->fromDocument(mDocument) && mime->holdsType(CSMWorld::UniversalId::Type_Region))
|
|
|
|
|
{
|
|
|
|
|
CSMWorld::UniversalId record (mime->returnMatching (CSMWorld::UniversalId::Type_Region));
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *regionModel = model();
|
|
|
|
|
|
|
|
|
|
CSMWorld::IdTable *cellsModel = &dynamic_cast<CSMWorld::IdTable&> (*
|
|
|
|
|
mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
|
|
|
|
|
|
|
|
|
std::string cellId(regionModel->data (index, CSMWorld::RegionMap::Role_CellId).
|
|
|
|
|
toString().toUtf8().constData());
|
|
|
|
|
|
|
|
|
|
QModelIndex index2 = cellsModel->getModelIndex (cellId,
|
|
|
|
|
cellsModel->findColumnIndex (CSMWorld::Columns::ColumnId_Region));
|
|
|
|
|
|
|
|
|
|
mDocument.getUndoStack().push(new CSMWorld::ModifyCommand
|
|
|
|
|
(*cellsModel, index2, QString::fromUtf8(record.getId().c_str())));
|
|
|
|
|
|
|
|
|
|
mRegionId = record.getId();
|
|
|
|
|
}
|
|
|
|
|
}
|