Commit 5bf2e7de authored by Alexander A. Maly's avatar Alexander A. Maly

Astyling and warning cleaning

parent cdb3a182
Pipeline #2272 passed with stages
in 4 minutes and 18 seconds
This diff is collapsed.
......@@ -340,7 +340,6 @@ void KumirVM::setProgram(const Bytecode::Data &program, bool isMain, const Strin
moduleContexts_[currentModuleContext].moduleNames[e.module] =
e.moduleLocalizedName;
}
uint8_t key = e.module;
moduleContexts_[currentModuleContext].inits.push_back(e);
breakpointsTable_.registerSourceFileName(filename, e.module);
}
......@@ -2170,7 +2169,6 @@ void KumirVM::do_store(uint8_t s, uint16_t id)
Variable &variable = findVariable(s, id);
const int dim = variable.dimension();
ValueType t = variable.baseType();
Variable *reference = variable.reference();
int bounds[7];
if (dim > 0) {
value.getBounds(bounds);
......
......@@ -6,248 +6,254 @@
#include <QApplication>
#include <QDesktopWidget>
namespace Widgets {
SecondaryWindow::SecondaryWindow(QWidget * topLevelParent,
class SecondaryWindowImplementationInterface * windowContainer,
class SecondaryWindowImplementationInterface * dockContainer,
const QString & settingsKey,
QWidget * centralWidget
)
: QObject(topLevelParent)
, dockContainer_(dockContainer)
, windowContainer_(windowContainer)
, settingsKey_(settingsKey)
, topLevelParent_(topLevelParent)
, centralWidget_(centralWidget)
namespace Widgets
{
SecondaryWindow::SecondaryWindow(
QWidget *topLevelParent,
class SecondaryWindowImplementationInterface *windowContainer,
class SecondaryWindowImplementationInterface *dockContainer,
const QString &settingsKey,
QWidget *centralWidget
):
QObject(topLevelParent),
dockContainer_(dockContainer),
windowContainer_(windowContainer),
settingsKey_(settingsKey),
topLevelParent_(topLevelParent),
centralWidget_(centralWidget)
{
}
SecondaryWindow * SecondaryWindow::createSecondaryWindow(
QWidget *centralWidget,
const QString &title,
const QIcon & icon,
QWidget *topLevelParent,
DockWindowPlace *dockPlace,
const QString &settingsKey,
bool resizable)
SecondaryWindow *SecondaryWindow::createSecondaryWindow(
QWidget *centralWidget,
const QString &title,
const QIcon &icon,
QWidget *topLevelParent,
DockWindowPlace *dockPlace,
const QString &settingsKey,
bool resizable)
{
SecondaryWindowImplementationInterface * window =
createWindowContainer(
title,
icon,
topLevelParent,
resizable
);
SecondaryWindowImplementationInterface * dock =
createDockContainer(
title,
dockPlace
);
SecondaryWindow * result = new SecondaryWindow(topLevelParent,
window, dock, settingsKey,
centralWidget
);
if (dock) {
dock->setPairedContainer(window);
dockPlace->registerWindowHere(result);
window->setPairedContainer(dock);
}
window->getWidgetOwnership(centralWidget);
const QMetaObject * meta = centralWidget->metaObject();
if (meta->indexOfSignal("resizeRequest(QSize)") != -1) {
connect(centralWidget, SIGNAL(resizeRequest(QSize)),
window->toWidget(), SLOT(handleResizeRequest(QSize)));
}
if (meta->indexOfSignal("activateRequest()") != -1) {
connect(centralWidget, SIGNAL(activateRequest()),
result, SLOT(activate()));
}
return result;
SecondaryWindowImplementationInterface *window = createWindowContainer(
title,
icon,
topLevelParent,
resizable
);
SecondaryWindowImplementationInterface *dock = createDockContainer(
title,
dockPlace
);
SecondaryWindow *result = new SecondaryWindow(
topLevelParent,
window, dock, settingsKey,
centralWidget
);
if (dock) {
dock->setPairedContainer(window);
dockPlace->registerWindowHere(result);
window->setPairedContainer(dock);
}
window->getWidgetOwnership(centralWidget);
const QMetaObject *meta = centralWidget->metaObject();
if (meta->indexOfSignal("resizeRequest(QSize)") != -1) {
connect(centralWidget, SIGNAL(resizeRequest(QSize)),
window->toWidget(), SLOT(handleResizeRequest(QSize)));
}
if (meta->indexOfSignal("activateRequest()") != -1) {
connect(centralWidget, SIGNAL(activateRequest()),
result, SLOT(activate()));
}
return result;
}
void SecondaryWindow::changeDockPlace(DockWindowPlace *dockPlace)
{
Q_ASSERT(dockContainer_);
SecondaryWindowImplementationInterface * dock =
createDockContainer(dockContainer_->title(), dockPlace);
dock->setPairedContainer(windowContainer_);
dockPlace->registerWindowHere(this);
windowContainer_->setPairedContainer(dock);
QObject* old = dynamic_cast<QObject*>(dockContainer_);
// old->deleteLater();
dockContainer_ = dock;
Q_ASSERT(dockContainer_);
SecondaryWindowImplementationInterface *dock =
createDockContainer(dockContainer_->title(), dockPlace);
dock->setPairedContainer(windowContainer_);
dockPlace->registerWindowHere(this);
windowContainer_->setPairedContainer(dock);
// QObject* old = dynamic_cast<QObject*>(dockContainer_);
// old->deleteLater();
dockContainer_ = dock;
}
SecondaryWindowImplementationInterface *
SecondaryWindow::createWindowContainer(const QString &title,
const QIcon & icon,
QWidget *topLevelParent,
bool resizable)
{
SecondaryWindowImplementationInterface * result = nullptr;
QWidget * parent = topLevelParent;
SecondaryWindow::createWindowContainer(
const QString &title,
const QIcon &icon,
QWidget *topLevelParent,
bool resizable
) {
SecondaryWindowImplementationInterface *result = nullptr;
QWidget *parent = topLevelParent;
#ifdef Q_WS_WIN32
parent = 0;
parent = 0;
#endif
result = new SecondaryWindowGenericImplementation(parent);
// TODO create platform-specific implementations
result = new SecondaryWindowGenericImplementation(parent);
// TODO create platform-specific implementations
result->setResizeble(resizable);
result->setTitle(title);
result->setIcon(icon);
result->setResizeble(resizable);
result->setTitle(title);
result->setIcon(icon);
return result;
return result;
}
SecondaryWindowImplementationInterface *
SecondaryWindow::createDockContainer(const QString &title,
DockWindowPlace *dockPlace)
{
if (dockPlace) {
SecondaryWindowImplementationInterface * result =
new DockWindowPlaceContainer(dockPlace);
result->setTitle(title);
return result;
}
else {
return nullptr;
}
SecondaryWindow::createDockContainer(
const QString &title,
DockWindowPlace *dockPlace
) {
if (dockPlace) {
SecondaryWindowImplementationInterface *result =
new DockWindowPlaceContainer(dockPlace);
result->setTitle(title);
return result;
} else {
return nullptr;
}
}
SecondaryWindowImplementationInterface *
SecondaryWindow::dockContainer() const
{
return dockContainer_;
return dockContainer_;
}
SecondaryWindowImplementationInterface *
SecondaryWindow::windowContainer() const
{
return windowContainer_;
return windowContainer_;
}
const QString & SecondaryWindow::settingsKey() const
const QString &SecondaryWindow::settingsKey() const
{
return settingsKey_;
return settingsKey_;
}
void SecondaryWindow::activate()
{
SecondaryWindowImplementationInterface * whom = currentContainer();
if (whom) {
whom->activate(QPoint(), QSize());
}
SecondaryWindowImplementationInterface *whom = currentContainer();
if (whom) {
whom->activate(QPoint(), QSize());
}
}
bool SecondaryWindow::isSeparateWindow() const
{
return currentContainer() == windowContainer();
return currentContainer() == windowContainer();
}
SecondaryWindowImplementationInterface * SecondaryWindow::currentContainer() const
SecondaryWindowImplementationInterface *
SecondaryWindow::currentContainer() const
{
SecondaryWindowImplementationInterface * result = nullptr;
if (windowContainer_ && windowContainer_->hasWidgetOwnership()) {
result = windowContainer_;
}
else if (dockContainer_ && dockContainer_->hasWidgetOwnership()) {
result = dockContainer_;
}
return result;
SecondaryWindowImplementationInterface *result = nullptr;
if (windowContainer_ && windowContainer_->hasWidgetOwnership()) {
result = windowContainer_;
} else if (dockContainer_ && dockContainer_->hasWidgetOwnership()) {
result = dockContainer_;
}
return result;
}
void SecondaryWindow::updateSettings(ExtensionSystem::SettingsPtr settings,
const QStringList &)
{
saveState();
settings_ = settings;
restoreState();
void SecondaryWindow::updateSettings(
ExtensionSystem::SettingsPtr settings,
const QStringList &
) {
saveState();
settings_ = settings;
restoreState();
}
static const char * WindowSize = "/WindowSize";
static const char * WindowPos = "/WindowPos";
static const char * DockSize = "/DockSize";
static const char * IsDocked = "/IsDocked";
static const char * IsDockVisible = "/IsDockVisible";
static const char *WindowSize = "/WindowSize";
static const char *WindowPos = "/WindowPos";
static const char *DockSize = "/DockSize";
static const char *IsDocked = "/IsDocked";
static const char *IsDockVisible = "/IsDockVisible";
void SecondaryWindow::saveState()
{
if (!settings_) return;
if (windowContainer_) {
settings_->setValue(settingsKey_ + WindowSize,
windowContainer_->toWidget()->size());
settings_->setValue(settingsKey_ + WindowPos,
windowContainer_->toWidget()->pos());
}
if (dockContainer_) {
settings_->setValue(settingsKey_ + DockSize,
dockContainer_->toWidget()->size());
settings_->setValue(settingsKey_ + IsDockVisible,
dockContainer_->toWidget()->isVisible());
settings_->setValue(settingsKey_ + IsDocked,
dockContainer_ == currentContainer());
}
if (!settings_) {
return;
}
if (windowContainer_) {
settings_->setValue(settingsKey_ + WindowSize,
windowContainer_->toWidget()->size());
settings_->setValue(settingsKey_ + WindowPos,
windowContainer_->toWidget()->pos());
}
if (dockContainer_) {
settings_->setValue(settingsKey_ + DockSize,
dockContainer_->toWidget()->size());
settings_->setValue(settingsKey_ + IsDockVisible,
dockContainer_->toWidget()->isVisible());
settings_->setValue(settingsKey_ + IsDocked,
dockContainer_ == currentContainer());
}
}
void SecondaryWindow::restoreState()
{
if (!settings_) return;
if (windowContainer_) {
QWidget * window = windowContainer_->toWidget();
const QSize prefSize = centralWidget_ ? centralWidget_->sizeHint() : QSize();
QSize sz = settings_->value(settingsKey_ + WindowSize, prefSize).toSize();
QPoint ps = settings_->value(settingsKey_ + WindowPos, QPoint(-1, -1)).toPoint();
if (ps == QPoint(-1, -1) || ps.x() < -sz.width() || ps.y() < -16) {
ps = QApplication::desktop()->availableGeometry(topLevelParent_).center();
ps.rx() -= sz.width() / 2;
ps.ry() -= sz.height() / 2;
}
window->resize(sz);
window->move(ps);
}
bool docked = settings_->value(settingsKey_ + IsDocked, true).toBool();
if (dockContainer_ && docked) {
QWidget * w = currentContainer()->releaseWidgetOwnership();
dockContainer_->getWidgetOwnership(w);
bool dockVisible = settings_->value(settingsKey_ + IsDockVisible, false).toBool();
if (dockVisible) {
dockContainer_->activate(QPoint(), QSize());
if (centralWidget_) {
QObject * obj = centralWidget_;
if (-1 != obj->metaObject()->indexOfMethod("setDock(bool)")) {
QMetaObject::invokeMethod(obj, "setDock", Q_ARG(bool, true));
}
}
}
QWidget * dock = dockContainer_->toWidget();
QSize sz = settings_->value(settingsKey_ + DockSize).toSize();
dock->resize(sz);
}
else {
QWidget * w = currentContainer()->releaseWidgetOwnership();
windowContainer_->getWidgetOwnership(w);
}
if (!settings_) {
return;
}
if (windowContainer_) {
QWidget *window = windowContainer_->toWidget();
const QSize prefSize = centralWidget_ ? centralWidget_->sizeHint() : QSize();
QSize sz = settings_->value(settingsKey_ + WindowSize, prefSize).toSize();
QPoint ps = settings_->value(settingsKey_ + WindowPos, QPoint(-1, -1)).toPoint();
if (ps == QPoint(-1, -1) || ps.x() < -sz.width() || ps.y() < -16) {
ps = QApplication::desktop()->availableGeometry(topLevelParent_).center();
ps.rx() -= sz.width() / 2;
ps.ry() -= sz.height() / 2;
}
window->resize(sz);
window->move(ps);
}
bool docked = settings_->value(settingsKey_ + IsDocked, true).toBool();
if (dockContainer_ && docked) {
QWidget *w = currentContainer()->releaseWidgetOwnership();
dockContainer_->getWidgetOwnership(w);
bool dockVisible = settings_->value(settingsKey_ + IsDockVisible, false).toBool();
if (dockVisible) {
dockContainer_->activate(QPoint(), QSize());
if (centralWidget_) {
QObject *obj = centralWidget_;
if (-1 != obj->metaObject()->indexOfMethod("setDock(bool)")) {
QMetaObject::invokeMethod(obj, "setDock", Q_ARG(bool, true));
}
}
}
QWidget *dock = dockContainer_->toWidget();
QSize sz = settings_->value(settingsKey_ + DockSize).toSize();
dock->resize(sz);
} else {
QWidget *w = currentContainer()->releaseWidgetOwnership();
windowContainer_->getWidgetOwnership(w);
}
}
bool SecondaryWindow::event(QEvent *evt)
{
if (QEvent::ApplicationFontChange == evt->type()) {
if (dockContainer()) {
QObject *dockTarget = dockContainer()->toWidget();
qApp->sendEvent(dockTarget, evt);
}
}
return QObject::event(evt);
if (QEvent::ApplicationFontChange == evt->type()) {
if (dockContainer()) {
QObject *dockTarget = dockContainer()->toWidget();
qApp->sendEvent(dockTarget, evt);
}
}
return QObject::event(evt);
}
} // namespace Widgets
......@@ -11,73 +11,71 @@
#define WIDGETS_EXPORT Q_DECL_IMPORT
#endif
namespace Widgets {
namespace Widgets
{
class WIDGETS_EXPORT SecondaryWindow
: public QObject
class WIDGETS_EXPORT SecondaryWindow : public QObject
{
Q_OBJECT
Q_OBJECT
public:
class SecondaryWindowImplementationInterface * dockContainer() const;
class SecondaryWindowImplementationInterface * windowContainer() const;
const QString & settingsKey() const;
class SecondaryWindowImplementationInterface *dockContainer() const;
class SecondaryWindowImplementationInterface *windowContainer() const;
static SecondaryWindow * createSecondaryWindow(
QWidget * centralWidget,
const QString & title,
const QIcon & icon,
QWidget * topLevelParent,
class DockWindowPlace * dockPlace,
const QString & settingsKey,
bool resizable
);
void changeDockPlace(class DockWindowPlace * dockPlace);
bool isSeparateWindow() const;
const QString &settingsKey() const;
static SecondaryWindow *createSecondaryWindow(
QWidget *centralWidget,
const QString &title,
const QIcon &icon,
QWidget *topLevelParent,
class DockWindowPlace *dockPlace,
const QString &settingsKey,
bool resizable
);
void changeDockPlace(class DockWindowPlace *dockPlace);
bool isSeparateWindow() const;
signals:
public slots:
void activate();
void updateSettings(ExtensionSystem::SettingsPtr settings,
const QStringList & keys);
void saveState();
void restoreState();
void activate();
void updateSettings(ExtensionSystem::SettingsPtr settings,
const QStringList &keys);
void saveState();
void restoreState();
private /*methods*/:
bool event(QEvent *evt);
bool event(QEvent *evt);
explicit SecondaryWindow(QWidget * topLevelParent,
class SecondaryWindowImplementationInterface * windowContainer,
class SecondaryWindowImplementationInterface * dockContainer,
const QString & settingsKey,
QWidget * centralWidget
);
explicit SecondaryWindow(QWidget *topLevelParent,
class SecondaryWindowImplementationInterface *windowContainer,
class SecondaryWindowImplementationInterface *dockContainer,
const QString &settingsKey,
QWidget *centralWidget
);
static SecondaryWindowImplementationInterface * createWindowContainer(
const QString & title,
const QIcon & icon,
QWidget * topLevelParent,
bool resizable
);
static SecondaryWindowImplementationInterface *createWindowContainer(
const QString &title,
const QIcon &icon,
QWidget *topLevelParent,
bool resizable
);
static SecondaryWindowImplementationInterface * createDockContainer(
const QString & title,
class DockWindowPlace * dockPlace
);
static SecondaryWindowImplementationInterface *createDockContainer(
const QString &title,
class DockWindowPlace *dockPlace
);
class SecondaryWindowImplementationInterface * currentContainer() const;
class SecondaryWindowImplementationInterface *currentContainer() const;
private /*fields*/:
class SecondaryWindowImplementationInterface * dockContainer_;
class SecondaryWindowImplementationInterface * windowContainer_;
QString settingsKey_;
ExtensionSystem::SettingsPtr settings_;
QWidget * topLevelParent_;
QWidget * centralWidget_;
class SecondaryWindowImplementationInterface *dockContainer_;
class SecondaryWindowImplementationInterface *windowContainer_;
QString settingsKey_;
ExtensionSystem::SettingsPtr settings_;
QWidget *topLevelParent_;
QWidget *centralWidget_;
};
......
......@@ -12,98 +12,100 @@
#include <kumir2-libs/vm/vm_enums.h>
#include <kumir2-libs/vm/vm_instruction.hpp>