Project

General

Profile

Actions

Bug #9589

open

Wt does not always show the indicator between the rows if dropping on an item is also allowed.

Added by Andreas Frolov about 2 years ago. Updated about 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
01/07/2022
Due date:
% Done:

0%

Estimated time:

Description

Feature #8636 https://redmine.webtoolkit.eu/issues/8636 is not usable well.

If both drop locations (Wt::DropLocation::OnItem and Wt::DropLocation::BetweenRows) are allowed in view, a drop indicator is displayed between items in tree view only if the mouse cursor with the drop object is in the decoration area (to the left of items). In the table view in this case it is only possible to drop after the last item.

Small example so that you can test it quickly:

auto layout = std::make_unique<Wt::WHBoxLayout>();

int rowCount = 10;

auto model1 = std::make_shared<Wt::WStandardItemModel>(rowCount, 1);
for (int i = 0; i < rowCount; ++i)
{
    model1->setData(model1->index(i, 0), std::string("Model 1 item ") + std::to_string(i));
    auto item = model1->item(i);
    item->setFlags(item->flags() | Wt::ItemFlag::DragEnabled | Wt::ItemFlag::DropEnabled);
}

auto view1 = layout->addWidget(std::make_unique<Wt::WTreeView>());
view1->setModel(model1);
view1->setSelectionMode(Wt::SelectionMode::Single);
view1->setDragEnabled(true);
view1->setDropsEnabled(true);
view1->setEnabledDropLocations(Wt::DropLocation::OnItem | Wt::DropLocation::BetweenRows);

auto model2 = std::make_shared<Wt::WStandardItemModel>(rowCount, 1);
for (int i = 0; i < rowCount; ++i)
{
    model2->setData(model2->index(i, 0), std::string("Model 2 item ") + std::to_string(i));
    auto item = model2->item(i);
    item->setFlags(item->flags() | Wt::ItemFlag::DragEnabled | Wt::ItemFlag::DropEnabled);
}

auto view2 = layout->addWidget(std::make_unique<Wt::WTableView>());
view2->setModel(model2);
view2->setSelectionMode(Wt::SelectionMode::Single);
view2->setDragEnabled(true);
view2->setDropsEnabled(true);
view2->setEnabledDropLocations(Wt::DropLocation::OnItem | Wt::DropLocation::BetweenRows);
Actions #1

Updated by Korneel Dumon about 2 years ago

The idea is that if the view allows both OnItem and BetweenRows that it will show the bold line in between rows except when the model item has the DropEnabled flag, then it will show the indication for dropping on the item.

In your example, all items have DropEnabled set so there should actually be no possibility to drop between rows (which seems a bit bugged). Does this make sense?

Actions #2

Updated by Andreas Frolov about 2 years ago

Hi Korneel
no, that makes no sense. You made it possible to set both modes OnItem and BetweenRows. Then you say it's impossible to use them both at the same time. I do not understand that.

Most hierarchical models use both modes. Dropping between rows inserts an element on the same level and dropping on an item inserts a sub-item. With flat models it is sometimes necessary to insert new elements or to overwrite existing ones. Current implementation makes such functionality impossible.

Actions

Also available in: Atom PDF