Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further fixes for Qt6 #1713

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions avogadro/qtopengl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Widgets OpenGLWidgets REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGLWidgets)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()
Expand All @@ -19,7 +19,7 @@ target_sources(QtOpenGL PRIVATE
)

avogadro_add_library(QtOpenGL)
target_link_libraries(QtOpenGL Avogadro::Rendering Avogadro::QtGui Qt::Widgets)
target_link_libraries(QtOpenGL PUBLIC Avogadro::Rendering Avogadro::QtGui Qt::Widgets)
if(QT_VERSION EQUAL 6)
target_link_libraries(QtOpenGL Qt::OpenGLWidgets)
target_link_libraries(QtOpenGL PRIVATE Qt6::OpenGLWidgets)
endif()
5 changes: 5 additions & 0 deletions avogadro/qtopengl/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
#include <avogadro/rendering/glrenderer.h>

#include <QPointer>

#if QT_VERSION >= 0x060000
#include <QtOpenGLWidgets/QOpenGLWidget>
#else
#include <QOpenGLWidget>
#endif

class QTimer;

Expand Down
12 changes: 12 additions & 0 deletions avogadro/qtplugins/aligntool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Gui REQUIRED)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()

set(aligntool_srcs
aligntool.cpp
)
Expand All @@ -20,3 +26,9 @@ avogadro_plugin(AlignTool
)

target_link_libraries(AlignTool PRIVATE Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(AlignTool PRIVATE Qt6::Gui)
else()
target_link_libraries(AlignTool PRIVATE Qt5::Widgets)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ QString CoordinateEditorDialog::detectInputFormat() const
FORMAT_DEBUG(qDebug() << "\n\nExamining sample:" << sample;)

// Split the string into tokens, and identify the type of each.
QList<QString> tokens(sample.split(TOKEN_SEPARATOR, QString::SkipEmptyParts));
QList<QString> tokens(sample.split(TOKEN_SEPARATOR, Qt::SkipEmptyParts));
QList<TokenType> tokenTypes;
tokenTypes.reserve(tokens.size());
size_t tokenTypeCounts[3] = { 0, 0, 0 };
Expand Down
12 changes: 12 additions & 0 deletions avogadro/qtplugins/forcefield/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 COMPONENTS Gui REQUIRED)
else()
find_package(Qt5 COMPONENTS Widgets REQUIRED)
endif()

set(forcefield_srcs
forcefield.cpp
forcefielddialog.cpp
Expand Down Expand Up @@ -28,6 +34,12 @@ avogadro_plugin(Forcefield

target_link_libraries(Forcefield PRIVATE Avogadro::Calc)

if(QT_VERSION EQUAL 6)
target_link_libraries(Forcefield PRIVATE Qt6::Gui)
else()
target_link_libraries(Forcefield PRIVATE Qt5::Widgets)
endif()

if (BUILD_GPL_PLUGINS AND OpenBabel3_LIBRARY)
target_link_libraries(Forcefield PRIVATE OpenBabel3)
endif()
Expand Down
10 changes: 6 additions & 4 deletions avogadro/qtplugins/forcefield/obmmenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ Real OBMMEnergy::value(const Eigen::VectorXd& x)
input = "coord\n";
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}

result = writeAndRead(input);
Expand Down Expand Up @@ -257,8 +258,9 @@ void OBMMEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
QByteArray result, input = "coord\n";
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}

result = writeAndRead(input);
Expand Down
19 changes: 12 additions & 7 deletions avogadro/qtplugins/forcefield/scriptenergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <QtCore/QDir>
#include <QtCore/QScopedPointer>

#include <QRegularExpression>

#include <qjsonarray.h>
#include <qjsondocument.h>
#include <qjsonobject.h>
Expand Down Expand Up @@ -115,8 +117,9 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x)
QByteArray input;
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}
QByteArray result = m_interpreter->asyncWriteAndResponse(input);

Expand All @@ -125,7 +128,7 @@ Real ScriptEnergy::value(const Eigen::VectorXd& x)
double energy = 0.0;
for (auto line : lines) {
if (line.startsWith("AvogadroEnergy:")) {
QStringList items = line.split(" ", QString::SkipEmptyParts);
QStringList items = line.split(" ", Qt::SkipEmptyParts);
if (items.size() > 1) {
energy = items[1].toDouble();
break;
Expand All @@ -148,8 +151,9 @@ void ScriptEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
QByteArray input;
for (Index i = 0; i < x.size(); i += 3) {
// write as x y z (space separated)
input += QString::number(x[i]) + " " + QString::number(x[i + 1]) + " " +
QString::number(x[i + 2]) + "\n";
input += QString::number(x[i]).toUtf8() + " " +
QString::number(x[i + 1]).toUtf8() + " " +
QString::number(x[i + 2]).toUtf8() + "\n";
}
QByteArray result = m_interpreter->asyncWriteAndResponse(input);

Expand All @@ -165,7 +169,7 @@ void ScriptEnergy::gradient(const Eigen::VectorXd& x, Eigen::VectorXd& grad)
}

if (readingGrad) {
QStringList items = line.split(" ", QString::SkipEmptyParts);
QStringList items = line.split(" ", Qt::SkipEmptyParts);
if (items.size() == 3) {
grad[i] = items[0].toDouble();
grad[i + 1] = items[1].toDouble();
Expand Down Expand Up @@ -365,7 +369,8 @@ void ScriptEnergy::processElementString(const QString& str)
QString str2(str);
str2.replace(',', ' ');
// then split on whitespace
QStringList strList = str2.split(QRegExp("\\s+"), QString::SkipEmptyParts);
QStringList strList =
str2.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
foreach (QString sstr, strList) {
// these should be numbers or ranges (e.g., 1-84)
if (sstr.contains('-')) {
Expand Down
10 changes: 9 additions & 1 deletion avogadro/qtplugins/label/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ avogadro_plugin(LabelEditor
)

target_link_libraries(Label LINK_PRIVATE Avogadro::Rendering)
target_link_libraries(LabelEditor LINK_PRIVATE Avogadro::QtOpenGL)
target_link_libraries(LabelEditor
LINK_PRIVATE
Avogadro::Rendering
Avogadro::QtOpenGL)

target_include_directories(LabelEditor
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/../../rendering
${CMAKE_CURRENT_BINARY_DIR}/../../qtopengl)
14 changes: 14 additions & 0 deletions avogadro/qtplugins/playertool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6
REQUIRED COMPONENTS
OpenGL
OpenGLWidgets)
endif()

avogadro_plugin(PlayerTool
"Player tool"
ToolPlugin
Expand All @@ -13,3 +20,10 @@ target_link_libraries(PlayerTool
gwavi
gif-h
Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(PlayerTool
PRIVATE
Qt6::OpenGL
Qt6::OpenGLWidgets)
endif()
6 changes: 3 additions & 3 deletions avogadro/qtplugins/qtaim/qtaimwavefunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)

while (fileContentsByLine.first().startsWith("TYPE ASSIGNMENTS")) {
QString line(fileContentsByLine.first().mid(20, -1));
QStringList splitLine(line.split(" ", QString::SkipEmptyParts));
QStringList splitLine(line.split(" ", Qt::SkipEmptyParts));

for (qint64 i = 0; i < splitLine.length(); ++i) {
typeAssignmentsList.append(splitLine.at(i).toLongLong());
Expand Down Expand Up @@ -261,7 +261,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)

while (fileContentsByLine.first().startsWith("EXPONENTS")) {
QString line(fileContentsByLine.first().mid(9, -1));
QStringList splitLine(line.split(" ", QString::SkipEmptyParts));
QStringList splitLine(line.split(" ", Qt::SkipEmptyParts));

for (qint64 i = 0; i < splitLine.length(); ++i) {
QString str(splitLine.at(i));
Expand Down Expand Up @@ -324,7 +324,7 @@ bool QTAIMWavefunction::initializeWithWFNFile(const QString& fileName)
m_molecularOrbitalEigenvalues[i] = molecularOrbitalEigenvaluesList.at(i);

moCoefficientsStringList =
moCoefficientsStringList.join(" ").split(" ", QString::SkipEmptyParts);
moCoefficientsStringList.join(" ").split(" ", Qt::SkipEmptyParts);

for (qint64 i = 0; i < moCoefficientsStringList.length(); ++i) {
QString str(moCoefficientsStringList.at(i));
Expand Down
10 changes: 10 additions & 0 deletions avogadro/qtplugins/resetview/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS OpenGLWidgets)
endif()

avogadro_plugin(ResetView
"Manipulate the view camera."
ExtensionPlugin
Expand All @@ -8,3 +12,9 @@ avogadro_plugin(ResetView
)

target_link_libraries(ResetView PRIVATE Avogadro::QtOpenGL)

if(QT_VERSION EQUAL 6)
target_link_libraries(ResetView
PRIVATE
Qt6::OpenGLWidgets)
endif()
2 changes: 1 addition & 1 deletion avogadro/qtplugins/scriptcharges/scriptchargemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void ScriptChargeModel::processElementString(const QString& str)
QString str2(str);
str2.replace(',', ' ');
// then split on whitespace
QStringList strList = str2.split(QRegExp("\\s+"), QString::SkipEmptyParts);
QStringList strList = str2.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
foreach (QString sstr, strList) {
// these should be numbers or ranges (e.g., 1-84)
if (sstr.contains('-')) {
Expand Down
10 changes: 10 additions & 0 deletions avogadro/qtplugins/surfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(QT_VERSION EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS OpenGL)
endif()

set(surfaces_srcs
gaussiansetconcurrent.cpp
slatersetconcurrent.cpp
Expand All @@ -23,3 +27,9 @@ target_link_libraries(Surfaces
gif-h
gwavi
tinycolormap)

if(QT_VERSION EQUAL 6)
target_link_libraries(Surfaces
PRIVATE
Qt6::OpenGL)
endif()
2 changes: 1 addition & 1 deletion avogadro/quantumio/gamessukout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool tokenize(std::vector<std::string>& vcr, const char* buf,
splitString += QString(delimstr);
splitString += QString("]");
QRegExp splitter(splitString);
foreach (const QString& str, tmp.split(splitter, QString::SkipEmptyParts))
foreach (const QString& str, tmp.split(splitter, Qt::SkipEmptyParts))
vcr.push_back(str.toStdString());

return true;
Expand Down
Loading