Commit e6c06b72 authored by Victor Yacovlev's avatar Victor Yacovlev

Removed variables window due to void implementation

parent ccefa1f2
......@@ -9,7 +9,6 @@ set(SOURCES
terminal_onesession.cpp
terminal_plane.cpp
tabbar.cpp
kumirvariableswebobject.cpp
aboutdialog.cpp
)
......@@ -33,7 +32,6 @@ set(MOC_HEADERS
terminal_onesession.h
terminal_plane.h
tabbar.h
kumirvariableswebobject.h
aboutdialog.h
tabwidgetelement.h
)
......
#include "kumirprogram.h"
#include "extensionsystem/pluginmanager.h"
#include "interfaces/actorinterface.h"
#include "kumirvariableswebobject.h"
#include "dataformats/ast_algorhitm.h"
namespace CoreGUI {
......@@ -15,7 +14,6 @@ KumirProgram::KumirProgram(QObject *parent)
, m_ast(0)
, m_process(0)
, m_terminal(0)
, plugin_nativeGenerator(0)
, plugin_bytcodeGenerator(0)
, plugin_bytecodeRun(0)
, plugin_editor(0)
......@@ -28,8 +26,6 @@ KumirProgram::KumirProgram(QObject *parent)
, a_stepOut(0)
, a_stop(0)
, gr_actions(0)
, m_variablesWebObject(0)
, w_mainWidget(0)
{
b_blind = false;
......@@ -134,47 +130,20 @@ KumirProgram::KumirProgram(QObject *parent)
gr_actions->addAction(s2);
gr_actions->addAction(a_stop);
m_variablesWebObject = new KumirVariablesWebObject(this);
i_timerId = startTimer(1000);
}
void KumirProgram::setAST(const AST::Data *ast)
{
m_ast = ast;
m_variablesWebObject->setProgram(m_ast);
}
KumirVariablesWebObject * KumirProgram::variablesWebObject()
{
return m_variablesWebObject;
}
void KumirProgram::setNativeGenerator(GeneratorInterface *cpp)
{
plugin_nativeGenerator = cpp;
if (cpp) {
m_process = new QProcess(this);
connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(handleProcessFinished(int,QProcess::ExitStatus)));
connect(m_process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(handleProcessError(QProcess::ProcessError)));
}
else {
a_fastRun->deleteLater();
a_fastRun = 0;
}
}
void KumirProgram::handleMarginTextRequest(int lineNo, const QString &text)
{
if (lineNo!=-1 && !text.isEmpty())
plugin_editor->appendMarginText(i_documentId, lineNo, text);
if (e_state==StepRun)
m_variablesWebObject->refreshRoot();
}
void KumirProgram::handleMarginClearRequest(int fromLine, int toLine)
......@@ -356,7 +325,6 @@ void KumirProgram::regularRun()
prepareKumirRunner(Shared::GeneratorInterface::LinesAndVariables);
}
e_state = RegularRun;
m_variablesWebObject->reset(plugin_bytecodeRun);
PluginManager::instance()->switchGlobalState(GS_Running);
plugin_bytecodeRun->runContinuous();
}
......@@ -377,7 +345,6 @@ void KumirProgram::prepareKumirRunner(Shared::GeneratorInterface::DebugLevel deb
}
}
const QString exeFileName = s_sourceFileName.mid(0, s_sourceFileName.length()-4)+".kum";
m_variablesWebObject->setProgram(m_ast);
m_terminal->start(exeFileName);
}
......@@ -389,7 +356,6 @@ void KumirProgram::stepRun()
if (e_state==Idle) {
emit giveMeAProgram();
prepareKumirRunner(Shared::GeneratorInterface::LinesAndVariables);
m_variablesWebObject->reset(plugin_bytecodeRun);
}
e_state = StepRun;
a_stepRun->setIcon(QIcon::fromTheme("debug-step-over", QIcon(QApplication::instance()->property("sharePath").toString()+"/icons/debug-step-over.png")));
......@@ -459,7 +425,6 @@ void KumirProgram::handleRunnerStopped(int rr)
// a_stepOut->setEnabled(plugin_bytecodeRun->canStepOut());
}
else if (reason==Shared::RunInterface::SR_UserTerminated) {
m_variablesWebObject->refreshRoot();
s_endStatus = tr("Evaluation terminated");
m_terminal->finish();
PluginManager::instance()->switchGlobalState(GS_Observe);
......@@ -470,7 +435,6 @@ void KumirProgram::handleRunnerStopped(int rr)
}
else if (reason==Shared::RunInterface::SR_Error) {
s_endStatus = tr("Evaluation error");
m_variablesWebObject->refreshRoot();
m_terminal->error(plugin_bytecodeRun->error());
plugin_editor->highlightLineRed(i_documentId, plugin_bytecodeRun->currentLineNo());
PluginManager::instance()->switchGlobalState(GS_Observe);
......@@ -480,7 +444,6 @@ void KumirProgram::handleRunnerStopped(int rr)
else if (reason==Shared::RunInterface::SR_Done) {
s_endStatus = tr("Evaluation finished");
m_terminal->finish();
m_variablesWebObject->refreshRoot();
PluginManager::instance()->switchGlobalState(GS_Observe);
e_state = Idle;
m_terminal->clearFocus();
......@@ -548,15 +511,6 @@ void KumirProgram::switchGlobalState(GlobalState prev, GlobalState cur)
a_stepOut->setEnabled(true);
a_stop->setEnabled(true);
}
if (prev==GS_Unlocked && cur==GS_Running) {
m_variablesWebObject->reset(plugin_bytecodeRun);
}
if (cur==GS_Unlocked) {
m_variablesWebObject->reset(0);
}
}
......@@ -596,9 +550,6 @@ void KumirProgram::handleActorResetRequest(const QString & actorName)
void KumirProgram::timerEvent(QTimerEvent *e)
{
if (e_state==RegularRun && !b_blind) {
m_variablesWebObject->refreshRoot();
}
e->accept();
}
......
......@@ -25,7 +25,6 @@ class KumirProgram : public QObject
Q_OBJECT
public:
explicit KumirProgram(QObject *parent = 0);
void setNativeGenerator(GeneratorInterface * cpp);
inline void setBytecodeGenerator(GeneratorInterface * bc) { plugin_bytcodeGenerator = bc; }
inline void setEditorPlugin(EditorInterface * ed) { plugin_editor = ed; }
void setAST(const AST::Data * ast);
......@@ -40,7 +39,6 @@ public:
void addActor(KPlugin * a, QWidget * w);
inline QString endStatus() const { return s_endStatus; }
~KumirProgram();
class KumirVariablesWebObject * variablesWebObject();
signals:
void giveMeAProgram();
void activateDocumentTab(int documentId);
......@@ -74,7 +72,6 @@ private:
QProcess * m_process;
Term * m_terminal;
QDockWidget * m_terminalWindow;
GeneratorInterface * plugin_nativeGenerator;
GeneratorInterface * plugin_bytcodeGenerator;
RunInterface * plugin_bytecodeRun;
EditorInterface * plugin_editor;
......@@ -92,7 +89,6 @@ private:
QMap<QString,ActorInterface*> m_actors;
int i_documentId;
bool b_blind;
class KumirVariablesWebObject * m_variablesWebObject;
int i_timerId;
QWidget * w_mainWidget;
bool b_processUserTerminated;
......
This diff is collapsed.
#ifndef COREGUI_KUMIRVARIABLESWEBOBJECT_H
#define COREGUI_KUMIRVARIABLESWEBOBJECT_H
#include <QtCore>
#include "dataformats/ast.h"
#include "dataformats/ast_variable.h"
#include "interfaces/runinterface.h"
#include "interfaces/browserinterface.h"
namespace CoreGUI {
class KumirVariablesWebObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString rootPage READ rootPage)
public:
explicit KumirVariablesWebObject(QObject *parent = 0);
inline void setBrowserPlugin(Shared::BrowserInterface * browser)
{
m_browser = browser;
}
signals:
void jsRequest(const QString& method, const QVariantList & args);
void newWindowCreated(const Shared::BrowserComponent & bc);
void windowRaiseRequest(QWidget * w);
void windowCloseRequest(QWidget * w);
public slots:
QString rootPage() const;
QString modulePage(int index) const;
QString tableTitle(const QString & hashValue) const;
QString tablePage(const QString & hashValue) const;
QString tablePage(const QString & hashValue, int pageNo) const;
int tablePagesCount(const QString & hashValue) const;
int tablePagesStartIndex(const QString & hashValue) const;
QString unavailableTableText() const;
int modulesCount() const;
void reset(const Shared::RunInterface * runner);
void setProgram(const AST::Data * ast);
void refreshRoot();
void test(const QString & aaa);
void openTableWindow(int dimension, int moduleId, int algorhitmId, int variableId);
void checkUnusedWindows();
private:
static QString table1D(const QList<int> & bounds, const QVariant & vl);
static QString table2D(const QList<int> & bounds, const QVariant & vl);
static QString table3D(const QList<int> & bounds, const QVariant & vl);
QString valuesTable(int moduleId, int algId, const QList<AST::Variable*> values) const;
const AST::Variable * findVariable(
const QString & moduleName,
const QString & algName,
const QString & varName,
bool global,
int &modId, int &algId, int &varId
) const;
QString makeTableValue(int dim, int moduleId, int algorhitmId, int variableId, int dimension, const QVariant value) const;
static QString makeArr(int dim, const QList<int> & bounds, const QVariant & value);
QList<AST::Module*> l_userModules;
QList<int> l_userModulesIds;
const Shared::RunInterface * m_runner;
Shared::BrowserInterface * m_browser;
QMap<QString,Shared::BrowserComponent> l_openedChildWindows;
struct TableMetadata {
QString moduleName;
QString algorhitmName;
bool global;
QString variableName;
int dimension;
uint hash;
};
QMap<QString,TableMetadata> l_openedChildData;
};
} // namespace CoreGUI
#endif // COREGUI_KUMIRVARIABLESWEBOBJECT_H
This diff is collapsed.
#ifndef COREGUI_KUMIRVARIABLESWINDOW_H
#define COREGUI_KUMIRVARIABLESWINDOW_H
#include <QtCore>
#include <QtGui>
#include "abstractsyntaxtree/ast.h"
#include "ui_kumirvariableswindow.h"
namespace CoreGUI {
class KumirVariablesWindow
: public QWidget
, Ui::KumirVariablesWindow
{
public:
Q_OBJECT
public:
explicit KumirVariablesWindow ( QWidget* parent = 0 );
~KumirVariablesWindow();
void init( AST::Data * ast );
public slots:
void refreshVariables();
void reset();
protected slots:
void handleItemDoubleClicked(QTreeWidgetItem * item, int column);
void handleTableViewerClosed();
void handleItemHovered(QTreeWidgetItem * item, int column);
protected:
static QString unserializeArray(const QVariant &data);
static QString unserialize1D(const QList<QVariant> l, int size, int &index);
void createSeparateTableViewer(int moduleId, int variableId);
void showEvent(QShowEvent *event);
void closeEvent ( QCloseEvent * event );
void setHeaders();
bool isFunction(const QString& name);
QVariant getValue(int mod, int alg, int id) const;
AST::Data * m_ast;
QMap<QString, class TableViewer*> l_tables;
QMap<QString, class QWidget*> l_childWindows;
};
} // namespace CoreGUI
#endif // COREGUI_KUMIRVARIABLESWINDOW_H
#include "plugin.h"
#include "mainwindow.h"
#include "extensionsystem/pluginmanager.h"
#include "kumirvariableswebobject.h"
#include "widgets/secondarywindow.h"
#include "ui_mainwindow.h"
#ifdef Q_OS_MACX
......@@ -125,51 +124,10 @@ QString Plugin::initialize(const QStringList & parameters)
m_kumirProgram = new KumirProgram(this);
m_kumirProgram->setBytecodeGenerator(plugin_BytecodeGenerator);
m_kumirProgram->setNativeGenerator(plugin_NativeGenerator);
m_kumirProgram->setEditorPlugin(plugin_editor);
m_kumirProgram->setTerminal(m_terminal, 0);
QMap<QString,QObject*> variablesBrowserObjects;
variablesBrowserObjects["variablesObject"] = m_kumirProgram->variablesWebObject();
m_kumirProgram->variablesWebObject()->setBrowserPlugin(plugin_browser);
struct Shared::BrowserComponent variablesBrowser =
plugin_browser->createBrowser(
QUrl::fromLocalFile(
QApplication::instance()->property("sharePath").toString()+
"/coregui/variableswindow_kumir/index.html"
),
variablesBrowserObjects);
connect(m_kumirProgram->variablesWebObject(), SIGNAL(jsRequest(QString,QVariantList)),
variablesBrowser.widget, SLOT(evaluateCommand(QString,QVariantList)));
variablesBrowser.widget->setMinimumWidth(430);
Widgets::SecondaryWindow * variablesWindow = new Widgets::SecondaryWindow(
variablesBrowser.widget,
0,
m_mainWindow,
mySettings(),
"Variables");
variablesWindow->setWindowTitle(tr("Variables"));
connect(m_kumirProgram->variablesWebObject(), SIGNAL(newWindowCreated(Shared::BrowserComponent)),
this, SLOT(handleNewVariablesWindow(Shared::BrowserComponent)));
connect(m_kumirProgram->variablesWebObject(), SIGNAL(windowCloseRequest(QWidget*)),
this, SLOT(handleCloseVariablesWindow(QWidget*)));
connect(m_kumirProgram->variablesWebObject(), SIGNAL(windowRaiseRequest(QWidget*)),
this, SLOT(handleRaiseVariablesWindow(QWidget*)));
connect(m_mainWindow->ui->actionVariables, SIGNAL(triggered()),
variablesWindow->toggleViewAction(), SLOT(trigger()));
l_secondaryWindows << variablesWindow;
connect(m_kumirProgram, SIGNAL(giveMeAProgram()), this, SLOT(prepareKumirProgramToRun()), Qt::DirectConnection);
......@@ -307,52 +265,6 @@ void Plugin::updateSettings()
}
}
void Plugin::handleNewVariablesWindow(const Shared::BrowserComponent &browser)
{
Widgets::SecondaryWindow * window = new Widgets::SecondaryWindow(
browser.widget,
0,
m_mainWindow,
mySettings(),
"Variables"+QString::number(l_variablesChildBrowsers.size()));
l_secondaryWindows << window;
connect(browser.widget, SIGNAL(titleChanged(QString)),
window, SLOT(setWindowTitle(QString)));
connect(m_kumirProgram->variablesWebObject(), SIGNAL(jsRequest(QString,QVariantList)),
browser.widget, SLOT(evaluateCommand(QString,QVariantList)));
window->setMinimumSize(300, 120);
window->resize(300, 180);
window->show();
l_variablesChildBrowsers << browser;
l_variablesChildWindows << window;
}
void Plugin::handleCloseVariablesWindow(QWidget *w)
{
int index = -1;
for (int i=0; i<l_variablesChildBrowsers.size(); i++) {
if (l_variablesChildBrowsers[i].widget==w) {
index = i;
break;
}
}
l_variablesChildBrowsers[index].widget->deleteLater();
l_variablesChildWindows[index]->deleteLater();
l_variablesChildBrowsers.removeAt(index);
l_variablesChildWindows.removeAt(index);
}
void Plugin::handleRaiseVariablesWindow(QWidget *w)
{
int index = -1;
for (int i=0; i<l_variablesChildBrowsers.size(); i++) {
if (l_variablesChildBrowsers[i].widget==w) {
index = i;
break;
}
}
l_variablesChildWindows[index]->show();
}
void Plugin::changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState state)
{
......
......@@ -41,9 +41,6 @@ public:
static QString DockSideKey;
protected slots:
void prepareKumirProgramToRun();
void handleNewVariablesWindow(const Shared::BrowserComponent & browser);
void handleCloseVariablesWindow(QWidget * w);
void handleRaiseVariablesWindow(QWidget * w);
protected:
QString initialize(const QStringList &arguments);
......@@ -63,9 +60,7 @@ protected:
BrowserInterface * plugin_browser;
QList<ActorInterface*> l_plugin_actors;
BrowserComponent m_startPage;
QList<Shared::BrowserComponent> l_variablesChildBrowsers;
QList<Widgets::SecondaryWindow*> l_secondaryWindows;
QList<QWidget*> l_variablesChildWindows;
Term * m_terminal;
QMap<QString,QObject*> m_browserObjects;
KumirProgram * m_kumirProgram;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment