Skip to content

Misleading usage of the enum ItemDataRole::ItemTypeRole when using QStandardItemModel::setData in KDGantt #69

@1molPotato

Description

@1molPotato

Description

The official API documentation for KDGantt suggests using ItemDataRole::ItemTypeRole as the role when setting the ItemType through the QStandardItemModel::setData(). However, when implementing this in practice, setting ItemType with ItemTypeRole does not work as expected and leads to rendering errors in the Gantt chart as below:

image

Steps to Reproduce

Open the example file <PathToKDChart>\examples\Gantt\legend_example\mainwindow.cpp and modify line 236 to:

model->setData(model->index(row, 1, parent), dialog->type(), KDGantt::ItemTypeRole);

Run the example application and add any new Entry through the dialog.

branch: master(commit e1a206f)

Expected Behavior

Items with Task/Event/Summary type should be rendered correctly in the graphics scene when setting the role with KDGantt::ItemTypeRole.
Or if I misunderstood the documentation and this is a by-design behavior? If so, please provide more detailed explanation why we should assign role with other values (as far as I know, Qt::DisplayRole and Qt::EditRole work well) instead of the more semantics KDGantt::ItemTypeRole.
Actually, I found it necessary to set role as KDGantt::StartTimeRole or KDGantt::EndTimeRole when setting data for start/end time of a task item. So it's weired and apparently inconsistent if the same API is designed to be used in different ways.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions