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

COMP: Fix QModelIndex::child() deprecation warnings #1011

Merged

Conversation

jcfr
Copy link
Member

@jcfr jcfr commented Nov 5, 2021

This commit introduces ctk::modelChildIndex() function so that the
same code compiles without deprecation warnings pre and post Qt 5.8.

It fixes warnings like the following:

  /path/to/S-r/CTK/Libs/DICOM/Core/ctkDICOMModel.cpp:745:32: warning: 'child' is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
        this->setChildData(index.child(i,0), value, role);
                                 ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qabstractitemmodel.h:71:5: note: 'child' has been explicitly marked deprecated here
      QT_DEPRECATED_X("Use QAbstractItemModel::index") inline QModelIndex child(int row, int column) const;
      ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X'
  #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
                                  ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  #    define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
                                                        ^

References:

This commit introduces ctk::modelChildIndex() function so that the
same code compiles without deprecation warnings pre and post Qt 5.8.

It fixes warnings like the following:

  /path/to/S-r/CTK/Libs/DICOM/Core/ctkDICOMModel.cpp:745:32: warning: 'child' is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
        this->setChildData(index.child(i,0), value, role);
                                 ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qabstractitemmodel.h:71:5: note: 'child' has been explicitly marked deprecated here
      QT_DEPRECATED_X("Use QAbstractItemModel::index") inline QModelIndex child(int row, int column) const;
      ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X'
  #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
                                  ^
  /path/to/Support/Qt/5.15.2/clang_64/lib/QtCore.framework/Headers/qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  #    define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
                                                        ^
@jcfr jcfr mentioned this pull request Nov 5, 2021
Copy link
Member

@lassoan lassoan left a comment

Choose a reason for hiding this comment

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

Looks perfect, thank you.

@jcfr jcfr merged commit 04a3fd3 into commontk:master Nov 8, 2021
@jcfr jcfr deleted the fix-deprecation-warnings-qmodelindex-child branch November 8, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants