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 »

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.
I didn't knew that. Thanks for pointing this out :roll:
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.
ok. I belive i used it in other places but it won't take long to correct it.
User avatar
pvdk
Posts: 528
Joined: 12 Aug 2011, 16:34

Re: Drag & Drop

Post by pvdk »

Zini wrote: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.
I believe that is untrue, QString::toStdString will convert the string to a QByteArray using QString::toAscii() (QString::toUtf8() in Qt 5.0). When you set the QTextCodec::codecForCStrings() to UTF-8 it should work. That doesn't mean it's efficient, I'd say use QString::toUtf8().constData() instead.

The documentation on QString::toAscii:
Qt 4.8 documentation wrote:If a codec has been set using QTextCodec::setCodecForCStrings(), it is used to convert Unicode to 8-bit char; otherwise this function does the same as toLatin1().
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini »

I meant to look into the codec stuff, but never got around to it. Note that we are still on Qt 4.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka »

I meant to look into the codec stuff, but never got around to it.
Nobody knows everything.

Anyway, I just finished implementing functionality. Dropping record creates filter, dropping multiple creates filter with or. Dropping record on filter containing something will replace it, doing the same with pressed ctrl will glue them with "and". Use shift for "or" glue.

I did not implement menu to select column: it is just not needed. The number of types that can be matched into more than one column is limited and those filters yields acceptable small ammounts of resoults.

At this point I have to just refactor code and send pull request.

PS
I guess it would be nice to just drag record from filters table. If forgot about it. ;)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Drag & Drop

Post by Zini »

Just to make this clear: We still need either the other string conversion method in your code or we need to look into the codec thing. As I wrote, I haven't investigated it yet, but I doubt we have a UTF-8 codec as default.

Dragging filters to the filter field: Better replace that with dragging the filter to the entire subview. This is completely unambiguous since there is no other context with a filter ID drag target.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Drag & Drop

Post by sirherrbatka »

Just to make this clear: We still need either the other string conversion method in your code or we need to look into the codec thing. As I wrote, I haven't investigated it yet, but I doubt we have a UTF-8 codec as default.
Right now I'm converting first to the c_string, and then to the qstring with the fromUtf8 method.
Dragging filters to the filter field: Better replace that with dragging the filter to the entire subview. This is completely unambiguous since there is no other context with a filter ID drag target.
Good idea.
Post Reply