Drag & Drop

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

Re: Drag & Drop

Post by sirherrbatka » 18 Feb 2014, 11:01

Well, I guess i should try to do make drag and drop for record filters.

@Zini, why do you think this is more difficult?

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini » 18 Feb 2014, 13:37

We need to properly design this feature first. Here are my thoughts:

If we drag an ID to an empty filter field, OpenCS should look, if this type of ID is used in any column (except for the record ID column). If it is, a one shot filter should be created that let's through any record, that has matching cell content in at least one column.
However me also might consider an option to open a small transient dialogue here that let's the user specify the column(s) in case there is more than one.

If the filter field is not empty, the situation is less clear. I think we need to offer the user several options here:
- replace the old filter
- combine the old and the new filter via and
- combine the old and new filter via or
Maybe a pop-up menu? And some modifier keys for the drag to skip the menu and select one of the options directly?

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka » 18 Feb 2014, 15:34

Ah, ok. I thought we just want drag and drop of filters into filter record. Actually this is any interesting idea.

Well I propose to have consisten behavior:
However me also might consider an option to open a small transient dialogue here that let's the user specify the column(s) in case there is more than one.
Let's use mouse chording for that. Press shift to get all columns and…
Maybe a pop-up menu? And some modifier keys for the drag to skip the menu and select one of the options directly?
Shift for “or”, ctrl for “and”. Maybe alt for replacing?

Simply speaking, let's use shift key as a chord for any wider/stronger action universally in the OpenCS. BTW: I consider keyboard shortcuts to be significant part of the user interface and since We still miss those we may start thinking about directions we may want to go.

And one more think: drag and drop clearly should not be the only option to make a filter. Obviously we would like to have keyboard shortcut. I'm not sure how to handle keyboard shortcuts in the qt (my audio player does this strongly not-qt way) but I know that We will need qaction in the table that can be triggered and send signal to the record filter field.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka » 19 Feb 2014, 13:02

I'm working on it. It seems that i know how to handle this task.

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini » 19 Feb 2014, 16:08

I haven't planned much in terms of keyboard shortcuts. Obviously we need shortcuts for the menu items (both main and context). Some modifier stuff as mentioned above and probably some more in the 3D window.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka » 19 Feb 2014, 16:28

Ok, I guess this element can be considered later.

Well my status: i basicly passed all needed informations to create filter into the filterbox. I had to increase table interface, and I'm not quite sure if I did this in the best way imaginable. Basicly, I added this function:

std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const

Is it ok, or i should rather access/return columns differently?

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini » 19 Feb 2014, 18:56

You don't need a new function. Use headerData with the right role.

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka » 19 Feb 2014, 19:23

Actually that's what I do, but…

Code: Select all

std::vector<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const
{
    int count = mModel->columnCount();

    std::vector<std::string> titles;
    for (int i = 0; i < count; ++i)
    {
        CSMWorld::ColumnBase::Display columndisplay = static_cast<CSMWorld::ColumnBase::Display>
                                                     (mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());

        if (display == columndisplay)
        {
            titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toStdString());
        }
    }
    return titles;
}
We should handle dragging more than one record (for instance to check for orcs and redguard npcs).

User avatar
sirherrbatka
Posts: 2121
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka » 20 Feb 2014, 12:39

I have no idea what i meant when writting the previous post. :oops:

At the moment basic creation of filters works, but before implementing the rest of functions I really would like you, zini to take a small look into my code and see if i didn't mess anything (if you only have a moment of free time to spare). Pardon, but I'm under impression that we missunderstand each other when it comes to my changes in the tables.

Thanks in advance and no need to rush as it won't get into the 0.29.0 anyway.

User avatar
Zini
Posts: 5134
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini » 20 Feb 2014, 14:05

Looks okay. Mostly.

You really need to get rid of the habit of following a return with a break in a case statement. That is unreachable code. It may trigger warnings with some compiler/compiler configurations (not a problem for us AFAIK) and may also create warnings from certain code analysis tools.

Also, your use of QString::toStdString is incorrect. This only works for ASCII (or ISO 8859 Latin1 characters; the documentation is not entirely clear about that). We are using UTF-8.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest