Page 3 of 6

Re: Drag & Drop

Posted: 11 Feb 2014, 13:42
by sirherrbatka
Ah, actually you suggested first solution earlier, but the second one is new. I will think about it.

Re: Drag & Drop

Posted: 11 Feb 2014, 16:05
by sirherrbatka
Ok, I think that spliting enumeration is the way to go. My further plan is to take the following code:
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;
}
};
from the columnimp, and create explicit specialisations. Is that correct (I'm still not quite comfortable using templates)?

Re: Drag & Drop

Posted: 11 Feb 2014, 16:26
by Zini
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.

Re: Drag & Drop

Posted: 11 Feb 2014, 17:23
by sirherrbatka
Oh, that's easy. thanks

Re: Drag & Drop

Posted: 13 Feb 2014, 13:02
by sirherrbatka
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:

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;
        }
    };
To access this enum I had to add extra public function in the idTable

Code: Select all

CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const
{
    return mIdCollection->getColumn(index).mDisplayType;
}
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 :P

Re: Drag & Drop

Posted: 13 Feb 2014, 13:21
by Zini
You do not need the getColumnDisplay function. Use the headerData function.

Re: Drag & Drop

Posted: 13 Feb 2014, 13:58
by sirherrbatka
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…

Re: Drag & Drop

Posted: 13 Feb 2014, 15:23
by sirherrbatka
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?

Re: Drag & Drop

Posted: 13 Feb 2014, 15:39
by Zini
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.

Re: Drag & Drop

Posted: 13 Feb 2014, 18:05
by sirherrbatka
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?