...
 
Commits (2)
......@@ -4,8 +4,7 @@ HEADERS += sparqlquerytext.h
SOURCES += main.cpp sparqlquerytext.cpp
#QT += sparql #enable this later
QT += network xml gui
equals(QT_MAJOR_VERSION, 5): QT += widgets
QT += network xml gui widgets
# install # FIXME: install + package examples later
#target.path = $$EXAMPLES_DIR/sparql/dbpedia
......
......@@ -53,11 +53,7 @@ SparqlQueryText::SparqlQueryText(QSparqlConnection& conn, QWidget *parent)
tableView = new QTableView();
tableView->setModel(model);
tableView->resize(1000, 600);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#endif
}
void SparqlQueryText::runQuery()
......
......@@ -40,26 +40,16 @@
****************************************************************************/
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QGuiApplication>
#include <QQuickItem>
#include <QQuickView>
#include <QQmlEngine>
#else
#include <QApplication>
#include <QtDeclarative>
#endif
#include <QtSparql>
#include <QtDBus>
#include <QString>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
typedef QGuiApplication ApplicationType;
typedef QQuickView ViewType;
#else
typedef QApplication ApplicationType;
typedef QDeclarativeView ViewType;
#endif
class ModelLiveChange : public QObject
{
......@@ -127,11 +117,7 @@ int main(int argc, char *argv[])
// they haven't been install
viewQml.engine()->addImportPath("../../../imports");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
viewQml.setSource(QUrl::fromLocalFile("main-qt5.qml"));
#else
viewQml.setSource(QUrl::fromLocalFile("main.qml"));
#endif
// The bindings can be cast back to the appropriate QtSparql classes by setting
// an "objectName" property on them, and casting them, eg :
......
import Qt 4.7
import QtSparql 1.0
Rectangle {
id: mainRectangle
width: 800
height: 400
// this will force the ListView model
// to requery the data
function reload() {
queryModel.reload();
}
Rectangle {
id: contactsRect
width: parent.width
height : parent.height - 50
anchors.top: controlRect.bottom
ListView {
id: contactsView
width: parent.width
height: parent.height
// We'll use a results list model here
// By setting the "objectName" property we can use these models and connections
// in C++, see main.cpp for an example
model: SparqlListModel {
id: "queryModel"
objectName: "queryModel"
// create a new SparqlConnection for the queryModel
connection: SparqlConnection { id:sparqlConnection; objectName:"sparqlConnection"; driver:"QTRACKER_DIRECT" }
// This is the query for the model
query: "select ?u ?firstName ?secondName"+
"{ ?u a nco:PersonContact;"+
"nie:isLogicalPartOf <qml-example>;"+
"nco:nameGiven ?firstName;"+
"nco:nameFamily ?secondName .} order by ?secondName ?firstName"
}
delegate: Item { height: 50; Text { font.pixelSize: 40; text: secondName+","+firstName } }
}
}
// The "NameInput" page,
Rectangle {
id: nameInput
visible: false
width: mainRectangle.width
height: mainRectangle.height
anchors.verticalCenter: parent.verticalCenter
Rectangle {
width: parent.width
height: 300
// This is the button that deals with inserting
// a contact
Rectangle {
// When the button is clicked, insert the data using the "update" function of
// of the sparql connection
MouseArea {
anchors.fill: parent
onClicked: {
var queryString = "insert { "+
"_:u a nco:PersonContact; nie:isLogicalPartOf <qml-example>; "+
"nco:nameGiven $:firstName;"+
"nco:nameFamily $:secondName . }";
var boundValues = { "firstName":firstNameInput.text, "secondName":familyNameInput.text }
sparqlConnection.update(queryString, boundValues);
// clean up
firstNameInput.text = ""
familyNameInput.text = ""
nameInput.visible = false
contactsRect.visible = true
contactsView.visible = true
controlRect.visible = true
}
}
anchors.top: gridView.bottom
anchors.topMargin: 20
anchors.horizontalCenter: gridView.horizontalCenter
color: "red"; width: 75; height: 75
gradient: Gradient {
GradientStop {
position: 0.0
color: "dimgrey"
}
GradientStop {
position: 1.0
color: "darkgrey"
}
}
Text { anchors.centerIn: parent; font.pixelSize: 50; text: "+" }
}
Grid {
id: gridView
columns: 1
spacing: 2
width: parent.width - 50
anchors.horizontalCenter : parent.horizontalCenter
Rectangle {
width: parent.width; height: 50
Text { smooth: true; font.pixelSize: 50; text: "Firstname"; anchors.verticalCenter: parent.verticalCenter}
}
Rectangle {
border.width:5; radius:5; border.color:"black"; width: parent.width; height: 75
TextInput {
id: firstNameInput
smooth: true
font.pixelSize: 50
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 10
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (!firstNameInput.activeFocus) {
firstNameInput.forceActiveFocus()
} else {
firstNameInput.focus = false
}
}
}
onAccepted: { firstNameInput.closeSoftwareInputPanel() }
}
}
Rectangle {
width: parent.width; height: 50
Text { smooth: true; font.pixelSize: 50; text: "Surname"; anchors.verticalCenter: parent.verticalCenter}
}
Rectangle {
border.width:5; radius:5; border.color:"black"; width: parent.width; height: 75
TextInput {
id: familyNameInput
smooth: true
font.pixelSize: 50
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 10
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (!familyNameInput.activeFocus) {
familyNameInput.forceActiveFocus();
} else {
familyNameInput.focus = false;
}
}
}
onAccepted: { familyNameInput.closeSoftwareInputPanel() }
}
}
}
}
}
// the menu bar
Rectangle {
id: controlRect
width: parent.width
height: 50
color: "blue"
gradient: Gradient {
GradientStop {
position: 0.0
color: "dimgrey"
}
GradientStop {
position: 1.0
color: "darkgrey"
}
}
Rectangle {
id: addButton
width: 50
height: 50
anchors.centerIn: parent
color: "red"
border.width: 1
radius: 4
smooth: true
gradient: Gradient {
GradientStop {
position: 0.0
color: !mouseArea.pressed ? activePalette.light : activePalette.button
}
GradientStop {
position: 1.0
color: !mouseArea.pressed ? activePalette.button : activePalette.dark
}
}
SystemPalette { id: activePalette }
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked:
{
if (contactsRect.visible) {
controlRect.visible = false
contactsRect.visible = false
nameInput.visible = true
} else {
contactsRect.visible = true
nameInput.visible = false
}
}
}
Text {
id: text
anchors.centerIn:parent
font.pointSize: 50
smooth: true
text: "+"
color: activePalette.buttonText
}
}
}
}
......@@ -3,9 +3,7 @@ include(../sparql-examples.pri)
SOURCES += main.cpp
#QT += sparql #enable this later
QT += gui dbus
equals(QT_MAJOR_VERSION, 4): QT += declarative
equals(QT_MAJOR_VERSION, 5): QT += quick
QT += gui dbus quick
copy2build.target = $$QTSPARQL_BUILD_TREE/examples/sparql/qmlbindings/main.qml
copy2build.commands = $$QMAKE_COPY $$PWD/main.qml $$QTSPARQL_BUILD_TREE/examples/sparql/qmlbindings
......
......@@ -40,15 +40,10 @@
****************************************************************************/
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QGuiApplication>
#include <QQmlContext>
#include <QQuickItem>
#include <QQuickView>
#else
#include <QApplication>
#include <QtDeclarative>
#endif
#include <QtSparql>
#include <QtDBus>
#include <QString>
......@@ -143,30 +138,17 @@ void ModelLiveChange::gotClick(QString firstName, QString familyName)
int main(int argc, char *argv[])
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QGuiApplication app(argc, argv);
#else
QApplication app(argc, argv);
#endif
// Initialise QML
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QQuickView viewQml;
QQmlContext *ctxt = viewQml.rootContext();
#else
QDeclarativeView viewQml;
QDeclarativeContext *ctxt = viewQml.rootContext();
#endif
// Create the model
QSparqlQueryModel *model = new QSparqlQueryModel();
// Now set the context property for the ListView model to the liveQuery model
ctxt->setContextProperty("contactModel", model);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
viewQml.setSource(QUrl::fromLocalFile("main-qt5.qml"));
#else
viewQml.setSource(QUrl::fromLocalFile("main.qml"));
#endif
ModelLiveChange changeNotifier(model);
......
import Qt 4.7
import QtSparql 1.0
Rectangle {
id: mainRectangle
width: 800
height: 400
// This signal will be emitted, and caught on the c++ side
// we someone enters a new contact
signal addContact(string firstName, string familyName)
Rectangle {
id: contactsRect
width: parent.width
height : parent.height - 50
anchors.top: controlRect.bottom
ListView {
id: contactsView
width: parent.width
height: parent.height
// contactModel will be set from C++
model: contactModel
delegate: Item { height: 50; Text { font.pixelSize: 40; text: secondName+","+firstName } }
}
}
// The "NameInput" page,
Rectangle {
id: nameInput
visible: false
width: mainRectangle.width
height: mainRectangle.height
anchors.verticalCenter: parent.verticalCenter
Rectangle {
width: parent.width
height: 300
// This is the button that deals with inserting
// a contact
Rectangle {
// When the button is clicked, emit the addContact signal with the input
// we can catch and process this on the C++ side
MouseArea {
anchors.fill: parent
onClicked: {
addContact(firstNameInput.text ,familyNameInput.text)
firstNameInput.text = ""
familyNameInput.text = ""
nameInput.visible = false
contactsRect.visible = true
contactsView.visible = true
controlRect.visible = true
}
}
anchors.top: gridView.bottom
anchors.topMargin: 20
anchors.horizontalCenter: gridView.horizontalCenter
color: "red"; width: 75; height: 75
gradient: Gradient {
GradientStop {
position: 0.0
color: "dimgrey"
}
GradientStop {
position: 1.0
color: "darkgrey"
}
}
Text { anchors.centerIn: parent; font.pixelSize: 50; text: "+" }
}
Grid {
id: gridView
columns: 1
spacing: 2
width: parent.width - 50
anchors.horizontalCenter : parent.horizontalCenter
Rectangle {
width: parent.width; height: 50
Text { smooth: true; font.pixelSize: 50; text: "Firstname"; anchors.verticalCenter: parent.verticalCenter}
}
Rectangle {
border.width:5; radius:5; border.color:"black"; width: parent.width; height: 75
TextInput {
id: firstNameInput
smooth: true
font.pixelSize: 50
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 10
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (!firstNameInput.activeFocus) {
firstNameInput.forceActiveFocus()
} else {
firstNameInput.focus = false
}
}
}
onAccepted: { firstNameInput.closeSoftwareInputPanel() }
}
}
Rectangle {
width: parent.width; height: 50
Text { smooth: true; font.pixelSize: 50; text: "Surname"; anchors.verticalCenter: parent.verticalCenter}
}
Rectangle {
border.width:5; radius:5; border.color:"black"; width: parent.width; height: 75
TextInput {
id: familyNameInput
smooth: true
font.pixelSize: 50
anchors.fill: parent
anchors.leftMargin: 10
anchors.topMargin: 10
anchors.verticalCenter: parent.verticalCenter
MouseArea {
anchors.fill: parent
onClicked: {
if (!familyNameInput.activeFocus) {
familyNameInput.forceActiveFocus();
} else {
familyNameInput.focus = false;
}
}
}
onAccepted: { familyNameInput.closeSoftwareInputPanel() }
}
}
}
}
}
// the menu bar
Rectangle {
id: controlRect
width: parent.width
height: 50
color: "blue"
gradient: Gradient {
GradientStop {
position: 0.0
color: "dimgrey"
}
GradientStop {
position: 1.0
color: "darkgrey"
}
}
Rectangle {
id: addButton
width: 50
height: 50
anchors.centerIn: parent
color: "red"
border.width: 1
radius: 4
smooth: true
gradient: Gradient {
GradientStop {
position: 0.0
color: !mouseArea.pressed ? activePalette.light : activePalette.button
}
GradientStop {
position: 1.0
color: !mouseArea.pressed ? activePalette.button : activePalette.dark
}
}
SystemPalette { id: activePalette }
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked:
{
if (contactsRect.visible) {
controlRect.visible = false
contactsRect.visible = false
nameInput.visible = true
} else {
contactsRect.visible = true
nameInput.visible = false
}
}
}
Text {
id: text
anchors.centerIn:parent
font.pointSize: 50
smooth: true
text: "+"
color: activePalette.buttonText
}
}
}
}
......@@ -3,9 +3,7 @@ include(../sparql-examples.pri)
SOURCES += main.cpp
#QT += sparql #enable this later
QT += gui dbus
equals(QT_MAJOR_VERSION, 4): QT += declarative
equals(QT_MAJOR_VERSION, 5): QT += quick
QT += gui dbus quick
copy2build.target = $$QTSPARQL_BUILD_TREE/examples/sparql/qmlquerymodel/main.qml
copy2build.commands = $$QMAKE_COPY $$PWD/main.qml $$QTSPARQL_BUILD_TREE/examples/sparql/qmlquerymodel
......
......@@ -3,8 +3,7 @@ HEADERS = customsparqlmodel.h
SOURCES = customsparqlmodel.cpp \
main.cpp
#QT += sparql #enable this later
QT += gui
equals(QT_MAJOR_VERSION, 5): QT += widgets
QT += gui widgets
# install # FIXME: install + package examples later
#target.path = $$EXAMPLES_DIR/sparql/querymodel
#sources.files = $$SOURCES *.h $$RESOURCES $$FORMS querymodel.pro
......
include(../../shared.pri)
equals(QT_MAJOR_VERSION, 4): LIBS += -lQtSparql
equals(QT_MAJOR_VERSION, 5): LIBS += -lQt5Sparql
LIBS += -lQt5Sparql
QMAKE_RPATHDIR = $$QTSPARQL_BUILD_TREE/$$QTSPARQL_INSTALL_LIB $$QMAKE_RPATHDIR
EXAMPLES_DIR =
......
......@@ -4,12 +4,6 @@
include(shared.pri)
lessThan(QT_MAJOR_VERSION, 5) {
lessThan(QT_MAJOR_VERSION, 4) | lessThan(QT_MINOR_VERSION, 7) {
error("QtSparql requires Qt 4.7 or newer but Qt $$[QT_VERSION] was detected.")
}
}
TEMPLATE = subdirs
CONFIG += ordered
......
#we need to explicitly set the include path for any Qt Includes now, add them here
#then we can add the base include path after we've included the headers from the build tree
equals(QT_MAJOR_VERSION, 4) {
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtCore $$[QT_INSTALL_HEADERS]/QtXml $$[QT_INSTALL_HEADERS]/QtNetwork $$[QT_INSTALL_HEADERS]/QtDeclarative $$[QT_INSTALL_HEADERS]/QtTest $$[QT_INSTALL_HEADERS]/QtGui $$[QT_INSTALL_HEADERS]/QtDBus \
$$QTSPARQL_BUILD_TREE/include $$QTSPARQL_BUILD_TREE/include/QtSparql/ \
$$[QT_INSTALL_HEADERS]
}
equals(QT_MAJOR_VERSION, 5) {
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtCore $$[QT_INSTALL_HEADERS]/QtXml $$[QT_INSTALL_HEADERS]/QtNetwork $$[QT_INSTALL_HEADERS]/QtQml $$[QT_INSTALL_HEADERS]/QtQuick $$[QT_INSTALL_HEADERS]/QtTest $$[QT_INSTALL_HEADERS]/QtGui $$[QT_INSTALL_HEADERS]/QtDBus \
$$QTSPARQL_BUILD_TREE/include $$QTSPARQL_BUILD_TREE/include/Qt5Sparql/ \
$$[QT_INSTALL_HEADERS]
}
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtCore $$[QT_INSTALL_HEADERS]/QtXml $$[QT_INSTALL_HEADERS]/QtNetwork $$[QT_INSTALL_HEADERS]/QtQml $$[QT_INSTALL_HEADERS]/QtQuick $$[QT_INSTALL_HEADERS]/QtTest $$[QT_INSTALL_HEADERS]/QtGui $$[QT_INSTALL_HEADERS]/QtDBus \
$$QTSPARQL_BUILD_TREE/include $$QTSPARQL_BUILD_TREE/include/Qt5Sparql/ \
$$[QT_INSTALL_HEADERS]
QT = core
......@@ -25,12 +18,5 @@ VERSION = 0.2.6
# for documentation
DOC_VERSION = 0.2.6
equals(QT_MAJOR_VERSION, 4) {
LIBRARYNAME = QtSparql
PACKAGENAME = libqtsparql
}
equals(QT_MAJOR_VERSION, 5) {
LIBRARYNAME = Qt5Sparql
PACKAGENAME = libqt5sparql
}
LIBRARYNAME = Qt5Sparql
PACKAGENAME = libqt5sparql
......@@ -27,20 +27,14 @@ coverage {
QMAKE_EXTRA_TARGETS += coverage
}
equals(QT_MAJOR_VERSION, 4): PLUGIN_TYPE = declarative
target.path = $$QTSPARQL_INSTALL_IMPORTS/QtSparql
QT = core
equals(QT_MAJOR_VERSION, 4): QT *= declarative
equals(QT_MAJOR_VERSION, 5): {
QT *= qml
DEFINES *= QT_VERSION_5
}
QT *= qml
DEFINES *= QT_VERSION_5
INSTALLS += target
equals(QT_MAJOR_VERSION, 4): LIBS += -lQtSparql
equals(QT_MAJOR_VERSION, 5): LIBS += -lQt5Sparql
LIBS += -lQt5Sparql
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
DESTDIR = $$QTSPARQL_BUILD_TREE/imports/QtSparql
......
......@@ -46,9 +46,7 @@ QT_BEGIN_NAMESPACE
class QSPARQL_ENDPOINTDriverPlugin : public QSparqlDriverPlugin
{
Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.nemomobile.QtSparql.EndpointDriverInterface")
#endif
public:
QSPARQL_ENDPOINTDriverPlugin();
......@@ -78,11 +76,6 @@ QStringList QSPARQL_ENDPOINTDriverPlugin::keys() const
return l;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_STATIC_PLUGIN(QSPARQL_ENDPOINTDriverPlugin)
Q_EXPORT_PLUGIN2(qsparqlendpoint, QSPARQL_ENDPOINTDriverPlugin)
#endif
QT_END_NAMESPACE
#include "main.moc"
......@@ -3,8 +3,7 @@ TEMPLATE = lib
CONFIG += qt plugin
QT = core
DESTDIR = $$QTSPARQL_BUILD_TREE/plugins/sparqldrivers
equals(QT_MAJOR_VERSION, 4): LIBS += -lQtSparql
equals(QT_MAJOR_VERSION, 5): LIBS += -lQt5Sparql
LIBS += -lQt5Sparql
target.path = $$QTSPARQL_INSTALL_PLUGINS/sparqldrivers
......
......@@ -46,9 +46,7 @@ QT_BEGIN_NAMESPACE
class QTrackerDriverPlugin : public QSparqlDriverPlugin
{
Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.nemomobile.QtSparql.TrackerDriverInterface")
#endif
public:
QTrackerDriverPlugin();
......@@ -78,11 +76,6 @@ QStringList QTrackerDriverPlugin::keys() const
return l;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_STATIC_PLUGIN(QTrackerDriverPlugin)
Q_EXPORT_PLUGIN2(qsparqltracker, QTrackerDriverPlugin)
#endif
QT_END_NAMESPACE
#include "main.moc"
......@@ -46,9 +46,7 @@ QT_BEGIN_NAMESPACE
class QTrackerDirectDriverPlugin : public QSparqlDriverPlugin
{
Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.nemomobile.QtSparql.TrackerDirectDriverInterface")
#endif
public:
QTrackerDirectDriverPlugin();
......@@ -78,11 +76,6 @@ QStringList QTrackerDirectDriverPlugin::keys() const
return l;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_STATIC_PLUGIN(QTrackerDirectDriverPlugin)
Q_EXPORT_PLUGIN2(qsparqltrackerdirect, QTrackerDirectDriverPlugin)
#endif
QT_END_NAMESPACE
#include "main.moc"
......@@ -46,9 +46,7 @@ QT_BEGIN_NAMESPACE
class QVirtuosoDriverPlugin : public QSparqlDriverPlugin
{
Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.nemomobile.QtSparql.VirtuosoDriverInterface")
#endif
public:
QVirtuosoDriverPlugin();
......@@ -78,11 +76,6 @@ QStringList QVirtuosoDriverPlugin::keys() const
return l;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_STATIC_PLUGIN(QVirtuosoDriverPlugin)
Q_EXPORT_PLUGIN2(qsparqlvirtuoso, QVirtuosoDriverPlugin)
#endif
QT_END_NAMESPACE
#include "main.moc"
SOURCES += declarative/qsparqlsparqlconnection.cpp declarative/qsparqlsparqllistmodel.cpp
HEADERS += declarative/qsparqlsparqlconnection_p.h declarative/qsparqlsparqlconnectionoptions_p.h declarative/qsparqlsparqllistmodel_p.h
equals(QT_MAJOR_VERSION, 4) {
QT += declarative
}
equals(QT_MAJOR_VERSION, 5) {
QT += qml
DEFINES *= QT_VERSION_5
}
QT += qml
DEFINES *= QT_VERSION_5
......@@ -55,9 +55,7 @@
#include <QtCore/qeventloop.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qurl.h>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtCore/qurlquery.h>
#endif
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtNetwork/qnetworkrequest.h>
......@@ -422,37 +420,23 @@ EndpointResult* EndpointDriver::exec(const QString& query, QSparqlQuery::Stateme
bool EndpointResult::exec(const QString& query, QSparqlQuery::StatementType type, const QString& prefixes)
{
QUrl queryUrl(d->driverPrivate->url);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QUrlQuery urlQuery(queryUrl);
urlQuery.addQueryItem(QLatin1String("query"), prefixes + query);
#else
queryUrl.addQueryItem(QLatin1String("query"), prefixes + query);
#endif
setQuery(query);
setStatementType(type);
// Virtuoso protocol extension options - timeout and maxrows
QVariant timeout = d->driverPrivate->options.option(QLatin1String("timeout"));
if (timeout.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
urlQuery.addQueryItem(QLatin1String("timeout"), timeout.toString());
#else
queryUrl.addQueryItem(QLatin1String("timeout"), timeout.toString());
#endif
}
QVariant maxrows = d->driverPrivate->options.option(QLatin1String("maxrows"));
if (maxrows.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
urlQuery.addQueryItem(QLatin1String("maxrows"), maxrows.toString());
#else
queryUrl.addQueryItem(QLatin1String("maxrows"), maxrows.toString());
#endif
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
queryUrl.setQuery(urlQuery);
#endif
// qDebug() << "Real url to run.... " << queryUrl.toString();
......
......@@ -57,15 +57,9 @@
Q_DECLARE_METATYPE(QVector<QStringList>)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#define ATOMIC_INT_IS_ZERO(val) ((val).load() == 0)
#define SET_ATOMIC_INT(val, n) (val).store(n)
#define ATOMIC_INT_VALUE(val) (val).load()
#else
#define ATOMIC_INT_IS_ZERO(val) !(val)
#define SET_ATOMIC_INT(val, n) (val) = n
#define ATOMIC_INT_VALUE(val) static_cast<int>(val)
#endif
/*
Allows a metatype to be declared for a type containing commas.
......
......@@ -46,20 +46,12 @@ namespace AtomicIntOperations {
inline void setValue(QAtomicInt &v, int n)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
v.store(n);
#else
v = n;
#endif
}
inline int getValue(const QAtomicInt &v)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
return v.load();
#else
return static_cast<int>(v);
#endif
}
}
......
......@@ -212,9 +212,6 @@ void QSparqlQueryModelPrivate::findRoleNames()
Q_FOREACH(QString word, uniqueNames) {
roleNames[roleCounter++] = word.toLatin1();
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
q->setRoleNames(roleNames);
#endif
} else {
qWarning() << "QSparqlQueryModel: Invalid Query";
}
......@@ -603,11 +600,9 @@ QModelIndex QSparqlQueryModel::indexInQuery(const QModelIndex &item) const
item.internalPointer());
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QHash<int, QByteArray> QSparqlQueryModel::roleNames() const
{
return d->roleNames;
}
#endif
QT_END_NAMESPACE
......@@ -89,9 +89,7 @@ public:
QSparqlError lastError() const;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
virtual QHash<int, QByteArray> roleNames() const;
#endif
Q_SIGNALS:
void finished();
......
......@@ -66,9 +66,7 @@ public:
SparqlConnectionOptions *options;
int lastRowCount;
QSparqlResultsList::Status status;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QHash<int, QByteArray> roleNames;
#endif
};
QSparqlResultsList::QSparqlResultsList(QObject *parent) :
......@@ -141,12 +139,8 @@ void QSparqlResultsList::queryData(int rowCount)
QAbstractItemModel::beginInsertRows(QModelIndex(), d->lastRowCount, rowCount - 1);
if (d->lastRowCount == 0 && d->result->first()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QHash<int, QByteArray> &roleNames = d->roleNames;
roleNames = QAbstractItemModel::roleNames();
#else
QHash<int, QByteArray> roleNames = QAbstractItemModel::roleNames();
#endif
QSparqlResultRow resultRow = d->result->current();
// Create two sets of declarative variables from the variable names used
......@@ -161,10 +155,6 @@ void QSparqlResultsList::queryData(int rowCount)
for (int i = 0; i < resultRow.count(); i++) {
roleNames.insert((Qt::UserRole + 1) + i + resultRow.count(), QByteArray("$") + resultRow.binding(i).name().toLatin1());
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(roleNames);
#endif
}
d->lastRowCount = rowCount;
......@@ -230,10 +220,7 @@ QString QSparqlResultsList::errorString() const
return d->result->lastError().message();
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QHash<int, QByteArray> QSparqlResultsList::roleNames() const
{
return d->roleNames;
}
#endif
......@@ -87,10 +87,8 @@ public:
Status status() const;
Q_INVOKABLE QString errorString() const;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
virtual QHash<int, QByteArray> roleNames() const;
#endif
public Q_SLOTS:
void reload();
......
......@@ -2,8 +2,7 @@ include(../../shared.pri)
TEMPLATE = lib
CONFIG += create_pc create_prl
equals(QT_MAJOR_VERSION, 4): TARGET = QtSparql
equals(QT_MAJOR_VERSION, 5): TARGET = Qt5Sparql
TARGET = Qt5Sparql
DESTDIR = $$QTSPARQL_BUILD_TREE/$$QTSPARQL_INSTALL_LIB
DEFINES += QT_BUILD_SPARQL_LIB
DEFINES += QT_NO_USING_NAMESPACE
......@@ -35,8 +34,7 @@ create_mkspecs_dirhook.depends = create_mkspecs_dir
create_mkspecs_dirhook.target = Makefile
QMAKE_EXTRA_TARGETS += create_mkspecs_dirhook
equals(QT_MAJOR_VERSION, 4): PRF_INPUT_FILE=$$QTSPARQL_SOURCE_TREE/mkspecs/features/qtsparql.prf.in
equals(QT_MAJOR_VERSION, 5): PRF_INPUT_FILE=$$QTSPARQL_SOURCE_TREE/mkspecs/features/qt5/qtsparql.prf.in
PRF_INPUT_FILE=$$QTSPARQL_SOURCE_TREE/mkspecs/features/qt5/qtsparql.prf.in
PRF_OUTPUT_FILE=$$QTSPARQL_BUILD_TREE/mkspecs/features/qtsparql.prf
install_prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
install_prf.files = $$PRF_OUTPUT_FILE
......@@ -56,12 +54,10 @@ INSTALLS += \
target.path = $$QTSPARQL_INSTALL_LIBS
QMAKE_PKGCONFIG_PREFIX = $$QTSPARQL_INSTALL_PREFIX
equals(QT_MAJOR_VERSION, 4): QMAKE_PKGCONFIG_REQUIRES = QtCore QtNetwork
equals(QT_MAJOR_VERSION, 5): QMAKE_PKGCONFIG_REQUIRES = Qt5Core Qt5Network
QMAKE_PKGCONFIG_REQUIRES = Qt5Core Qt5Network
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_CFLAGS = -I$$QTSPARQL_INSTALL_HEADERS
equals(QT_MAJOR_VERSION, 4): QMAKE_PKGCONFIG_NAME = QtSparql
equals(QT_MAJOR_VERSION, 5): QMAKE_PKGCONFIG_NAME = Qt5Sparql
QMAKE_PKGCONFIG_NAME = Qt5Sparql
QMAKE_PKGCONFIG_DESCRIPTION = "Library for accessing RDF stores."
coverage {
......
......@@ -45,20 +45,12 @@ public:
MessageRecorder()
{
selfPtr = this;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
prevMsgHandler = qInstallMessageHandler(&MessageRecorder::msgHandler);
#else
prevMsgHandler = qInstallMsgHandler(&MessageRecorder::msgHandler);
#endif
}
~MessageRecorder()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qInstallMessageHandler(prevMsgHandler);
#else
qInstallMsgHandler(prevMsgHandler);
#endif
selfPtr = 0;
}
......@@ -85,27 +77,15 @@ private:
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
static void msgHandler(QtMsgType type, const QMessageLogContext &ctxt, const QString &msg)
#else
static void msgHandler(QtMsgType type, const char *msg)
#endif
{
if (!selfPtr->handleMsg(type, msg)) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
(*selfPtr->prevMsgHandler)(type, ctxt, msg);
#else
(*selfPtr->prevMsgHandler)(type, msg);
#endif
}
}
private:
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QtMessageHandler prevMsgHandler;
#else
QtMsgHandler prevMsgHandler;
#endif
QSet<QtMsgType> msgsToRecord;
QMap<QtMsgType, QStringList> msgs;
};
......
......@@ -172,11 +172,7 @@ void tst_QSparqlEndpoint::query_with_error()
void tst_QSparqlEndpoint::select_query_server_not_responding()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QSKIP("Neither endpoint driver nor QNetworkAccessManager has timeout functionality");
#else
QSKIP("Neither endpoint driver nor QNetworkAccessManager has timeout functionality", SkipAll);
#endif
// When connection is established but server doesn't respond, client (endpoint driver) hangs
QSparqlConnectionOptions options;
options.setPort(8080);
......
......@@ -2,9 +2,7 @@ include(../sparqltest.pri)
CONFIG += qt warn_on console depend_includepath
# Without 'gui' QTEST_MAIN() would instantiate QCoreApplication instead of
# QApplication which is needed for the declarative stuff to work.
QT += testlib gui
equals(QT_MAJOR_VERSION, 4): QT += declarative
equals(QT_MAJOR_VERSION, 5): QT += qml
QT += testlib gui qml
SOURCES += tst_qsparql_qmlbindings.cpp
......@@ -18,7 +16,6 @@ QMAKE_EXTRA_TARGETS += check memcheck
#QT = sparql # enable this later
equals(QT_MAJOR_VERSION, 4): install_qml.files = qsparqlconnection.qml qsparqlresultlist.qml qsparqllegacy.qml
equals(QT_MAJOR_VERSION, 5): install_qml.files = qsparqlconnection-qt5.qml qsparqlresultlist-qt5.qml qsparqllegacy-qt5.qml
install_qml.files = qsparqlconnection-qt5.qml qsparqlresultlist-qt5.qml qsparqllegacy-qt5.qml
install_qml.path = $$PREFIX/$$QTSPARQL_INSTALL_LIB/$$PACKAGENAME-tests/
INSTALLS += install_qml
/****************************************************************************
**
** Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (ivan.frade@nokia.com)
**
** This file is part of the test suite of the QtSparql module (not yet part of the Qt Toolkit).
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at ivan.frade@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
import Qt 4.7
import QtSparql 1.0
Rectangle {
id: rootComp
property string setDriver: "QTRACKER_DIRECT"
property string queryString: sparqlQueryString
property int portNumber: setPortNumber
property string host: setHost
property int connectionStatus: 0
property int resultReadyCalled: 0
property variant resultFromSlot: 0
signal resultReadySignal();
SparqlConnection {
objectName: "connectionWithOptions"
id: sparqlConnection
driver: setDriver
options: SparqlConnectionOptions { id:connectionOptions; hostName: host; port: portNumber }
onStatusChanged: connectionStatus = sparqlConnection.status
onResultReady: resultReadySignal()
}
function runSelectQuery()
{
return sparqlConnection.select(queryString);
}
function runAskQuery(query)
{
return sparqlConnection.ask(query);
}
function runAskQueryAsync(query)
{
sparqlConnection.ask(query, true);
}
function runConstructQuery()
{
// will result in error, since construct queries are not
// supported by tracker
return sparqlConnection.construct(queryString);
}
function runSelectQueryAsync()
{
sparqlConnection.resultReady.connect(asyncResultReady);
sparqlConnection.select(queryString, true);
}
function asyncResultReady(result)
{
resultFromSlot = result;
resultReadySignal();
}
// returns from the result property
function returnResults()
{
return sparqlConnection.result;
}
function returnResultsFromSlot()
{
return resultFromSlot;
}
function returnConnectionOptions() {
var hash = {};
for (var prop in connectionOptions) {
hash[prop] = connectionOptions[prop];
}
return hash;
}
function insertContact() {
var insertQuery = "insert { <qmlInsert> a nco:PersonContact; "+
"nie:isLogicalPartOf <qsparql-qml-tests>; "+
"nco:nameGiven 'QML INSERT' }";
sparqlConnection.update(insertQuery);
}
function insertBoundContact() {
var insertQuery = "insert { <qmlInsert-bound> a nco:PersonContact; "+
"nie:isLogicalPartOf <qsparql-qml-tests>; "+
"nco:nameGiven ?:nameGiven; "+
"nco:nameFamily ?:nameFamily }";
var boundValues = { "nameFamily":"QML Family", "nameGiven":"QML Insert" };
sparqlConnection.update(insertQuery, boundValues);
}
function deleteBoundContact() {
var deleteQuery = "delete { ?u a nco:PersonContact } "+
"where { ?u a nco:PersonContact; nco:nameGiven ?:ng; nco:nameFamily ?:nf } ";
var boundValues = { "ng":"QML Insert", "nf":"QML Family" };
sparqlConnection.update(deleteQuery, boundValues);
}
function selectBoundContact() {
var selectQuery = "select ?u { ?u a nco:PersonContact; "+
"nie:isLogicalPartOf <qsparql-qml-tests>; "+
"nco:nameGiven ?:nameGiven; nco:nameFamily ?:nameFamily}";
var boundValues = { "nameFamily":"QML Family", "nameGiven":"QML Insert" };
return sparqlConnection.select(selectQuery, boundValues);
}
function askBoundContact() {
var askQuery = "ask { ?u a nco:PersonContact; "+
"nco:nameGiven ?:ng;"+
"nco:nameFamily ?:nf .}";
var boundValues = { "ng":"QML Insert", "nf":"QML Family" };
return sparqlConnection.ask(askQuery, boundValues);
}
function insertContactAsync() {
var insertQuery = "insert { <qmlInsert> a nco:PersonContact; "+
"nie:isLogicalPartOf <qsparql-qml-tests>; "+
"nco:nameGiven 'QML INSERT' }";
sparqlConnection.update(insertQuery, true);
}
function deleteContact() {
var deleteQuery = "delete { <qmlInsert> a nco:PersonContact } "+
"where { <qmlInsert> a nco:PersonContact } ";
sparqlConnection.update(deleteQuery);
}
function deleteContactAsync() {
var deleteQuery = "delete { <qmlInsert> a nco:PersonContact } "+
"where { <qmlInsert> a nco:PersonContact } ";
sparqlConnection.update(deleteQuery, true);
}
function getStatus()
{
// return the property value here
// that way we can also check to make sure
// the notify for Status is working
return connectionStatus
}
function getLastError()
{
return sparqlConnection.errorString();
}
}
/****************************************************************************
**
** Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (ivan.frade@nokia.com)
**
** This file is part of the test suite of the QtSparql module (not yet part of the Qt Toolkit).
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at ivan.frade@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
import Qt 4.7
import QtSparql 0.1
ListView {
width: 1000; height: 600
model: SparqlResultsList {
options: SparqlConnectionOptions {
driverName: "QTRACKER_DIRECT"
hostName: "dbpedia.org"
}
query: "SELECT $predicate $thing WHERE { <http://dbpedia.org/resource/The_Beatles> $predicate $thing . }"
}
delegate: Text { text: "Data: " + $predicate + ", " + $thing }
}
/****************************************************************************
**
** Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (ivan.frade@nokia.com)
**
** This file is part of the test suite of the QtSparql module (not yet part of the Qt Toolkit).
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at ivan.frade@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
import Qt 4.7
import QtSparql 1.0
Rectangle {
id: rootComp
property string setDriver: "QTRACKER_DIRECT"
property string queryString: sparqlQueryString
property int modelStatus: 0
signal modelCountChanged()
signal modelStatusReady()
ListView {
id: contactsView
width: parent.width
height: parent.height
model: SparqlListModel {
id: sparqlResultList
onCountChanged: { modelCountChanged() }
objectName: "queryModel"
// load existing query model
connection: sparqlConnection
query: sparqlQueryString
onStatusChanged: { modelStatusChanged() }
}
delegate: Item { height: 50; }
}
SparqlConnection {
objectName: "sparqlConnection"
id: sparqlConnection
driver: setDriver
}
function modelStatusChanged()
{
modelStatus = sparqlResultList.status;
if (modelStatus == SparqlListModel.Ready) {
modelStatusReady();
}
}
function getCount()
{
var resultListCount = sparqlResultList.count;
return resultListCount
}
function getStatus()
{
// return the property value here
// that way we can also check to make sure
// the notify for Status is working
return modelStatus
}
function reloadModel()
{
sparqlResultList.reload();
}
function setQuery(query)
{
sparqlResultList.query = query;
}
function getRow(row)
{
return sparqlResultList.get(row);
}
}
......@@ -39,15 +39,10 @@
#include <QtTest/QtTest>
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QtQml/qqml.h>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QQmlContext>
#else
#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative>
#endif
#include <private/qsparqlsparqlconnection_p.h>
#include <QtSparql>
......@@ -93,15 +88,9 @@ namespace {
// QML stuff
enum Status { Null, Ready, Loading, Error };
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QQmlEngine *engine;
QQmlComponent *component;
QQmlContext *context;
#else
QDeclarativeEngine *engine;
QDeclarativeComponent *component;
QDeclarativeContext *context;
#endif
QObject* qmlObject;
const QString contactSelectQuery =
......@@ -154,17 +143,9 @@ bool loadQmlFile(QString fileName, QList<QPair<QString, QVariant> > contextPrope
{
QFileInfo fileInfo(qApp->arguments()[0]);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
engine = new QQmlEngine();
#else
engine = new QDeclarativeEngine();
#endif
engine->addImportPath("../../../imports");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
component = new QQmlComponent(engine, QUrl::fromLocalFile(fileInfo.absolutePath()+"/"+fileName+"-qt5.qml"));
#else
component = new QDeclarativeComponent(engine, QUrl::fromLocalFile(fileInfo.absolutePath()+"/"+fileName+".qml"));
#endif
context = engine->rootContext();
for(int i=0;i<contextProperties.size();i++) {
......
......@@ -165,13 +165,8 @@ tst_QSparqlThreading::tst_QSparqlThreading()
void tst_QSparqlThreading::joinThreads()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
threadJoin.acquire(threadJoinCount.load());
threadJoinCount.store(0);
#else
threadJoin.acquire(threadJoinCount);
threadJoinCount = 0;
#endif
}
bool tst_QSparqlThreading::waitForSignal(QObject *obj, const char *signal, int delay)
......
......@@ -70,16 +70,10 @@ private slots:
namespace {
int testLogLevel = QtWarningMsg;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msgString)
#else
void myMessageOutput(QtMsgType type, const char *msg)
#endif
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const QByteArray ba(msgString.toLocal8Bit());
const char *msg(ba.constData());
#endif
switch (type) {
case QtDebugMsg:
if (testLogLevel <= 0)
......@@ -114,11 +108,7 @@ void tst_QSparqlTracker::initTestCase()
// For running the test without installing the plugins. Should work in
// normal and vpath builds.
QCoreApplication::addLibraryPath("../../../plugins");
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qInstallMessageHandler(myMessageOutput);
#else
qInstallMsgHandler(myMessageOutput);
#endif
// clean any remainings
cleanupTestCase();
......
include(../../shared.pri)
equals(QT_MAJOR_VERSION, 4): LIBS += -lQtSparql
equals(QT_MAJOR_VERSION, 5): {
LIBS += -lQt5Sparql
DEFINES *= QT_VERSION_5
}
LIBS += -lQt5Sparql
DEFINES *= QT_VERSION_5
QMAKE_RPATHDIR = $$QTSPARQL_BUILD_TREE/$$QTSPARQL_INSTALL_LIB $$QMAKE_RPATHDIR
target.path = $$QTSPARQL_INSTALL_TESTS # to be changed when we are part of qt
INSTALLS += target
......
......@@ -46,16 +46,10 @@ namespace {
int testLogLevel = QtWarningMsg;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msgString)
#else
void myMessageOutput(QtMsgType type, const char *msg)
#endif
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const QByteArray ba(msgString.toLocal8Bit());
const char *msg(ba.constData());
#endif
switch (type) {
case QtDebugMsg:
if (testLogLevel <= 0)
......@@ -112,11 +106,7 @@ QSparqlResult* TrackerDirectCommon::runQuery(QSparqlConnection &conn, const QSpa
void TrackerDirectCommon::installMsgHandler()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QtMessageHandler prevHandler = qInstallMessageHandler(myMessageOutput);
#else
QtMsgHandler prevHandler = qInstallMsgHandler(myMessageOutput);
#endif
if (!origMsgHandler)
origMsgHandler = prevHandler;
}
......@@ -186,24 +176,14 @@ bool TrackerDirectCommon::cleanData()
void TrackerDirectCommon::testError(const QString& msg)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QtMessageHandler currMsgHandler = 0;
if (origMsgHandler != 0)
currMsgHandler = qInstallMessageHandler(origMsgHandler);
#else
QtMsgHandler currMsgHandler = 0;
if (origMsgHandler != 0)
currMsgHandler = qInstallMsgHandler(origMsgHandler);
#endif
qWarning() << "Test error:" << msg;
if (currMsgHandler != 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qInstallMessageHandler(currMsgHandler);
#else
qInstallMsgHandler