update
This commit is contained in:
parent
9c064f57c0
commit
621bc1cecb
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef PYTHONQT_QTALL_H
|
||||||
|
#define PYTHONQT_QTALL_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* Further, this software is distributed without any warranty that it is
|
||||||
|
* free of the rightful claim of any third person regarding infringement
|
||||||
|
* or the like. Any license provided herein, whether implied or
|
||||||
|
* otherwise, applies only to this software file. Patent licenses, if
|
||||||
|
* any, provided herein do not apply to combinations of this program with
|
||||||
|
* other software, or any other product whatsoever.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
|
||||||
|
* 28359 Bremen, Germany or:
|
||||||
|
*
|
||||||
|
* http://www.mevis.de
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#ifdef PYTHONQT_QTALL_EXPORTS
|
||||||
|
#define PYTHONQT_QTALL_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define PYTHONQT_QTALL_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define PYTHONQT_QTALL_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace PythonQt_QtAll {
|
||||||
|
//! initialize the Qt binding
|
||||||
|
PYTHONQT_QTALL_EXPORT void init();
|
||||||
|
}; // namespace PythonQt_QtAll
|
||||||
|
|
||||||
|
#endif
|
Binary file not shown.
|
@ -92,7 +92,8 @@ HEADERS += \
|
||||||
aboutsoftwaredialog.h \
|
aboutsoftwaredialog.h \
|
||||||
sponsordialog.h \
|
sponsordialog.h \
|
||||||
scriptmanager.h \
|
scriptmanager.h \
|
||||||
scriptcenterwindow.h
|
scriptcenterwindow.h \
|
||||||
|
PythonQt/PythonQt_QtAll.h
|
||||||
|
|
||||||
DISTFILES += WingHexPy.json \
|
DISTFILES += WingHexPy.json \
|
||||||
img/infotable.png \
|
img/infotable.png \
|
||||||
|
@ -104,7 +105,8 @@ DISTFILES += WingHexPy.json \
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
$$PWD/WingHexPy.ts
|
$$PWD/WingHexPy.ts
|
||||||
|
|
||||||
LIBS += $$PWD/PythonQt/libPythonQt-Qt5-Python3.7.a
|
LIBS += $$PWD/PythonQt/libPythonQt-Qt5-Python3.7.a \
|
||||||
|
$$PWD/PythonQt/libPythonQt_QtAll-Qt5-Python3.7.a
|
||||||
|
|
||||||
DEFINES += PYTHONQT_CATCH_ALL_EXCEPTIONS
|
DEFINES += PYTHONQT_CATCH_ALL_EXCEPTIONS
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "plginterface.h"
|
#include "plginterface.h"
|
||||||
#include "PythonQt/PythonQtCppWrapperFactory.h"
|
#include "PythonQt/PythonQtCppWrapperFactory.h"
|
||||||
|
#include "PythonQt/PythonQt_QtAll.h"
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
@ -9,6 +10,7 @@ PlgInterface *PlgInterface::m_instace = nullptr;
|
||||||
|
|
||||||
bool PlgInterface::init() {
|
bool PlgInterface::init() {
|
||||||
PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
|
PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
|
||||||
|
PythonQt_QtAll::init();
|
||||||
auto py = PythonQt::self();
|
auto py = PythonQt::self();
|
||||||
py->registerClass(&QListWidget::staticMetaObject, "QtGui");
|
py->registerClass(&QListWidget::staticMetaObject, "QtGui");
|
||||||
py->registerClass(&QTableWidget::staticMetaObject, "QtGui");
|
py->registerClass(&QTableWidget::staticMetaObject, "QtGui");
|
||||||
|
@ -20,12 +22,6 @@ bool PlgInterface::init() {
|
||||||
PythonQtCreateObject<WingPlugin::Controller>);
|
PythonQtCreateObject<WingPlugin::Controller>);
|
||||||
py->registerCPPClass("plgservice", nullptr, "wingplg",
|
py->registerCPPClass("plgservice", nullptr, "wingplg",
|
||||||
PythonQtCreateObject<PlgService>);
|
PythonQtCreateObject<PlgService>);
|
||||||
py->registerCPPClass("infolistwrapper", nullptr, "wingplg",
|
|
||||||
PythonQtCreateObject<InfoListWrapper>);
|
|
||||||
py->registerCPPClass("infotreewrapper", nullptr, "wingplg",
|
|
||||||
PythonQtCreateObject<InfoTreeWrapper>);
|
|
||||||
py->registerCPPClass("infotablewrapper", nullptr, "wingplg",
|
|
||||||
PythonQtCreateObject<InfoTableWrapper>);
|
|
||||||
|
|
||||||
qRegisterMetaType<HexPosition>("hexposition");
|
qRegisterMetaType<HexPosition>("hexposition");
|
||||||
qRegisterMetaType<BookMark>("bookmark");
|
qRegisterMetaType<BookMark>("bookmark");
|
||||||
|
@ -55,10 +51,6 @@ void PlgInterface::initInfo(QListWidget *infolist, QTreeWidget *infotree,
|
||||||
mainContext.addObject("infotable", infotable);
|
mainContext.addObject("infotable", infotable);
|
||||||
mainContext.addObject("infolist", infolist);
|
mainContext.addObject("infolist", infolist);
|
||||||
mainContext.addObject("infotxt", infotxt);
|
mainContext.addObject("infotxt", infotxt);
|
||||||
|
|
||||||
mainContext.addObject("treewrapper", new InfoTreeWrapper(infotree));
|
|
||||||
mainContext.addObject("tablewrapper", new InfoTableWrapper(infotable));
|
|
||||||
mainContext.addObject("listwrapper", new InfoListWrapper(infolist));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonQtScriptingConsole *PlgInterface::getScriptingConsole() {
|
PythonQtScriptingConsole *PlgInterface::getScriptingConsole() {
|
||||||
|
|
163
plginterface.h
163
plginterface.h
|
@ -70,167 +70,4 @@ private:
|
||||||
PlgInterface *inter;
|
PlgInterface *inter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class InfoListWrapper : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
InfoListWrapper() {}
|
|
||||||
InfoListWrapper(QListWidget *list) : m_list(list) {}
|
|
||||||
public slots:
|
|
||||||
void addItem(QString content) {
|
|
||||||
if (m_list)
|
|
||||||
m_list->addItem(content);
|
|
||||||
}
|
|
||||||
void addIconItem(QIcon icon, QString content) {
|
|
||||||
if (m_list)
|
|
||||||
m_list->addItem(new QListWidgetItem(icon, content));
|
|
||||||
}
|
|
||||||
void clear() {
|
|
||||||
if (m_list)
|
|
||||||
m_list->clear();
|
|
||||||
}
|
|
||||||
void insertItem(int index, QString content) {
|
|
||||||
if (m_list)
|
|
||||||
m_list->insertItem(index, content);
|
|
||||||
}
|
|
||||||
void insertIconItem(int index, QIcon icon, QString content) {
|
|
||||||
if (m_list)
|
|
||||||
m_list->insertItem(index, new QListWidgetItem(icon, content));
|
|
||||||
}
|
|
||||||
void removeAt(int index) {
|
|
||||||
if (m_list) {
|
|
||||||
auto item = m_list->item(index);
|
|
||||||
m_list->removeItemWidget(item);
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QListWidget *m_list;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InfoTableWrapper : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
InfoTableWrapper() {}
|
|
||||||
InfoTableWrapper(QTableWidget *table) : m_table(table) {}
|
|
||||||
public slots:
|
|
||||||
void setColumnCount(int count) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setColumnCount(count);
|
|
||||||
}
|
|
||||||
void setRowCount(int count) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setRowCount(count);
|
|
||||||
}
|
|
||||||
void setRowHeight(int row, int height) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setRowHeight(row, height);
|
|
||||||
}
|
|
||||||
void setColumnWidth(int col, int width) {
|
|
||||||
m_table->setColumnWidth(col, width);
|
|
||||||
}
|
|
||||||
void clear() {
|
|
||||||
if (m_table)
|
|
||||||
m_table->clear();
|
|
||||||
}
|
|
||||||
void clearContents() {
|
|
||||||
if (m_table)
|
|
||||||
m_table->clearContents();
|
|
||||||
}
|
|
||||||
void setItem(int row, int col, QString content) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setItem(row, col, new QTableWidgetItem(content));
|
|
||||||
}
|
|
||||||
void setIconItem(int row, int col, QIcon icon, QString content) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setItem(row, col, new QTableWidgetItem(icon, content));
|
|
||||||
}
|
|
||||||
void hideRow(int row) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->hideRow(row);
|
|
||||||
}
|
|
||||||
void hideCol(int col) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->hideColumn(col);
|
|
||||||
}
|
|
||||||
void setHorizontalHeaderLabels(QStringList lbls) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setHorizontalHeaderLabels(lbls);
|
|
||||||
}
|
|
||||||
void setVerticalHeaderLabels(QStringList lbls) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setVerticalHeaderLabels(lbls);
|
|
||||||
}
|
|
||||||
void setHorizontalHeaderLabel(int index, QString lbl) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setHorizontalHeaderItem(index, new QTableWidgetItem(lbl));
|
|
||||||
}
|
|
||||||
void setVerticalHeaderLabel(int index, QString lbl) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setVerticalHeaderItem(index, new QTableWidgetItem(lbl));
|
|
||||||
}
|
|
||||||
void setCurrentCell(int row, int col) {
|
|
||||||
if (m_table)
|
|
||||||
m_table->setCurrentCell(row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTableWidget *m_table;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InfoTreeWrapper : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
InfoTreeWrapper() {}
|
|
||||||
InfoTreeWrapper(QTreeWidget *tree) : m_tree(tree) {}
|
|
||||||
public slots:
|
|
||||||
void clear() {
|
|
||||||
if (m_tree)
|
|
||||||
m_tree->clear();
|
|
||||||
}
|
|
||||||
void expandAll() {
|
|
||||||
if (m_tree)
|
|
||||||
m_tree->expandAll();
|
|
||||||
}
|
|
||||||
QTreeWidgetItem *addItem(QTreeWidget *parent, QStringList contents) {
|
|
||||||
try {
|
|
||||||
if (m_tree) {
|
|
||||||
if (parent)
|
|
||||||
return new QTreeWidgetItem(parent, contents);
|
|
||||||
return new QTreeWidgetItem(m_tree, contents);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
} catch (...) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QTreeWidgetItem *addItem(QTreeWidgetItem *parent, QStringList contents) {
|
|
||||||
try {
|
|
||||||
if (m_tree) {
|
|
||||||
if (parent)
|
|
||||||
return new QTreeWidgetItem(parent, contents);
|
|
||||||
return new QTreeWidgetItem(m_tree, contents);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
} catch (...) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void remove(QTreeWidgetItem *item) {
|
|
||||||
if (m_tree)
|
|
||||||
m_tree->removeItemWidget(item, 0);
|
|
||||||
}
|
|
||||||
void setHeaderLabel(QString &label) {
|
|
||||||
if (m_tree)
|
|
||||||
m_tree->setHeaderLabel(label);
|
|
||||||
}
|
|
||||||
void setHeaderLabels(const QStringList &labels) {
|
|
||||||
if (m_tree)
|
|
||||||
m_tree->setHeaderLabels(labels);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTreeWidget *m_tree;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PLGINTERFACE_H
|
#endif // PLGINTERFACE_H
|
||||||
|
|
Loading…
Reference in New Issue