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

Fix simple warnings #1097

Merged
merged 9 commits into from
Jun 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int main(int argc, char** argv)
else if (args.contains("string"))
{
QByteArray byteArray;
byteArray.append(args["string"].toString());
byteArray.append(args["string"].toString().toUtf8());
QBuffer buffer(&byteArray);
buffer.open(QIODevice::ReadOnly);

Expand Down
2 changes: 1 addition & 1 deletion Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMBrowserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ctkDICOMBrowserTester::initTestCase()
QDir dataDir = QDir(QProcessEnvironment::systemEnvironment().value("CTKData_DIR", ""));
QVERIFY(dataDir.exists());

this->DICOMDir = dataDir.filePath("Data/DICOM");
this->DICOMDir.setPath(dataDir.filePath("Data/DICOM"));
QVERIFY(this->DICOMDir.exists());

this->DatabaseDirectoryName = QDir::tempPath() + "/ctkDICOMBrowserTest-Database";
Expand Down
2 changes: 1 addition & 1 deletion Libs/DICOM/Widgets/ctkDICOMBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ void ctkDICOMBrowser::exportSelectedItems(ctkDICOMModel::IndexType level)
Q_D(const ctkDICOMBrowser);
ctkFileDialog* directoryDialog = new ctkFileDialog();
directoryDialog->setOption(QFileDialog::ShowDirsOnly);
directoryDialog->setFileMode(QFileDialog::DirectoryOnly);
directoryDialog->setFileMode(QFileDialog::Directory);
bool res = directoryDialog->exec();
if (!res)
{
Expand Down
8 changes: 8 additions & 0 deletions Libs/DICOM/Widgets/ctkDICOMTableView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,11 @@ void ctkDICOMTableViewPrivate::applyColumnProperties()
{
if (columnIndicesByVisualIndex[j] > columnIndicesByVisualIndex[j+1])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
columnIndicesByVisualIndex.swapItemsAt(j, j+1);
#else
columnIndicesByVisualIndex.swap(j, j+1);
#endif
header->swapSections(j, j+1);
}
}
Expand All @@ -360,7 +364,11 @@ void ctkDICOMTableViewPrivate::applyColumnProperties()
{
if (columnWeights[j] > columnWeights[j+1])
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
columnWeights.swapItemsAt(j, j+1);
#else
columnWeights.swap(j, j+1);
#endif
header->swapSections(j, j+1);
}
}
Expand Down
23 changes: 16 additions & 7 deletions Libs/PluginFramework/ctkPluginStorageSQL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ctkPluginFrameworkUtil_p.h"
#include "ctkPluginFrameworkContext_p.h"
#include "ctkServiceException.h"
#include "ctkUtils.h"

#include <QFileInfo>
#include <QUrl>
Expand Down Expand Up @@ -696,7 +697,7 @@ QStringList ctkPluginStorageSQL::findResourcesPath(int archiveKey, const QString
}
}

return paths.toList();
return ctk::qSetToQStringList(paths);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -733,13 +734,17 @@ void ctkPluginStorageSQL::executeQuery(QSqlQuery *query, const QString &statemen
}

ctkPluginDatabaseException::Type errorType;
int result = query->lastError().number();
if (result == 26 || result == 11) //SQLILTE_NOTADB || SQLITE_CORRUPT
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QString result = query->lastError().nativeErrorCode();
#else
QString result = QString::number(query->lastError().number());
#endif
if (result == "26" || result == "11") //SQLILTE_NOTADB || SQLITE_CORRUPT
{
qWarning() << "ctkPluginFramework:- Database file is corrupt or invalid:" << getDatabasePath();
errorType = ctkPluginDatabaseException::DB_FILE_INVALID;
}
else if (result == 8) //SQLITE_READONLY
else if (result == "8") // SQLITE_READONLY
errorType = ctkPluginDatabaseException::DB_WRITE_ERROR;
else
errorType = ctkPluginDatabaseException::DB_SQL_ERROR;
Expand Down Expand Up @@ -1009,13 +1014,17 @@ void ctkPluginStorageSQL::beginTransaction(QSqlQuery *query, TransactionType typ
success = query->exec(QLatin1String("BEGIN IMMEDIATE"));

if (!success) {
int result = query->lastError().number();
if (result == 26 || result == 11) //SQLITE_NOTADB || SQLITE_CORRUPT
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QString result = query->lastError().nativeErrorCode();
#else
QString result = QString::number(query->lastError().number());
#endif
if (result == "26" || result == "11") // SQLITE_NOTADB || SQLITE_CORRUPT
{
throw ctkPluginDatabaseException(QString("ctkPluginFramework: Database file is corrupt or invalid: %1").arg(getDatabasePath()),
ctkPluginDatabaseException::DB_FILE_INVALID);
}
else if (result == 8) //SQLITE_READONLY
else if (result == "8") // SQLITE_READONLY
{
throw ctkPluginDatabaseException(QString("ctkPluginFramework: Insufficient permissions to write to database: %1").arg(getDatabasePath()),
ctkPluginDatabaseException::DB_WRITE_ERROR);
Expand Down
3 changes: 2 additions & 1 deletion Libs/Widgets/Testing/Cpp/ctkFileDialogTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ int testSelectionMode(ctkFileDialog* fileDialog)
CHECK_INT(fileDialog->selectionMode(), static_cast<int>(QAbstractItemView::SingleSelection));

fileDialog->setSelectionMode(QAbstractItemView::ExtendedSelection);
fileDialog->setFileMode(QFileDialog::DirectoryOnly);
fileDialog->setFileMode(QFileDialog::Directory);
fileDialog->setOption(QFileDialog::ShowDirsOnly);
CHECK_INT(fileDialog->selectionMode(), static_cast<int>(QAbstractItemView::SingleSelection));

fileDialog->setSelectionMode(QAbstractItemView::ExtendedSelection);
Expand Down
7 changes: 7 additions & 0 deletions Libs/Widgets/ctkWorkflowButtonBoxWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,17 @@ void ctkWorkflowButtonBoxWidgetPrivate::updateGoToButtons(ctkWorkflowStep* curre
Q_ASSERT(q->layout());

// Change the buttons only if the set of steps to have goTo buttons is either empty or has changed
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QList<ctkWorkflowStep*> finishSteps = this->Workflow->finishSteps();
QSet<ctkWorkflowStep*> goToStepsToHaveButtons(finishSteps.begin(), finishSteps.end());
QList<ctkWorkflowStep*> steps = this->GoToButtonToStepMap.values();
QSet<ctkWorkflowStep*> goToStepsThatHaveButtons(steps.begin(), steps.end());
#else
QSet<ctkWorkflowStep*> goToStepsToHaveButtons =
QSet<ctkWorkflowStep*>::fromList(this->Workflow->finishSteps());
QSet<ctkWorkflowStep*> goToStepsThatHaveButtons =
QSet<ctkWorkflowStep*>::fromList(this->GoToButtonToStepMap.values());
#endif

// Remove the buttons if the set of steps to have goTo buttons has changed
if (goToStepsThatHaveButtons != goToStepsToHaveButtons)
Expand Down
4 changes: 2 additions & 2 deletions Plugins/org.commontk.dah.core/ctkSoapConnectionRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ void ctkSoapConnectionRunnable::readClient(QTcpSocket& socket)
QByteArray block;
block.append("HTTP/1.1 200 OK\n");
block.append("Content-Type: text/xml;charset=utf-8\n");
block.append("Content-Length: ").append(QString::number(content.size())).append("\n");
block.append("Content-Length: ").append(QString::number(content.size()).toUtf8()).append("\n");
block.append("\n");

block.append(content);
block.append(content.toUtf8());

CTK_SOAP_LOG_LOWLEVEL( << block );

Expand Down