Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
- Qt 5.15 has marked quite a few bits of their code as obsolete, which
  generated a lot of warnings.
- warning about inaccuracies converting large ints to float.
  • Loading branch information
jdtournier committed Jun 17, 2020
1 parent 3a3b608 commit 8c1aaed
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/gui/dialog/dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace MR
}

Qt::ItemFlags flags (const QModelIndex& index) const {
if (!index.isValid()) return (0);
if (!index.isValid()) return {};
return (Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialog/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifdef MRTRIX_MACOSX
# define FILE_DIALOG_OPTIONS QFileDialog::DontUseNativeDialog
#else
# define FILE_DIALOG_OPTIONS static_cast<QFileDialog::Options> (0)
# define FILE_DIALOG_OPTIONS QFileDialog::Options()
#endif

namespace MR
Expand Down
16 changes: 8 additions & 8 deletions src/gui/dialog/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,40 @@ namespace MR

QVariant TreeModel::data (const QModelIndex& index, int role) const
{
if (!index.isValid()) return QVariant();
if (role != Qt::DisplayRole) return QVariant();
if (!index.isValid()) return {};
if (role != Qt::DisplayRole) return {};
return static_cast<TreeItem*> (index.internalPointer())->data (index.column());
}

Qt::ItemFlags TreeModel::flags (const QModelIndex& index) const
{
if (!index.isValid()) return 0;
if (!index.isValid()) return {};
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

QVariant TreeModel::headerData (int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) return rootItem->data (section);
return QVariant();
return {};
}

QModelIndex TreeModel::index (int row, int column, const QModelIndex& parent) const
{
if (!hasIndex (row, column, parent)) return QModelIndex();
if (!hasIndex (row, column, parent)) return {};
TreeItem* parentItem;
if (!parent.isValid()) parentItem = rootItem;
else parentItem = static_cast<TreeItem*> (parent.internalPointer());
TreeItem* childItem = parentItem->child (row);
if (childItem) return createIndex (row, column, childItem);
else return QModelIndex();
else return {};
}

QModelIndex TreeModel::parent (const QModelIndex& index) const
{
if (!index.isValid()) return QModelIndex();
if (!index.isValid()) return {};
TreeItem* childItem = static_cast<TreeItem*> (index.internalPointer());
TreeItem* parentItem = childItem->parent();
if (parentItem == rootItem) return QModelIndex();
if (parentItem == rootItem) return {};
return createIndex (parentItem->row(), 0, parentItem);
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/dwi/render_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ namespace MR

void RenderFrame::wheelEvent (QWheelEvent* event)
{
int scroll = event->delta() / 120;
QPoint pixels = event->pixelDelta();
int scroll = pixels.isNull() ? event->angleDelta().y() / 120 : event->angleDelta().y();
for (int n = 0; n < scroll; n++) scale *= ScaleInc;
for (int n = 0; n > scroll; n--) scale /= ScaleInc;
update();
Expand Down
60 changes: 30 additions & 30 deletions src/gui/mrview/sync/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see http://www.mrtrix.org/
*/
#ifndef __sync_enums_h__
#define __sync_enums_h__

namespace MR
{
namespace GUI
{
namespace MRView
{
namespace Sync
{
/**
* The type of message being sent between processes
*/
enum class MessageKey {
ConnectedID = 1,
SyncData = 2 //Data to be synced
};
/**
* For MessageKey::SyncData. This is type of data being sent for syncronising
*/
enum class DataKey {
WindowFocus = 1
};

}
}
}
}
*/
#ifndef __sync_enums_h__
#define __sync_enums_h__

namespace MR
{
namespace GUI
{
namespace MRView
{
namespace Sync
{
/**
* The type of message being sent between processes
*/
enum class MessageKey {
ConnectedID = 1,
SyncData = 2 //Data to be synced
};
/**
* For MessageKey::SyncData. This is type of data being sent for syncronising
*/
enum class DataKey {
WindowFocus = 1
};

}
}
}
}
#endif
8 changes: 4 additions & 4 deletions src/gui/mrview/tool/connectome/matrix_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ namespace MR
Matrix_list_model (Connectome* parent);

QVariant data (const QModelIndex& index, int role) const override {
if (!index.isValid()) return QVariant();
if (role != Qt::DisplayRole) return QVariant();
if (!index.isValid()) return {};
if (role != Qt::DisplayRole) return {};
return qstr (shorten (items[index.row()].get_name().toStdString(), 35, 0));
}

Qt::ItemFlags flags (const QModelIndex& index) const override {
if (!index.isValid()) return 0;
if (!index.isValid()) return {};
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

QModelIndex parent (const QModelIndex&) const override {
return QModelIndex();
return {};
}

int rowCount (const QModelIndex& parent = QModelIndex()) const override {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/mrview/tool/connectome/node_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ namespace MR
QVariant headerData (int section, Qt::Orientation orientation, int role) const override;

Qt::ItemFlags flags (const QModelIndex& index) const override {
if (!index.isValid()) return 0;
if (!index.isValid()) return {};
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

QModelIndex parent (const QModelIndex&) const override {
return QModelIndex();
return {};
}

int rowCount (const QModelIndex& parent = QModelIndex()) const override;
Expand Down
8 changes: 4 additions & 4 deletions src/gui/mrview/tool/odf/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace MR
QAbstractItemModel (parent) { }

QVariant data (const QModelIndex& index, int role) const {
if (!index.isValid()) return QVariant();
if (role != Qt::DisplayRole) return QVariant();
if (!index.isValid()) return {};
if (role != Qt::DisplayRole) return {};
return qstr (shorten (items[index.row()]->image.get_filename(), 35, 0));
}

Expand All @@ -54,12 +54,12 @@ namespace MR
}

Qt::ItemFlags flags (const QModelIndex& index) const {
if (!index.isValid()) return 0;
if (!index.isValid()) return {};
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}

QModelIndex parent (const QModelIndex&) const {
return QModelIndex();
return {};
}

int rowCount (const QModelIndex& parent = QModelIndex()) const {
Expand Down
10 changes: 5 additions & 5 deletions src/gui/mrview/tool/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ namespace MR
QAbstractItemModel (parent) { }

QVariant data (const QModelIndex& index, int role) const {
if (!index.isValid()) return QVariant();
if (!index.isValid()) return {};
if (role == Qt::CheckStateRole) {
return planes[index.row()].active ? Qt::Checked : Qt::Unchecked;
}
if (role != Qt::DisplayRole) return QVariant();
if (role != Qt::DisplayRole) return {};
return qstr (planes[index.row()].name);
}

Expand All @@ -81,7 +81,7 @@ namespace MR
}

Qt::ItemFlags flags (const QModelIndex& index) const {
if (!index.isValid()) return 0;
if (!index.isValid()) return {};
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
}

Expand All @@ -91,7 +91,7 @@ namespace MR
return createIndex (row, column);
}

QModelIndex parent (const QModelIndex&) const { return QModelIndex(); }
QModelIndex parent (const QModelIndex&) const { return {}; }

int rowCount (const QModelIndex& parent = QModelIndex()) const
{
Expand Down Expand Up @@ -292,7 +292,7 @@ namespace MR

transparent_intensity = new AdjustButton (this);
connect (transparent_intensity, SIGNAL (valueChanged()), this, SLOT (onSetTransparency()));
hlayout->addWidget (transparent_intensity, 0, 0);
hlayout->addWidget (transparent_intensity);

opaque_intensity = new AdjustButton (this);
connect (opaque_intensity, SIGNAL (valueChanged()), this, SLOT (onSetTransparency()));
Expand Down
12 changes: 6 additions & 6 deletions src/gui/mrview/volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ namespace MR
value_max = -std::numeric_limits<float>::infinity();

switch (type) {
case gl::BYTE: _scale_factor = std::numeric_limits<int8_t>::max(); break;
case gl::UNSIGNED_BYTE: _scale_factor = std::numeric_limits<uint8_t>::max(); break;
case gl::SHORT: _scale_factor = std::numeric_limits<int16_t>::max(); break;
case gl::UNSIGNED_SHORT: _scale_factor = std::numeric_limits<uint16_t>::max(); break;
case gl::INT: _scale_factor = std::numeric_limits<int32_t>::max(); break;
case gl::UNSIGNED_INT: _scale_factor = std::numeric_limits<uint32_t>::max(); break;
case gl::BYTE: _scale_factor = float (std::numeric_limits<int8_t>::max()); break;
case gl::UNSIGNED_BYTE: _scale_factor = float (std::numeric_limits<uint8_t>::max()); break;
case gl::SHORT: _scale_factor = float (std::numeric_limits<int16_t>::max()); break;
case gl::UNSIGNED_SHORT: _scale_factor = float (std::numeric_limits<uint16_t>::max()); break;
case gl::INT: _scale_factor = float (std::numeric_limits<int32_t>::max()); break;
case gl::UNSIGNED_INT: _scale_factor = float (std::numeric_limits<uint32_t>::max()); break;
default: _scale_factor = 1.0f;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/gui/mrview/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ namespace MR

namespace {

template <class Event> inline QPoint position (Event* event) { return event->pos(); }
template <> inline QPoint position (QWheelEvent* event) { return event->position().toPoint(); }

Qt::KeyboardModifiers get_modifier (const char* key, Qt::KeyboardModifiers default_key) {
std::string value = lowercase (MR::File::Config::get (key));
if (value.empty())
Expand Down Expand Up @@ -1622,15 +1625,15 @@ namespace MR
buttons_ = event->buttons();
modifiers_ = event->modifiers() & ( FocusModifier | MoveModifier | RotateModifier );
mouse_displacement_ = QPoint (0,0);
mouse_position_ = event->pos();
mouse_position_ = position (event);
mouse_position_.setY (glarea->height() - mouse_position_.y());
}


template <class Event> void Window::update_mouse_state (Event* event)
{
mouse_displacement_ = mouse_position_;
mouse_position_ = event->pos();
mouse_position_ = position (event);
mouse_position_.setY (glarea->height() - mouse_position_.y());
mouse_displacement_ = mouse_position_ - mouse_displacement_;
}
Expand Down

0 comments on commit 8c1aaed

Please sign in to comment.