Browse Source

COMP: Fix deprecated-declarations warnings

Fix warnings similar to:

    CTK/Libs/Widgets/ctkCollapsibleButton.cpp:650:3: warning: 'QStyleOptionFrameV3' is deprecated [-Wdeprecated-declarations]
      QStyleOptionFrameV3 fopt;
Max Smolens 7 years ago
parent
commit
bbd3a2b712

+ 8 - 0
Libs/Widgets/ctkCheckableComboBox.cpp

@@ -72,6 +72,8 @@ protected:
       if (isSeparator(index))
         {
         QRect rect = option.rect;
+
+#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
         if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*>(&option))
           {
           if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(v3->widget))
@@ -79,6 +81,12 @@ protected:
             rect.setWidth(view->viewport()->width());
             }
           }
+#else
+        if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(option.widget))
+          {
+          rect.setWidth(view->viewport()->width());
+          }
+#endif
         QStyleOption opt;
         opt.rect = rect;
         this->ComboBox->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, this->ComboBox);

+ 4 - 0
Libs/Widgets/ctkCollapsibleButton.cpp

@@ -647,7 +647,11 @@ void ctkCollapsibleButton::paintEvent(QPaintEvent * _event)
                         opt.text, QPalette::ButtonText);
 
   // Draw Frame around contents
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
   QStyleOptionFrameV3 fopt;
+#else
+  QStyleOptionFrame fopt;
+#endif
   fopt.init(this);
   // HACK: on some styles, the frame doesn't exactly touch the button.
   // this is because the button has some kind of extra border.

+ 8 - 0
Libs/Widgets/ctkSearchBox.cpp

@@ -97,7 +97,11 @@ QRect ctkSearchBoxPrivate::searchRect()const
   // the frame line width
   if (q->hasFrame())
     {
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
     QStyleOptionFrameV2 opt;
+#else
+    QStyleOptionFrame opt;
+#endif
     q->initStyleOption(&opt);
     sRect.adjust(opt.lineWidth, opt.lineWidth, -opt.lineWidth, -opt.lineWidth);
     }
@@ -226,7 +230,11 @@ void ctkSearchBox::paintEvent(QPaintEvent * event)
   QRect r = rect();
   QPalette pal = palette();
 
+#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
   QStyleOptionFrameV2 panel;
+#else
+  QStyleOptionFrame panel;
+#endif
   initStyleOption(&panel);
   r = this->style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);
   r.setX(r.x() + this->textMargins().left());