Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 24, 2019
1 parent 9d0b695 commit cff17fc
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 87 deletions.
4 changes: 3 additions & 1 deletion src/plugins/dataStore/DataStore/src/datastorepythonnumpy.h
Expand Up @@ -31,7 +31,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include <numpy/arrayobject.h>
#include "pythonbegin.h"
#include <numpy/arrayobject.h>
#include "pythonend.h"

//==============================================================================
// End of file
Expand Down
27 changes: 16 additions & 11 deletions src/plugins/miscellaneous/Core/src/corecliutils.cpp
Expand Up @@ -256,17 +256,22 @@ QString digitGroupNumber(const QString &pNumber)

QString sizeAsString(quint64 pSize, int pPrecision)
{
std::array<QString, 9> units = { QObject::tr("B"), QObject::tr("KB"),
QObject::tr("MB"), QObject::tr("GB"),
QObject::tr("TB"), QObject::tr("PB") };
static const std::array<QString, 9> Units = {
QObject::tr("B"),
QObject::tr("KB"),
QObject::tr("MB"),
QObject::tr("GB"),
QObject::tr("TB"),
QObject::tr("PB")
};

auto i = ulong(qFloor(log(pSize)/log(1024.0)));
double size = pSize/qPow(1024.0, i);
double scaling = qPow(10.0, pPrecision);

size = qRound(scaling*size)/scaling;

return QLocale().toString(size)+" "+units[i];
return QLocale().toString(size)+" "+Units.at(i);
}

//==============================================================================
Expand Down Expand Up @@ -639,13 +644,13 @@ QString openRemoteFile(const QString &pUrl)
}

return QString("");
} else {
// We were not able to retrieve the contents of the remote file, so
// let the user know about it

return QObject::tr("'%1' could not be opened (%2).").arg(fileNameOrUrl)
.arg(formatMessage(errorMessage));
}

// We were not able to retrieve the contents of the remote file, so let
// the user know about it

return QObject::tr("'%1' could not be opened (%2).").arg(fileNameOrUrl,
formatMessage(errorMessage));
}

return openFile(fileName, File::Type::Remote, fileNameOrUrl);
Expand Down Expand Up @@ -1089,7 +1094,7 @@ QByteArray serialiseDomDocument(const QDomDocument &pDomDocument)

// Manually serialise the elements' attributes

for (const auto &elementAttribute : elementsAttributes.keys()) {
for (const auto &elementAttribute : elementsAttributes) {
res.replace(elementAttribute+R"(="")", elementsAttributes.value(elementAttribute));
}

Expand Down
Expand Up @@ -22,12 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "jupyterkernelplugin.h"

//==============================================================================

#include "pythonbegin.h"
#include "pythonqtsupport.h"
#include "pythonend.h"
#include "pythonqtsupport.h"

//==============================================================================

Expand Down
Expand Up @@ -9,8 +9,8 @@ ADD_PLUGIN(PythonConsoleWindow
../../plugininterface.cpp
../../windowinterface.cpp

src/pythonconsolewindowplugin.cpp
src/pythonconsolewindow.cpp
src/pythonconsolewindowplugin.cpp
UIS
src/pythonconsolewindow.ui
PLUGINS
Expand Down
Expand Up @@ -25,30 +25,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "borderedwidget.h"

//==============================================================================

#include "pythonbegin.h"

//==============================================================================

#include "pythonconsolewindow.h"
#include "pythonqtsupport.h"

//==============================================================================

#include "PythonQt/PythonQt.h"

//==============================================================================

#include "ui_pythonconsolewindow.h"

//==============================================================================

#include <iostream>

//==============================================================================

namespace OpenCOR {
namespace PythonConsoleWindow {

Expand Down Expand Up @@ -149,7 +134,7 @@ PythonConsoleWindow::PythonConsoleWindow(QWidget *pParent) :

PyObject *createWidget = pythonQtInstance->lookupObject(qtConsoleModule, "create_ipython_widget");
PyObject *ipythonWidget = pythonQtInstance->callAndReturnPyObject(createWidget);
PythonQtInstanceWrapper *widgetWrapper = reinterpret_cast<PythonQtInstanceWrapper*>(ipythonWidget);
auto widgetWrapper = reinterpret_cast<PythonQtInstanceWrapper *>(ipythonWidget);

if (widgetWrapper == nullptr) {
if (PyErr_Occurred()) {
Expand Down Expand Up @@ -196,10 +181,6 @@ PythonConsoleWindow::~PythonConsoleWindow()
} // namespace PythonConsoleWindow
} // namespace OpenCOR

//==============================================================================

#include "pythonend.h"

//==============================================================================
// End of file
//==============================================================================
Expand Up @@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Python shell plugin
//==============================================================================

#include "pythonqtsupport.h"
#include "pythonqtsupportplugin.h"
#include "pythonshellplugin.h"

Expand All @@ -33,12 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "pythonbegin.h"
#include "pythonqtsupport.h"
#include "pythonend.h"

//==============================================================================

namespace OpenCOR {
namespace PythonShell {

Expand Down
Expand Up @@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "coreguiutils.h"
#include "webbrowserwindowplugin.h"
#include "webbrowserwindowwindow.h"
#include "webbrowserwindowpythonwrapper.h"

//==============================================================================

Expand All @@ -33,12 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "pythonbegin.h"
#include "webbrowserwindowpythonwrapper.h"
#include "pythonend.h"

//==============================================================================

namespace OpenCOR {
namespace WebBrowserWindow {

Expand Down
Expand Up @@ -30,10 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "pythonbegin.h"

//==============================================================================

#include "pythonqtsupport.h"
#include "webbrowserwindowpythonwrapper.h"

Expand Down Expand Up @@ -72,10 +68,6 @@ WebBrowserWindowPythonWrapper::WebBrowserWindowPythonWrapper(PyObject *pModule,
} // namespace WebBrowserWindow
} // namespace OpenCOR

//==============================================================================

#include "pythonend.h"

//==============================================================================
// End of file
//==============================================================================
7 changes: 1 addition & 6 deletions src/plugins/pythoninterface.h
Expand Up @@ -26,12 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "plugin.h"

//==============================================================================

#include "pythonbegin.h"
#include "pythoninclude.h"
#include "pythonend.h"
#include "pythoninclude.h"

//==============================================================================

Expand Down
10 changes: 2 additions & 8 deletions src/plugins/support/PythonQtSupport/src/pythonqtsupport.cpp
Expand Up @@ -25,10 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "pythonbegin.h"

//==============================================================================

#include "pythonqtsupport.h"

//==============================================================================
Expand Down Expand Up @@ -90,7 +86,9 @@ PyObject *wrapQObject(QObject *pQObject)
PythonQtInstanceWrapper *getInstanceWrapper(PyObject *pSelf)
{
if ( (pSelf != nullptr)
#include "pythonbegin.h"
&& PyObject_TypeCheck(pSelf, &PythonQtInstanceWrapper_Type)) {
#include "pythonend.h"
return reinterpret_cast<PythonQtInstanceWrapper*>(pSelf);
}

Expand All @@ -102,10 +100,6 @@ PythonQtInstanceWrapper *getInstanceWrapper(PyObject *pSelf)
} // namespace PythonQtSupport
} // namespace OpenCOR

//==============================================================================

#include "pythonend.h"

//==============================================================================
// End of file
//==============================================================================
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/support/PythonQtSupport/src/pythonqtsupport.h
Expand Up @@ -29,17 +29,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "PythonQt/PythonQt.h"

//==============================================================================

#include <QObject>
#include <QMetaObject>
#include <QString>
#include <QVariant>

//==============================================================================

#include "pythonbegin.h"
#include "PythonQt/PythonQt.h"
#include "pythonend.h"

//==============================================================================

namespace OpenCOR {
namespace PythonQtSupport {

Expand Down
Expand Up @@ -22,26 +22,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

#include "corecliutils.h"
#include "pythoninterface.h"
#include "pythonqtsupportplugin.h"
#include "solverinterface.h"

//==============================================================================

#include <Qt>

//==============================================================================

#include <csignal>
//#include <Qt>

//==============================================================================

#include "pythonbegin.h"
#include "pythoninterface.h"
#include "pythonqtsupportplugin.h"
#include "PythonQt/PythonQt_QtAll.h"
#include "pythonend.h"

//==============================================================================

//#include <csignal>

//==============================================================================

namespace OpenCOR {
namespace PythonQtSupport {

Expand Down
Expand Up @@ -27,12 +27,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "plugininfo.h"
#include "plugininterface.h"
#include "pythonqtsupportglobal.h"

//==============================================================================

#include "pythonbegin.h"
#include "pythonqtsupportglobal.h"
#include "PythonQt/PythonQt.h"
#include "PythonQt/PythonQt.h"
#include "pythonend.h"

//==============================================================================
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/support/PythonSupport/src/pythoninclude.h
Expand Up @@ -28,7 +28,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma push_macro("slots")
#undef slots

#include "Python.h"
#include "pythonbegin.h"
#include "Python.h"
#include "pythonend.h"

#pragma pop_macro("slots")

Expand Down

0 comments on commit cff17fc

Please sign in to comment.