Commit a964c9b2 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri

Merge branch 'qt5-support'

parents 3d5b2b30 7c65dc30
......@@ -2,9 +2,36 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(QtTesting)
IF(NOT QT_FOUND)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
SET(QtTesting_QT_VERSION "4" CACHE STRING "Expected Qt version")
MARK_AS_ADVANCED(QtTesting_QT_VERSION)
SET_PROPERTY(CACHE QtTesting_QT_VERSION PROPERTY STRINGS 4 5)
IF(NOT (QtTesting_QT_VERSION VERSION_EQUAL "4" OR
QtTesting_QT_VERSION VERSION_EQUAL "5"))
message(FATAL_ERROR "Expected value for QtTesting_QT_VERSION is either '4' or '5'")
ENDIF()
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
IF(NOT Qt5Test_FOUND)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Test REQUIRED)
ADD_DEFINITIONS(
${Qt5Widgets_DEFINITIONS}
${Qt5Test_DEFINITIONS}
)
INCLUDE_DIRECTORIES(
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Test_INCLUDE_DIRS}
)
SET(QT_LIBRARIES
${Qt5Widgets_LIBRARIES}
${Qt5Test_LIBRARIES}
)
ENDIF()
ELSE()
IF(NOT QT_FOUND)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
ENDIF()
ENDIF()
IF(NOT DEFINED QT_TESTING_WITH_PYTHON)
......@@ -79,7 +106,7 @@ INCLUDE_DIRECTORIES(
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${MOC_INCLUDE_DIRS}")
QT4_WRAP_CPP(MOC_BUILT_SOURCES
SET(MOC_SRCS
pq3DViewEventTranslator.h
pq3DViewEventPlayer.h
pqAbstractActivateEventPlayer.h
......@@ -121,19 +148,43 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqTreeViewEventTranslator.h
pqWidgetEventTranslator.h
pqWidgetEventPlayer.h
${PYTHON_MOCS}
)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ELSE()
QT4_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ENDIF()
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
QT4_WRAP_UI(UI_BUILT_SOURCES
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_UI(UI_BUILT_SOURCES
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
ELSE()
QT4_WRAP_UI(UI_BUILT_SOURCES
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
ENDIF()
QT4_ADD_RESOURCES(QRC_BUILT_SOURCES
Resources/QtTesting.qrc
)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_ADD_RESOURCES(QRC_BUILT_SOURCES
Resources/QtTesting.qrc
)
ELSE()
QT4_ADD_RESOURCES(QRC_BUILT_SOURCES
Resources/QtTesting.qrc
)
ENDIF()
SET(QtTesting_SOURCES
pq3DViewEventPlayer.cxx
......
......@@ -16,8 +16,13 @@ SET (MOC_FILES
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
QT4_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT4_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT5_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ELSE()
QT4_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT4_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ENDIF()
add_executable (TestingDemo
${SOURCE_FILES}
......@@ -27,3 +32,5 @@ add_executable (TestingDemo
target_link_libraries(TestingDemo
QtTesting)
set_target_properties(TestingDemo PROPERTIES
COMPILE_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
......@@ -321,7 +321,6 @@ void pqEventDispatcher::playEvent(int indent)
return;
}
QApplication::syncX();
static unsigned long counter=0;
unsigned long local_counter = counter++;
QString pretty_name = object.mid(object.lastIndexOf('/'));
......
......@@ -226,7 +226,12 @@ void pqEventTranslator::ignoreObject(QObject* Object)
// ----------------------------------------------------------------------------
bool pqEventTranslator::eventFilter(QObject* Object, QEvent* Event)
{
#if QT_VERSION >= 0x050000
if(Object->isWindowType())
{
return false;
}
#endif
// mouse events are propagated to parents
// our event translators/players don't quite like that,
// so lets consume those extra ones
......
......@@ -177,7 +177,7 @@ QtTesting_getProperty(PyObject* /*self*/, PyObject* args)
}
return Py_BuildValue(const_cast<char*>("s"),
PropertyValue.toAscii().data());
PropertyValue.toLatin1().data());
}
static PyObject*
......@@ -291,7 +291,7 @@ QtTesting_getChildren(PyObject* /*self*/, PyObject* args)
QString ret = QString("[%1]").arg(objs);
return Py_BuildValue(const_cast<char*>("s"),
ret.toAscii().data());
ret.toLatin1().data());
}
static PyObject*
......@@ -344,7 +344,7 @@ QtTesting_invokeMethod(PyObject* /*self*/, PyObject* args)
}
return Py_BuildValue(const_cast<char*>("s"),
PropertyResult.toAscii().data());
PropertyResult.toLatin1().data());
}
static PyMethodDef QtTestingMethods[] = {
......@@ -448,7 +448,7 @@ QString pqPythonEventSource::getProperty(QString& object, QString& prop)
object = QString::null;
return QString();
}
int idx = qobject->metaObject()->indexOfProperty(prop.toAscii().data());
int idx = qobject->metaObject()->indexOfProperty(prop.toLatin1().data());
if(idx == -1)
{
prop = QString::null;
......@@ -490,7 +490,7 @@ void pqPythonEventSource::setProperty(QString& object, QString& prop,
return;
}
int idx = qobject->metaObject()->indexOfProperty(prop.toAscii().data());
int idx = qobject->metaObject()->indexOfProperty(prop.toLatin1().data());
if(idx == -1)
{
prop = QString::null;
......@@ -505,7 +505,7 @@ void pqPythonEventSource::setProperty(QString& object, QString& prop,
{
val = value.split(";");
}
qobject->setProperty(prop.toAscii().data(), val);
qobject->setProperty(prop.toLatin1().data(), val);
}
}
......@@ -596,7 +596,7 @@ QString pqPythonEventSource::invokeMethod(QString& object, QString& method)
}
else
{
if(!QMetaObject::invokeMethod(qobject, method.toAscii().data(),
if(!QMetaObject::invokeMethod(qobject, method.toLatin1().data(),
Q_RETURN_ARG(QVariant, ret)))
{
method = QString::null;
......
......@@ -39,7 +39,7 @@ void pqStdoutEventObserver::onRecordEvent(
const QString& Arguments)
{
printf("event: %s %s %s\n",
Widget.toAscii().data(),
Command.toAscii().data(),
Arguments.toAscii().data());
Widget.toLatin1().data(),
Command.toLatin1().data(),
Arguments.toLatin1().data());
}
......@@ -106,8 +106,8 @@ bool pqTabBarEventPlayer::playEvent(
if (sibling_tab_bar->tabText(cc) == value)
{
std::cout << "DEBUG: Could not find request tab-pane on "
<< pqObjectNaming::GetName(*tab_bar).toAscii().data() << ". Using "
<< pqObjectNaming::GetName(*sibling_tab_bar).toAscii().data() << " instead."
<< pqObjectNaming::GetName(*tab_bar).toLatin1().data() << ". Using "
<< pqObjectNaming::GetName(*sibling_tab_bar).toLatin1().data() << " instead."
<< std::endl;
sibling_tab_bar->setCurrentIndex(cc);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment