Skip to main content

Module dnd_types

Module dnd_types 

Source
Expand description

Shared capability types for the data-source drag-and-drop + lazy protocol.

These types are the Teksilo-shaped equivalent of Qt’s flags/canDropMimeData/dropMimeData (DnD validation) and canFetchMore/fetchMore (lazy loading), expressed as defaulted methods on ListDataSource and TreeDataSource. A source owns the answer to “may this drop happen?” (can_accept) and “apply the move” (accept_drop); the view merely renders the source’s verdict and routes the commit. This is what lets an external source of truth (e.g. a Qleany entity store) drive a view without the view ever mutating a mirror model.

§Key types

  • ItemKey — blanket identity trait for any Clone + Eq + Hash + Debug + 'static type.
  • RowState — whether a lazy row’s data is resident (Ready) or still loading (Loading).
  • DragEligibility — per-row drag gate returned by ListDataSource::drag.
  • DropPosition — where a drop lands relative to the target row.
  • DragSource — who is dragging: the same view (intra-view reorder) or a foreign view/OS drop.
  • DropQuery / DropResponse — hover-time can-I-drop? query and verdict.
  • DropCommit — the committed drop handed to accept_drop.
// Example: implementing can_accept for a custom ListDataSource
fn can_accept(&self, query: &teksilo_data::DropQuery<'_, usize>) -> teksilo_data::DropResponse {
    match &query.source {
        teksilo_data::DragSource::SameView { .. } => teksilo_data::DropResponse::Accept,
        teksilo_data::DragSource::Foreign { .. } => teksilo_data::DropResponse::Reject,
    }
}

Structs§

DropCommit
A drop the user actually committed, handed to accept_drop to apply.
DropQuery
A hover-time question posed to a source: “may source drop at position relative to target?” The source answers with a DropResponse.

Enums§

DragEligibility
Whether a row may begin a drag at all (the per-item transferable gate, Qt’s Qt::ItemIsDragEnabled / TabBar’s with_transferable_predicate).
DragSource
Who is dragging, from the receiving source’s point of view.
DropPosition
Where, relative to a target row, a drop lands. Into (reparent) is only meaningful for trees; flat lists reject it.
DropResponse
A source’s verdict on a DropQuery. Drives the hover affordance and gates the commit.
RowState
Whether a realized row’s data is resident yet. A windowed/lazy source returns Loading for indices outside its resident window; the view renders a placeholder skeleton for those and calls request_window to pull them.

Traits§

ItemKey
A stable, hashable identity for a row/node. Blanket-implemented for every Clone + Eq + Hash + Debug + 'static type, so usize, NodeId, i64, String, Uuid, … all qualify with no extra work.