Skip to content

Commit

Permalink
Refactor getDefaultVariantForFormat function to simplify control flow…
Browse files Browse the repository at this point in the history
… and ensure format validation.
  • Loading branch information
przemek83 committed Jan 4, 2025
1 parent 596009e commit a9d0e45
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,14 @@ QString getXlsxTemplateName()

QVariant getDefaultVariantForFormat(ColumnType format)
{
switch (format)
{
case ColumnType::STRING:
return QVariant(QMetaType(QMetaType::QString));
Q_ASSERT(format != ColumnType::UNKNOWN);

case ColumnType::NUMBER:
return QVariant(QMetaType(QMetaType::Double));
if (format == ColumnType::NUMBER)
return QVariant(QMetaType(QMetaType::Double));

case ColumnType::DATE:
return QVariant(QMetaType(QMetaType::QDate));
if (format == ColumnType::DATE)
return QVariant(QMetaType(QMetaType::QDate));

default:
Q_ASSERT(false);
}
return QVariant(QMetaType(QMetaType::QString));
}

Expand Down

0 comments on commit a9d0e45

Please sign in to comment.