Skip to content

Commit

Permalink
Fixed compiler warnings in clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Nov 13, 2024
1 parent 80fc624 commit 3eeaa57
Show file tree
Hide file tree
Showing 18 changed files with 608 additions and 527 deletions.
4 changes: 2 additions & 2 deletions src/core/ColorMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void ColorMap::reload_color_maps()
if (!directory.exists())
{
QString warn_msg = "Cannot find the "+ colormapDir +" directory";
qWarning(warn_msg.toStdString().c_str());
qWarning("%s", warn_msg.toStdString().c_str());
//logW<< "Cannot find the " << directory.path()<<"\n";
return;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ void ColorMap::reload_color_maps()
else
{
QString warn_msg = "Cannot open colormap " + fileInfo.absoluteFilePath();
qWarning(warn_msg.toStdString().c_str());
qWarning("%s", warn_msg.toStdString().c_str());
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/RegionCaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RegionCaller
/**
* Destructor.
*/
~RegionCaller();
virtual ~RegionCaller();

virtual bool init(QString path, QString module, QString functionnName) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/core/ShellRegionCaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//---------------------------------------------------------------------------


ShellRegionCaller::ShellRegionCaller()
ShellRegionCaller::ShellRegionCaller() : RegionCaller()
{

m_exists = false;
Expand Down
2 changes: 1 addition & 1 deletion src/core/ShellRegionCaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ShellRegionCaller : public RegionCaller
/**
* Destructor.
*/
~ShellRegionCaller();
virtual ~ShellRegionCaller();

/**
* @brief init
Expand Down
4 changes: 2 additions & 2 deletions src/gstar/AbstractImageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,15 @@ void AbstractImageWidget::treeDoubleClicked(const QModelIndex& index)
if (item != nullptr)
{
QVariant data = item->data(0, index.column());
if (data.type() == QVariant::Color)
if (data.typeId() == QMetaType::QColor)
{
QColor color = QColorDialog::getColor(data.toString(), this);
if (color.isValid())
{
item->setData(index, color);
}
}
else if (data.type() == QVariant::Icon)
else if (data.typeId() == QMetaType::QIcon)
{
QDialog* custom_dialog = item->get_custom_dialog();
if(custom_dialog != nullptr)
Expand Down
74 changes: 38 additions & 36 deletions src/gstar/Annotation/AbstractGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,25 +293,28 @@ QVariant AbstractGraphicsItem::data(int row, int column) const

AnnotationProperty* data = m_data.value(column);

QVariant::Type valueType = data->getValue().type();

QPoint point;
QPointF pointf;

switch (valueType)
auto t = data->getValue().typeId();
if(t == QMetaType::QPoint)
{
case QVariant::Point:
point = data->getValue().toPoint();
return QString("%1, %2").arg(point.x()).arg(point.y());
case QVariant::PointF:
}
else if(t == QMetaType::QPointF)
{
pointf = data->getValue().toPointF();
return QString("%1, %2").arg(pointf.x()).arg(pointf.y());
case QVariant::StringList:
return data->getValue().toStringList()[0];
default:
}
else if(t == QMetaType::QStringList)
{
return data->getValue().toStringList()[0];
}
else
{
return data->getValue();
}

}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -386,19 +389,18 @@ Qt::ItemFlags AbstractGraphicsItem::displayFlags(int row, int column) const
return flags;
}

QVariant::Type t = prop->getValue().type();
switch(t)
auto t = prop->getValue().typeId();
if(t == QMetaType::QColor || t == QMetaType::QIcon)
{
case QVariant::Color:
case QVariant::Icon:
flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
break;
case QVariant::Bool:
}
else if(t == QMetaType::Bool)
{
flags = Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
break;
default:
}
else
{
flags = Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
break;
}

return flags;
Expand Down Expand Up @@ -737,12 +739,11 @@ bool AbstractGraphicsItem::setData(const QModelIndex& index,

AnnotationProperty* data = m_data.value(c);

QVariant::Type valueType = data->getValue().type();
auto t = data->getValue().typeId();

switch (valueType)
if(t == QMetaType::Double)
{
case QVariant::Double:
if (value.type() == QVariant::String)
if (value.typeId() == QMetaType::QString)
{
QString sVal = value.toString();
bool ok = false;
Expand All @@ -753,15 +754,15 @@ bool AbstractGraphicsItem::setData(const QModelIndex& index,
}
return ok;
}
else if (value.type() == QVariant::Double ||
value.type() == QVariant::Int)
else if (value.typeId() == QMetaType::Double ||
value.typeId() == QMetaType::Int)
{
data->setValue(value.toDouble());
}
break;
case QVariant::PointF:
case QVariant::Point:
if (value.type() == QVariant::String)
}
else if(t == QMetaType::QPoint || t == QMetaType::QPointF)
{
if (value.typeId() == QMetaType::QString)
{
QString sVal = value.toString();
if(sVal.contains(","))
Expand All @@ -779,25 +780,26 @@ bool AbstractGraphicsItem::setData(const QModelIndex& index,
else
return false;
}
else if (value.type() == QVariant::Point ||
value.type() == QVariant::PointF )
else if (value.typeId() == QMetaType::QPoint ||
value.typeId() == QMetaType::QPointF )
{
data->setValue(value);
}
break;
case QVariant::Color:
if (value.type() == QVariant::String)
}
else if(t == QMetaType::QColor)
{
if (value.typeId() == QMetaType::QString)
{
data->setValue(QColor(value.toString()));
}
else
{
data->setValue(value);
}
break;
default:
}
else
{
data->setValue(value);
break;
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/gstar/Annotation/UProbeRegionGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ UProbeRegionGraphicsItem* UProbeRegionGraphicsItem::cloneRegion()
QString UProbeRegionGraphicsItem::getUProbeName()
{
QVariant value = this->propertyValue(UPROBE_NAME);
if (value.type() == QVariant::String) {
if (value.typeId() == QMetaType::QString) {
return value.toString();
}
return nullptr;
Expand Down
12 changes: 6 additions & 6 deletions src/gstar/AnnotationTreeModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,18 @@ QVariant AnnotationTreeModel::data(const QModelIndex& index, int role) const
}
else if (role == Qt::DecorationRole)
{
if (var.type() == QVariant::Color)
if (var.typeId() == QMetaType::QColor)
{
return QColor(var.toString());
}
else if (var.type() == QVariant::Icon)
else if (var.typeId() == QMetaType::QIcon)
{
return var.value<QIcon>();
}
}
else if ( role == Qt::CheckStateRole )
{
if (var.type() == QVariant::Bool)
if (var.typeId() == QMetaType::Bool)
{
Qt::CheckState eChkState = ( item->data(index.row(), index.column() ).toBool() ) ? Qt::Checked : Qt::Unchecked;
return eChkState;
Expand All @@ -202,7 +202,7 @@ QVariant AnnotationTreeModel::data(const QModelIndex& index, int role) const
//this stops the color variants from displaying the color as
// a hex value in the tree
QVariant var = item->data(index.row(), index.column());
if (var.type() == QVariant::Color || var.type() == QVariant::Bool || var.type() == QVariant::Icon )
if (var.typeId() == QMetaType::QColor || var.typeId() == QMetaType::Bool || var.typeId() == QMetaType::QIcon )
{
return QVariant();
}
Expand All @@ -219,7 +219,7 @@ QVariant AnnotationTreeModel::data(const QModelIndex& index, int role) const
bool AnnotationTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
bool changed = false;
if (value.type() == QVariant::String)
if (value.typeId() == QMetaType::QString)
{
QString sValue = value.toString();
if (sValue.length() < 1)
Expand All @@ -242,7 +242,7 @@ QVariant AnnotationTreeModel::data(const QModelIndex& index, int role) const
return false;
}

if ( role == Qt::CheckStateRole && var.type() == QVariant::Bool)
if ( role == Qt::CheckStateRole && var.typeId() == QMetaType::Bool)
{
Qt::CheckState eChecked = static_cast< Qt::CheckState >( value.toInt() );
bool bNewValue = eChecked == Qt::Checked;
Expand Down
4 changes: 2 additions & 2 deletions src/gstar/RectItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ char* RectItem::getMask()

// Test if pixel is within ROI
if (contains(mapFromScene(QPointF((float) c, (float) r)))) {
mask[r * w + c] = 255;
mask[r * w + c] = (char)255;
}
else {
mask[r * w + c] = 0;
mask[r * w + c] = (char)0;
}

}
Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
if (uProbeX::log_textedit == nullptr)
{
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
switch (type)
{
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
Expand All @@ -47,6 +50,7 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
int cnt = 0;
switch (type)
{
case QtInfoMsg:
case QtDebugMsg:
cnt += h_msg.count("Info: ");
cnt += h_msg.count("Warning: ");
Expand Down
Loading

0 comments on commit 3eeaa57

Please sign in to comment.