A specialized treeview that supports a custom drop event.
More...
#include <FolderView.h>
|
static const char * | FileSelectionMimeType = "application/x-computers-selection" |
| Constant that indicates the mime type for a selection of files. More...
|
|
|
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &target) |
| Drop event. More...
|
|
A specialized treeview that supports a custom drop event.
Definition at line 21 of file FolderView.h.
◆ FolderView()
FolderView::FolderView |
( |
| ) |
|
Constructor.
Definition at line 17 of file FolderView.C.
static const char * FileSelectionMimeType
Constant that indicates the mime type for a selection of files.
◆ dropEvent()
void FolderView::dropEvent |
( |
const WDropEvent & |
event, |
|
|
const WModelIndex & |
target |
|
) |
| |
|
protectedvirtual |
Drop event.
Definition at line 26 of file FolderView.C.
41 WItemSelectionModel *selection
42 =
dynamic_cast<WItemSelectionModel *
>(
event.source());
45 StandardButton result = WMessageBox::show
48 + asString(selection->selectedIndexes().size())
49 +
" files to folder '" 50 + cpp17::any_cast<WString>(target.data(ItemDataRole::Display)).toUTF8()
52 StandardButton::Yes | StandardButton::No);
54 StandardButton result = StandardButton::Yes;
57 if (result == StandardButton::Yes) {
62 std::shared_ptr<WAbstractItemModel> sourceModel = selection->model();
64 WModelIndexSet toChange = selection->selectedIndexes();
66 for (WModelIndexSet::reverse_iterator i = toChange.rbegin();
67 i != toChange.rend(); ++i) {
68 WModelIndex index = *i;
76 std::map<ItemDataRole, cpp17::any> data = model()->itemData(target);
77 data[ItemDataRole::Decoration] = index.data(ItemDataRole::Decoration);
78 sourceModel->setItemData(index, data);
static const char * FileSelectionMimeType
Constant that indicates the mime type for a selection of files.
◆ FileSelectionMimeType
const char * FolderView::FileSelectionMimeType = "application/x-computers-selection" |
|
static |
Constant that indicates the mime type for a selection of files.
Every kind of dragged data should be identified using a unique mime type.
Definition at line 28 of file FolderView.h.
The documentation for this class was generated from the following files:
- /builddir/build/BUILD/wt-4.0.3/examples/treeview-dragdrop/FolderView.h
- /builddir/build/BUILD/wt-4.0.3/examples/treeview-dragdrop/FolderView.C