Drag & Drop
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
Ah, actually you suggested first solution earlier, but the second one is new. I will think about it.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
Ok, I think that spliting enumeration is the way to go. My further plan is to take the following code:
from the columnimp, and create explicit specialisations. Is that correct (I'm still not quite comfortable using templates)?struct StringIdColumn : public Column<ESXRecordT>
{
StringIdColumn (bool hidden = false)
: Column<ESXRecordT> (Columns::ColumnId_Id, ColumnBase::Display_String,
hidden ? 0 : ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return QString::fromUtf8 (record.get().mId.c_str());
}
virtual bool isEditable() const
{
return false;
}
};
Re: Drag & Drop
That is the StringId column. You don't need to touch that, because it can never be a drop target, because this specifies the ID of the record displayed in this row.
What you need to change are the columns that represent references to other IDs, e.g. PcFactionColumn.
What you need to change are the columns that represent references to other IDs, e.g. PcFactionColumn.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
I expirence some difficulties with splitting display.
I added some concrete display types, but as it seems, either i miss something or approach it from wrong side. Basicly i added extra enums and set columns like that:
To access this enum I had to add extra public function in the idTable
However, it appears to return 0 (display_string) instead of the new enum on the teleportcellcolumn. I'm trying to figure out why but a hint would be very helpfull. I can't use gus because he ran away
I added some concrete display types, but as it seems, either i miss something or approach it from wrong side. Basicly i added extra enums and set columns like that:
Code: Select all
template<typename ESXRecordT>
struct TeleportCellColumn : public Column<ESXRecordT>
{
TeleportCellColumn()
: Column<ESXRecordT> (Columns::ColumnId_TeleportCell, ColumnBase::Display_Cell)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return QString::fromUtf8 (record.get().mDestCell.c_str());
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
ESXRecordT record2 = record.get();
record2.mDestCell = data.toString().toUtf8().constData();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
virtual bool isUserEditable() const
{
return false;
}
};
Code: Select all
CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const
{
return mIdCollection->getColumn(index).mDisplayType;
}
Re: Drag & Drop
You do not need the getColumnDisplay function. Use the headerData function.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
Ah, ok, I'm using headData, but i still can't retrive correct display type. I will take a closer look into columnimp, maybe I missed something…
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
Ok, nailed it. But I'm confused.
It seems that refidcollection creates columns on it's own, without carrying about columnimp. Columninmp is used only by other collections. Is that correct?
It seems that refidcollection creates columns on it's own, without carrying about columnimp. Columninmp is used only by other collections. Is that correct?
Re: Drag & Drop
Yes. The columns defined in columnimp are intended for a single-type collection. That does not apply to the RefIdCollection and therefore we need a separate implementation.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Drag & Drop
Ok, at this point we miss changing value itself. I used to think that generating QVariant from the id string and using it in the modify command is the way to go, but now I have doubts. What would you suggest, zini?