Skip to content

Commit

Permalink
Allow to select no project
Browse files Browse the repository at this point in the history
  • Loading branch information
pasbi committed Oct 20, 2024
1 parent f8f9f6c commit 64fe034
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/views/perioddetailview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void init_style_selected(QStyleOptionViewItem* option, const QModelIndex& index)
}
}

void init_style_option(QStyleOptionViewItem* option, const QModelIndex& index, Period::Type period_type)
void init_style_option(QStyleOptionViewItem* option, const QModelIndex& index, const Period::Type period_type)
{
if (const auto data = index.data(Qt::DisplayRole); data.typeId() == qMetaTypeId<DatePair>()) {
const auto& [begin, end] = qvariant_cast<DatePair>(data);
Expand Down Expand Up @@ -88,6 +88,7 @@ class ProjectItemDelegate final : public QStyledItemDelegate
for (const auto& project : m_time_sheet->project_model().projects()) {
editor->addItem(project->name());
}
editor->addItem(tr("No Project"));
return editor.release();
}

Expand All @@ -102,7 +103,10 @@ class ProjectItemDelegate final : public QStyledItemDelegate
{
const auto& combo_box = dynamic_cast<QComboBox&>(*editor);
const Project* project = nullptr;
if (const auto current_text = combo_box.currentText(); current_text == combo_box.itemText(combo_box.currentIndex()))
if (combo_box.currentIndex() == m_time_sheet->project_model().projects().size()) {
project = nullptr;
} else if (const auto current_text = combo_box.currentText();
current_text == combo_box.itemText(combo_box.currentIndex()))
{
project = &m_time_sheet->project_model().project(combo_box.currentIndex());
} else if (QMessageBox::question(editor, QApplication::applicationDisplayName(),
Expand Down

0 comments on commit 64fe034

Please sign in to comment.