Skip to content

Commit

Permalink
Qt6 fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 26, 2024
1 parent 1a1cdfa commit b51e1bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion avogadro/qtplugins/surfaces/orbitals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void Orbitals::checkQueue()
}

QList<int> priorities = hash.keys();
qSort(priorities);
std::sort(priorities.begin(), priorities.end());
startCalculation(hash.value(priorities.first()));
}

Expand Down
14 changes: 10 additions & 4 deletions avogadro/qtplugins/surfaces/orbitaltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ QVariant OrbitalTableModel::data(const QModelIndex& index, int role) const
!index.isValid())
return QVariant();

// Simple lambda to convert QFlags to variant as in Qt 6 this needs help.
auto toVariant = [&](auto flags) {
return static_cast<Qt::Alignment::Int>(flags);
};

if (role == Qt::TextAlignmentRole) {
switch (Column(index.column())) {
case C_Energy:
return Qt::AlignRight + Qt::AlignVCenter; // numeric alignment
case C_Status: // everything else can be centered
return toVariant(Qt::AlignRight |
Qt::AlignVCenter); // numeric alignment
case C_Status: // everything else can be centered
case C_Description:
case C_Symmetry:
default:
return Qt::AlignHCenter + Qt::AlignVCenter;
return toVariant(Qt::AlignHCenter | Qt::AlignVCenter);
}
}

Expand Down Expand Up @@ -203,7 +209,7 @@ bool OrbitalTableModel::setOrbitals(const Core::BasisSet* basis)
count++;
}
// sort the orbital list (not sure if this is necessary)
qSort(m_orbitals.begin(), m_orbitals.end(), orbitalIndexLessThan);
std::sort(m_orbitals.begin(), m_orbitals.end(), orbitalIndexLessThan);

// add the rows for all the new orbitals
beginInsertRows(QModelIndex(), 0, m_orbitals.size() - 1);
Expand Down
3 changes: 2 additions & 1 deletion avogadro/qtplugins/surfaces/orbitalwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class OrbitalWidget : public QWidget
};

//! Constructor
explicit OrbitalWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
explicit OrbitalWidget(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::Widget);
//! Deconstructor
virtual ~OrbitalWidget();

Expand Down

1 comment on commit b51e1bf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: clang-format-diff detected formatting issues. See the artifact for a patch or run clang-format on your branch.

Please sign in to comment.