Commit 31cfc6ef authored by Matti Lehtimäki's avatar Matti Lehtimäki

[libqtsparql] Remove obsolete Qt4 support. Contributes to JB#38781

parent 39389334
......@@ -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,12 +3,10 @@ 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
copy2build.target = $$QTSPARQL_BUILD_TREE/examples/sparql/qmlbindings/main-qt5.qml
copy2build.commands = $$QMAKE_COPY $$PWD/main-qt5.qml $$QTSPARQL_BUILD_TREE/examples/sparql/qmlbindings
QMAKE_EXTRA_TARGETS += copy2build
copy2buildhook.depends = copy2build
......
......@@ -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,12 +3,10 @@ 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
copy2build.target = $$QTSPARQL_BUILD_TREE/examples/sparql/qmlquerymodel/main-qt5.qml
copy2build.commands = $$QMAKE_COPY $$PWD/main-qt5.qml $$QTSPARQL_BUILD_TREE/examples/sparql/qmlquerymodel
QMAKE_EXTRA_TARGETS += copy2build
copy2buildhook.depends = copy2build
......
......@@ -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"