#3752 CAF code changes to build on both Qt4 and Qt5

This commit is contained in:
Gaute Lindkvist 2018-11-26 09:53:12 +01:00
parent 398a59d0a6
commit cc7269c717
17 changed files with 34 additions and 29 deletions

View File

@ -95,10 +95,10 @@ void Log::infoMultiLine(const QString& line1, const QString& line2Etc)
if (generateTrace)
{
cvf::Trace::show("INF: %s", (const char*)line1.toAscii());
cvf::Trace::show("INF: %s", (const char*)line1.toLatin1());
if (!line2Etc.isEmpty())
{
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toAscii());
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toLatin1());
}
}
}
@ -127,10 +127,10 @@ void Log::warningMultiLine(const QString& line1, const QString& line2Etc)
if (generateTrace)
{
cvf::Trace::show("WRN: %s", (const char*)line1.toAscii());
cvf::Trace::show("WRN: %s", (const char*)line1.toLatin1());
if (!line2Etc.isEmpty())
{
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toAscii());
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toLatin1());
}
}
}
@ -186,10 +186,10 @@ bool Log::errorMultiLine(const QString& line1, const QString& line2Etc)
if (generateTrace)
{
cvf::Trace::show("\nERR: %s", (const char*)line1.toAscii());
cvf::Trace::show("\nERR: %s", (const char*)line1.toLatin1());
if (!line2Etc.isEmpty())
{
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toAscii());
cvf::Trace::show((const char*)Utils::indentString(5, line2Etc).toLatin1());
}
}

View File

@ -37,10 +37,10 @@
#include "cafMessagePanel.h"
#include <QtGui/QWidget>
#include <QtGui/QDockWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QBoxLayout>
#include <QWidget>
#include <QDockWidget>
#include <QTextEdit>
#include <QBoxLayout>
namespace caf {

View File

@ -37,7 +37,7 @@
#pragma once
#include <QtGui/QWidget>
#include <QWidget>
class QDockWidget;
class QTextEdit;

View File

@ -40,7 +40,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtGui/QLineEdit>
#include <QLineEdit>
#include <QtOpenGL/QGLContext>

View File

@ -1,6 +1,7 @@
#pragma once
#include <QMetaType>
#include <QString>
class QTextStream;

View File

@ -129,7 +129,7 @@ TEST(PdmReferenceHelperTest, ReferenceFrommRootToField)
QString refString = caf::PdmReferenceHelper::referenceFromRootToField(ihd1, &s3->m_dir);
QString expectedString = "m_dir m_simpleObjPtrField 2";
EXPECT_STREQ(expectedString.toAscii(), refString.toAscii());
EXPECT_STREQ(expectedString.toLatin1(), refString.toLatin1());
delete ihd1;
}
@ -160,7 +160,7 @@ TEST(PdmReferenceHelperTest, ReferenceFrommRootToObject)
QString refString = caf::PdmReferenceHelper::referenceFromRootToObject(ihd1, s3);
QString expectedString = "m_simpleObjPtrField 2";
EXPECT_STREQ(expectedString.toAscii(), refString.toAscii());
EXPECT_STREQ(expectedString.toLatin1(), refString.toLatin1());
ReferenceSimpleObj* ihd2 = new ReferenceSimpleObj;
SimpleObj* s4 = new SimpleObj;

View File

@ -266,7 +266,7 @@ TEST(BaseTest, PdmReferenceHelper)
{
QString refString = caf::PdmReferenceHelper::referenceFromRootToObject(ihd1, s3);
QString expectedString = ihd1->m_childArrayField.keyword() + " 3";
EXPECT_STREQ(refString.toAscii(), expectedString.toAscii());
EXPECT_STREQ(refString.toLatin1(), expectedString.toLatin1());
caf::PdmObjectHandle* fromRef = caf::PdmReferenceHelper::objectFromReference(ihd1, refString);
EXPECT_TRUE(fromRef == s3);

View File

@ -968,7 +968,7 @@ TEST(BaseTest, PdmReferenceHelper)
refString = caf::PdmReferenceHelper::referenceFromRootToObject(ihd1, s3);
QString expectedString = ihd1->m_simpleObjectsField.keyword() + " 3";
EXPECT_STREQ(refString.toAscii(), expectedString.toAscii());
EXPECT_STREQ(refString.toLatin1(), expectedString.toLatin1());
caf::PdmObjectHandle* fromRef = caf::PdmReferenceHelper::objectFromReference(ihd1, refString);
EXPECT_TRUE(fromRef == s3);

View File

@ -1,6 +1,6 @@
#pragma once
#include <QtGui/QMainWindow>
#include <QMainWindow>
#include <QAbstractItemModel>
#include <QItemSelection>

View File

@ -1,6 +1,6 @@
#pragma once
#include <QtGui/QWidget>
#include <QWidget>
class QGridLayout;

View File

@ -1,6 +1,6 @@
#pragma once
#include <QtGui/QWidget>
#include <QWidget>
class QGridLayout;

View File

@ -38,10 +38,10 @@
#include "cafAboutDialog.h"
#include "cafAssert.h"
#include <QtCore/QVariant>
#include <QtGui/QVBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QVariant>
#include <QVBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QtOpenGL/QGLFormat>
namespace caf {

View File

@ -37,7 +37,7 @@
#pragma once
#include <QtGui/QDialog>
#include <QDialog>
class QGridLayout;

View File

@ -200,8 +200,8 @@ void caf::UiListViewModelPdm::setPdmData(PdmObjectCollection* objectGroup, const
}
computeColumnCount();
reset();
beginResetModel();
endResetModel();
}

View File

@ -231,7 +231,11 @@ void PdmUiTableViewEditor::configureAndUpdateUi(const QString& uiConfigName)
}
else if (editorAttrib.resizePolicy == PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER)
{
#if QT_VERSION >= 0x050000
m_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
m_tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
}
}

View File

@ -195,7 +195,7 @@ QVariant PdmUiTableViewQModel::data(const QModelIndex &index, int role /*= Qt::D
}
else
{
return Qt::lightGray;
return QColor(Qt::lightGray);
}
}
else if (textColor.isValid())

View File

@ -85,13 +85,13 @@ TEST(PdmUiTreeSelectionQModelTest, ParentBehaviour)
{
QModelIndex firstChildIndex = myModel.index(0, 0, parentIndex);
EXPECT_STREQ("Second_a", myModel.data(firstChildIndex).toString().toAscii());
EXPECT_STREQ("Second_a", myModel.data(firstChildIndex).toString().toLatin1());
EXPECT_TRUE(parentIndex == myModel.parent(firstChildIndex));
}
{
QModelIndex secondChildIndex = myModel.index(1, 0, parentIndex);
EXPECT_STREQ("Second_b", myModel.data(secondChildIndex).toString().toAscii());
EXPECT_STREQ("Second_b", myModel.data(secondChildIndex).toString().toLatin1());
EXPECT_TRUE(parentIndex == myModel.parent(secondChildIndex));
}
}