WIP: Qt5 compatibility

This commit is contained in:
Matthias Koefferlein 2018-05-31 17:54:29 +02:00
parent b91a3b5cad
commit ecc0520ffb
20 changed files with 96 additions and 65 deletions

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtCore/gsiQtExternals.h"
# else
# include "../qt4/QtCore/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtCore/gsiQtExternals.h"
#else
# include "../qt4/QtCore/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtDesigner/gsiQtExternals.h"
# else
# include "../qt4/QtDesigner/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtDesigner/gsiQtExternals.h"
#else
# include "../qt4/QtDesigner/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtGui/gsiQtExternals.h"
# else
# include "../qt4/QtGui/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtGui/gsiQtExternals.h"
#else
# include "../qt4/QtGui/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,9 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtMultimedia/gsiQtExternals.h"
# else
#if QT_VERSION >= 0x050000
# include "../qt5/QtMultimedia/gsiQtExternals.h"
#else
// no present in Qt4
# endif
# define FORCE_LINK_GSI_QTMULTIMEDIA
#endif

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtNetwork/gsiQtExternals.h"
# else
# include "../qt4/QtNetwork/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtNetwork/gsiQtExternals.h"
#else
# include "../qt4/QtNetwork/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,9 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtPrintSupport/gsiQtExternals.h"
# else
#if QT_VERSION >= 0x050000
# include "../qt5/QtPrintSupport/gsiQtExternals.h"
#else
// no present in Qt4
# endif
# define FORCE_LINK_GSI_QTPRINTSUPPORT
#endif

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtSql/gsiQtExternals.h"
# else
# include "../qt4/QtSql/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtSql/gsiQtExternals.h"
#else
# include "../qt4/QtSql/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,9 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtSvg/gsiQtExternals.h"
# else
#if QT_VERSION >= 0x050000
# include "../qt5/QtSvg/gsiQtExternals.h"
#else
// no present in Qt4
# endif
# define FORCE_LINK_GSI_QTSVG
#endif

View File

@ -20,8 +20,9 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtWidgets/gsiQtExternals.h"
# else
#if QT_VERSION >= 0x050000
# include "../qt5/QtWidgets/gsiQtExternals.h"
#else
// no present in Qt4
# endif
# define FORCE_LINK_GSI_QTWIDGETS
#endif

View File

@ -20,8 +20,8 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtXml/gsiQtExternals.h"
# else
# include "../qt4/QtXml/gsiQtExternals.h"
# endif
#if QT_VERSION >= 0x050000
# include "../qt5/QtXml/gsiQtExternals.h"
#else
# include "../qt4/QtXml/gsiQtExternals.h"
#endif

View File

@ -20,8 +20,9 @@
*/
# if defined(HAVE_QT5)
# include "../qt5/QtXmlPatterns/gsiQtExternals.h"
# else
#if QT_VERSION >= 0x050000
# include "../qt5/QtXmlPatterns/gsiQtExternals.h"
#else
// Not present in Qt4
# endif
# define FORCE_LINK_GSI_QTXMLPATTERNS
#endif

View File

@ -25,6 +25,7 @@
#include "laySignalHandler.h"
#include "gsiDecl.h"
#include "gsiQtGuiExternals.h"
#include "gsiQtWidgetsExternals.h" // for Qt5
#include "gsiQtCoreExternals.h"
#include "gsiQtXmlExternals.h"
#include "tlArch.h"
@ -32,6 +33,7 @@
// this is here *once*
FORCE_LINK_GSI_QTCORE
FORCE_LINK_GSI_QTGUI
FORCE_LINK_GSI_QTWIDGETS
// required because the GSI bindings use QDomDocument
FORCE_LINK_GSI_QTXML

View File

@ -27,6 +27,7 @@
#include "laybasicCommon.h"
#include "gsiDecl.h"
#include "gsiQtGuiExternals.h"
#include "gsiQtWidgetsExternals.h"
namespace tl
{

View File

@ -23,6 +23,7 @@
#include "gsiDecl.h"
#include "gsiSignals.h"
#include "gsiQtGuiExternals.h"
#include "gsiQtWidgetsExternals.h" // for Qt5
#include "layMainWindow.h"
namespace gsi

View File

@ -46,7 +46,7 @@ namespace lay
static std::string module_doc_path (const std::string &m)
{
return "/code/index.xml?module=" + m;
return "/code/module_" + m + ".xml";
}
static std::string class_doc_path (const std::string &c)
@ -448,15 +448,13 @@ GSIHelpProvider::get (const std::string &path) const
QUrl url = QUrl::fromEncoded (path.c_str ());
QString url_path = url.path ();
QRegExp class_doc_url (QString::fromUtf8 ("^/code/class_(.*)\\.xml$"));
QRegExp module_index_url (QString::fromUtf8 ("^/code/module_(.*)\\.xml$"));
std::string text;
if (url_path == QString::fromUtf8 ("/code/index.xml")) {
if (url.hasQueryItem (QString::fromUtf8 ("module"))) {
QString module = url.queryItemValue (QString::fromUtf8 ("module"));
text = produce_class_index (module.toUtf8 ().constData ());
} else {
text = produce_class_index (0);
}
text = produce_class_index (0);
} else if (module_index_url.indexIn (url_path) == 0) {
text = produce_class_index (tl::to_string (module_index_url.cap (1)).c_str ());
} else if (class_doc_url.indexIn (url_path) == 0) {
text = produce_class_doc (tl::to_string (class_doc_url.cap (1)));
} else {

View File

@ -86,7 +86,7 @@ ConfirmationDialog::mark_fetching (const std::string &name)
list->scrollToItem (i->second);
for (int c = 0; c < list->columnCount (); ++c) {
i->second->setData (c, Qt::BackgroundColorRole, QColor (224, 244, 244));
i->second->setData (c, Qt::TextColorRole, Qt::blue);
i->second->setData (c, Qt::TextColorRole, QColor (Qt::blue));
}
i->second->setData (1, Qt::DisplayRole, tr ("FETCHING"));
}
@ -102,7 +102,7 @@ ConfirmationDialog::mark_error (const std::string &name)
list->scrollToItem (i->second);
for (int c = 0; c < list->columnCount (); ++c) {
i->second->setData (c, Qt::BackgroundColorRole, QColor (255, 224, 244));
i->second->setData (c, Qt::TextColorRole, Qt::black);
i->second->setData (c, Qt::TextColorRole, QColor (Qt::black));
}
i->second->setData (1, Qt::DisplayRole, tr ("ERROR"));
}
@ -118,7 +118,7 @@ ConfirmationDialog::mark_success (const std::string &name)
list->scrollToItem (i->second);
for (int c = 0; c < list->columnCount (); ++c) {
i->second->setData (c, Qt::BackgroundColorRole, QColor (160, 255, 160));
i->second->setData (c, Qt::TextColorRole, Qt::black);
i->second->setData (c, Qt::TextColorRole, QColor (Qt::black));
}
i->second->setData (1, Qt::DisplayRole, tr ("INSTALLED"));
}

View File

@ -23,6 +23,7 @@
#include "gsiDecl.h"
#include "gsiDeclBasic.h"
#include "gsiQtGuiExternals.h"
#include "gsiQtWidgetsExternals.h"
#include "layBrowserDialog.h"
#include "layBrowserPanel.h"
@ -35,6 +36,7 @@
#include <limits>
FORCE_LINK_GSI_QTGUI
FORCE_LINK_GSI_QTWIDGETS // for Qt5
namespace gsi
{

View File

@ -2253,8 +2253,6 @@ PythonModule::~PythonModule ()
m_getseters_heap.pop_back ();
}
m_string_heap.clear ();
if (mp_mod_def) {
delete[] mp_mod_def;
mp_mod_def = 0;
@ -3129,6 +3127,13 @@ PythonInterpreter::~PythonInterpreter ()
sp_interpreter = 0;
}
char *
PythonInterpreter::make_string (const std::string &s)
{
m_string_heap.push_back (s);
return const_cast<char *> (m_string_heap.back ().c_str ());
}
void
PythonInterpreter::add_path (const std::string &p)
{

View File

@ -329,6 +329,9 @@ private:
size_t prepare_trace (PyObject *);
tl::Variant eval_int (const char *string, const char *filename, int line, bool eval_expr, int context);
void get_context (int context, PythonRef &globals, PythonRef &locals, const char *file);
char *make_string (const std::string &s);
std::list<std::string> m_string_heap;
PythonRef m_stdout_channel, m_stderr_channel;
PythonPtr m_stdout, m_stderr;

View File

@ -25,9 +25,7 @@
#include "gsi.h"
#include "gsiExpression.h"
PyMODINIT_FUNC
DEF_INSIDE_PUBLIC
PyInit_db ()
static PyObject *module_init ()
{
gsi::initialize ();
gsi::initialize_expressions ();
@ -38,3 +36,19 @@ PyInit_db ()
return module.module ();
}
#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC
DEF_INSIDE_PUBLIC
initdb ()
{
module_init ();
}
#else
PyMODINIT_FUNC
DEF_INSIDE_PUBLIC
PyMODINIT_FUNC PyInit_themodulename ()
{
return module_init();
}
#endif