forked from mirror/openmw-tes3mp
Attempt to match types. Does not work at the moment.
This commit is contained in:
parent
71b2fc1c70
commit
09d3c7a446
6 changed files with 33 additions and 23 deletions
|
@ -1485,7 +1485,7 @@ namespace CSMWorld
|
|||
template<typename ESXRecordT>
|
||||
struct RaceColumn : public Column<ESXRecordT>
|
||||
{
|
||||
RaceColumn() : Column<ESXRecordT> (Columns::ColumnId_Race, ColumnBase::Display_String) {}
|
||||
RaceColumn() : Column<ESXRecordT> (Columns::ColumnId_Race, ColumnBase::Display_Race) {}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
|
|
|
@ -188,9 +188,4 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector<int>& newO
|
|||
CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const
|
||||
{
|
||||
return mReordering;
|
||||
}
|
||||
|
||||
CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const
|
||||
{
|
||||
return mIdCollection->getColumn(index).mDisplayType;
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
namespace CSMWorld
|
||||
{
|
||||
class CollectionBase;
|
||||
class ColumnsBase;
|
||||
class RecordBase;
|
||||
|
||||
class IdTable : public QAbstractItemModel
|
||||
|
@ -87,8 +86,6 @@ namespace CSMWorld
|
|||
/// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex).
|
||||
|
||||
Reordering getReordering() const;
|
||||
|
||||
CSMWorld::ColumnBase::Display getColumnDisplay(int index) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "universalid.hpp"
|
||||
#include "columnbase.hpp"
|
||||
#include <iostream>
|
||||
|
||||
CSMWorld::TableMimeData::TableMimeData (UniversalId id)
|
||||
{
|
||||
|
@ -76,8 +77,9 @@ bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type)
|
||||
bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
std::cout<<type<<std::endl;
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
if (it->getType() == convertEnums (type))
|
||||
|
@ -102,7 +104,7 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::Univers
|
|||
throw ("TableMimeData object does not hold object of the seeked type");
|
||||
}
|
||||
|
||||
CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type)
|
||||
CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
|
@ -115,15 +117,10 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnB
|
|||
throw ("TableMimeData object does not hold object of the seeked type");
|
||||
}
|
||||
|
||||
CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type)
|
||||
CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
throw ("This type is not handled");
|
||||
return CSMWorld::UniversalId::Type_None;
|
||||
break;
|
||||
|
||||
case CSMWorld::ColumnBase::Display_Race:
|
||||
return CSMWorld::UniversalId::Type_Race;
|
||||
break;
|
||||
|
@ -271,6 +268,14 @@ CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::Col
|
|||
case CSMWorld::ColumnBase::Display_Scene:
|
||||
return CSMWorld::UniversalId::Type_Scene;
|
||||
break;
|
||||
|
||||
case CSMWorld::ColumnBase::Display_Script:
|
||||
return CSMWorld::UniversalId::Type_Script;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CSMWorld::UniversalId::Type_None;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;
|
||||
|
|
|
@ -25,15 +25,15 @@ namespace CSMWorld
|
|||
std::string getIcon() const;
|
||||
std::vector<UniversalId> getData() const;
|
||||
bool holdsType(UniversalId::Type type) const;
|
||||
bool holdsType(CSMWorld::ColumnBase::Display type);
|
||||
bool holdsType(CSMWorld::ColumnBase::Display type) const;
|
||||
UniversalId returnMatching(UniversalId::Type type) const;
|
||||
UniversalId returnMatching(CSMWorld::ColumnBase::Display type);
|
||||
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
|
||||
|
||||
private:
|
||||
std::vector<UniversalId> mUniversalId;
|
||||
QStringList mObjectsFormats;
|
||||
|
||||
CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
|
||||
CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const;
|
||||
};
|
||||
}
|
||||
#endif // TABLEMIMEDATA_H
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "recordstatusdelegate.hpp"
|
||||
#include "util.hpp"
|
||||
#include <qt4/QtCore/qnamespace.h>
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
|
||||
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
||||
{
|
||||
|
@ -475,13 +477,24 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
|
|||
|
||||
void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
// QModelIndex index = indexAt (event->pos());
|
||||
|
||||
// if (dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->holdsType (mModel->getColumnDisplay (index.column())))
|
||||
// {
|
||||
event->acceptProposedAction();
|
||||
// }
|
||||
}
|
||||
|
||||
void CSVWorld::Table::dropEvent(QDropEvent *event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
QModelIndex index = indexAt (event->pos());
|
||||
|
||||
CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display>(mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
||||
if (dynamic_cast<const CSMWorld::TableMimeData*>(event->mimeData())->holdsType(display))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
std::cout<<"Dropped/n";
|
||||
} else {std::cout<<"Not Dropped\n";}
|
||||
}
|
||||
|
||||
void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event)
|
||||
|
|
Loading…
Reference in a new issue