Drag & Drop

Involved development of the OpenMW construction set.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka »

Ah, actually you suggested first solution earlier, but the second one is new. I will think about it.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post 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)?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post 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.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka »

Oh, that's easy. thanks
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post 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
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini »

You do not need the getColumnDisplay function. Use the headerData function.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post 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…
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post 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?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post 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.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post 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?
Post Reply