Commit 47136000 authored by Alexander A. Maly's avatar Alexander A. Maly

Astyled GrassHopper

parent 201b6b3a
Pipeline #2301 failed with stages
in 2 minutes and 25 seconds
//
// C++ Implementation: new task dialog
//
// Description:
// Description:
//
//
// Author: Denis Khachko <mordol@lpm.org.ru>
......@@ -9,46 +9,176 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#include "dialog.h"
#include <QDebug>
Dialog::Dialog(QWidget *parent, Qt::WindowFlags fl): QDialog(parent, fl), Ui::Dialog()
{
setupUi(this);
connect(BaseA, SIGNAL(valueChanged(int)), this, SLOT(setMax()));
connect(BaseB, SIGNAL(valueChanged(int)), this, SLOT(setMax()));
connect(pushButton, SIGNAL(clicked()), this, SLOT(addFlag()));
connect(pushButton_2, SIGNAL(clicked()), this, SLOT(removeFlag()));
connect(listWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(enableDelete()));
translateButtons();
}
Dialog::~Dialog() {}
void Dialog::setMax()
{
int max = BaseA->value();
if (BaseB->value() > max) {
max = BaseB->value();
}
}
Dialog::Dialog(QWidget* parent, Qt::WindowFlags fl ): QDialog ( parent, fl ), Ui::Dialog()
void Dialog::addFlag()
{
setupUi(this);
connect(BaseA,SIGNAL(valueChanged ( int )),this,SLOT(setMax()));
connect(BaseB,SIGNAL(valueChanged ( int )),this,SLOT(setMax()));
connect(pushButton,SIGNAL(clicked( )),this,SLOT(addFlag()));
connect(pushButton_2,SIGNAL(clicked( )),this,SLOT(removeFlag()));
connect(listWidget,SIGNAL(itemClicked (QListWidgetItem*)),this,SLOT(enableDelete()));
translateButtons();
};
void Dialog::setMax()
{
QList<QListWidgetItem *> flags = listWidget->findItems(NeedA->cleanText(), Qt::MatchExactly);
if (flags.count() > 0) {
return;
}
listWidget->addItem(NeedA->cleanText());
}
void Dialog::enableDelete()
{
pushButton_2->setEnabled(true);
}
int max=BaseA->value();
if(BaseB->value()>max)max=BaseB->value();
void Dialog::removeFlag()
{
QList<QListWidgetItem *> selectedItems = listWidget->selectedItems();
qDebug() << "Item Count" << selectedItems.count();
for (int i = 0; i < selectedItems.count(); i++) {
listWidget->takeItem(listWidget->row(selectedItems[i]));
}
if (listWidget->selectedItems().count() == 0) {
pushButton_2->setEnabled(false);
}
}
};
int Dialog::ASize() const
{
return BaseA->value();
}
int Dialog::BSize() const
{
return BaseB->value();
}
int Dialog::ANeed() const
{
return NeedA->value();
}
void Dialog::setSizes(int A, int B)
{
BaseA->setValue(A);
BaseB->setValue(B);
}
int Dialog::getStart() const
{
if (!taskNeeded->isChecked()) {
return 0;
}
return StartPos->value();
}
QList<int> Dialog::getFlags()
{
QList<int> toRet;
if (!taskNeeded->isChecked()) {
return toRet;
}
for (int i = 0; i < listWidget->count(); i++) {
toRet.append(listWidget->item(i)->text().toInt());
}
return toRet;
}
int Dialog::getLeftBorder() const
{
if (!taskNeeded->isChecked()) {
return 0;
}
return spinBox->value();
}
int Dialog::getRightBorder() const
{
if (!taskNeeded->isChecked()) {
return 0;
}
return spinBox_2->value();
}
void Dialog::setLeftBorder(int pos)
{
spinBox->setValue(pos);
}
void Dialog::setRightBorder(int pos)
{
spinBox_2->setValue(pos);
}
void Dialog::setStart(int pos)
{
StartPos->setValue(pos);
}
void Dialog::setFlags(QList<int> flags)
{
listWidget->clear();
for (int i = 0; i < flags.count(); i++) {
listWidget->addItem(QString::number(flags[i]));
}
}
bool Dialog::borders() const
{
return Borders->isChecked();
}
void Dialog::setBordersChB(bool brd)
{
Borders->setChecked(brd);
if (!brd) {
return;
}
spinBox->setEnabled(true);
spinBox_2->setEnabled(true);
}
bool Dialog::isTaskNeeded() const
{
return taskNeeded->isChecked();
}
void Dialog::setTaskNeeded(bool task)
{
taskNeeded->setChecked(task);
if (!task) {
return;
}
frame_3->setEnabled(true);
//qDebug() << "frame_3->ENABLED!";
}
void Dialog::translateButtons()
{
QList<QAbstractButton *>btns = buttonBox->buttons();
for (int i = 0; i < btns.count(); i++) {
if (buttonBox->buttonRole(btns[i]) == QDialogButtonBox::RejectRole) {
btns[i]->setText(trUtf8("Отмена"));
}
}
}
void Dialog::addFlag()
{
QList<QListWidgetItem *> flags=listWidget->findItems(NeedA->cleanText(),Qt::MatchExactly);
if(flags.count()>0)return;
listWidget->addItem(NeedA->cleanText());
};
void Dialog::enableDelete()
{
pushButton_2->setEnabled(true);
};
void Dialog::removeFlag()
{
QList<QListWidgetItem *> selectedItems=listWidget->selectedItems ();
qDebug()<<"Item Count"<<selectedItems.count();
for(int i=0;i<selectedItems.count();i++)listWidget->takeItem (listWidget->row(selectedItems[i]));
if(listWidget->selectedItems ().count()==0)pushButton_2->setEnabled(false);
};
......@@ -16,113 +16,50 @@
#include "ui_dialog.h"
#include <QtCore>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
class Dialog : public QDialog, Ui::Dialog
{
Q_OBJECT
public:
Dialog ( QWidget* parent = 0, Qt::WindowFlags fl = 0 );
~Dialog(){};
int ASize(){return BaseA->value();};
int BSize(){return BaseB->value();};
int ANeed(){return NeedA->value();};
void setSizes(int A,int B)
{
BaseA->setValue(A);
BaseB->setValue(B);
};
int getStart()
{
if(!taskNeeded->isChecked())return 0;
return StartPos->value();
};
QList<int> getFlags()
{
QList<int> toRet;
if(!taskNeeded->isChecked())return toRet;
for(int i=0;i<listWidget->count ();i++)
toRet.append(listWidget->item(i)->text().toInt());
return toRet;
};
int getLeftBorder()
{
if(!taskNeeded->isChecked())return 0;
return spinBox->value();
};
int getRightBorder()
{
if(!taskNeeded->isChecked())return 0;
return spinBox_2->value();
};
void setLeftBorder(int pos)
{
spinBox->setValue(pos);
};
void setRightBorder(int pos)
{
spinBox_2->setValue(pos);
};
void setStart(int pos)
{
StartPos->setValue(pos);
};
void setFlags(QList<int> flags)
{
listWidget->clear();
for(int i=0;i<flags.count();i++)
listWidget->addItem(QString::number(flags[i]));
};
bool borders()
{
return Borders->isChecked();
};
void setBordersChB(bool brd)
{
Borders->setChecked(brd);
if(!brd)return;
spinBox->setEnabled(true);
spinBox_2->setEnabled(true);
};
bool isTaskNeeded()
{
return taskNeeded->isChecked();
};
void setTaskNeeded(bool task)
{
taskNeeded->setChecked(task);
if(!task)return;
frame_3->setEnabled(true);
qDebug()<<"frame_3->ENABLED!";
};
void translateButtons()
{
QList<QAbstractButton *>btns = buttonBox->buttons();
for(int i=0;i<btns.count();i++)
{
if(buttonBox->buttonRole(btns[i])==QDialogButtonBox::RejectRole)btns[i]->setText(trUtf8("Отмена"));
}
}
public slots:
void setMax();
void addFlag();
void enableDelete();
void removeFlag();
public:
Dialog(QWidget *parent = 0, Qt::WindowFlags fl = 0);
~Dialog();
int ASize() const;
int BSize() const;
int ANeed() const;
void setSizes(int A, int B);
int getStart() const;
void setStart(int pos);
int getLeftBorder() const;
int getRightBorder() const;
void setLeftBorder(int pos);
void setRightBorder(int pos);
QList<int> getFlags();
void setFlags(QList<int> flags);
bool borders() const;
void setBordersChB(bool brd);
bool isTaskNeeded() const;
void setTaskNeeded(bool task);
void translateButtons();
public slots:
void setMax();
void addFlag();
void enableDelete();
void removeFlag();
};
......@@ -9,176 +9,182 @@ You should change it corresponding to functionality.
// Self include
#include "grasshoppermodule.h"
#include "pult.h"
// Kumir includes
#include <kumir2-libs/extensionsystem/kplugin.h>
#include "kuznec.h"
// Qt includes
#include <QtCore>
#include <QtGui>
namespace ActorGrasshopper {
namespace ActorGrasshopper
{
class AAA : public QWidget {
class AAA : public QWidget
{
public:
inline explicit AAA(QWidget * pult): QWidget(), pult_(pult) {
setLayout(new QVBoxLayout);
layout()->setContentsMargins(0, 0, 0, 0);
layout()->addWidget(pult);
}
inline QSize minimumSizeHint() const { return pult_->minimumSizeHint(); }
inline explicit AAA(QWidget *pult): QWidget(), pult_(pult)
{
setLayout(new QVBoxLayout);
layout()->setContentsMargins(0, 0, 0, 0);
layout()->addWidget(pult);
}
inline QSize minimumSizeHint() const
{
return pult_->minimumSizeHint();
}
private:
QWidget * pult_;
QWidget *pult_;
};
GrasshopperModule::GrasshopperModule(ExtensionSystem::KPlugin * parent)
: GrasshopperModuleBase(parent)
GrasshopperModule::GrasshopperModule(ExtensionSystem::KPlugin *parent)
: GrasshopperModuleBase(parent)
{
kuznec=nullptr;
kuznec = nullptr;
// Module constructor, called once on plugin load
// TODO implement me
// Module constructor, called once on plugin load
// TODO implement me
}
void GrasshopperModule::createGui()
{
kuznec=new KumKuznec(myResourcesDir());
kuznec->myModule=this;
connect(m_actionGrasshopperNewEnvironment,SIGNAL(triggered()) ,kuznec , SLOT(ClearPicture()));
connect(m_actionGrasshopperLoadEnvironment,SIGNAL(triggered()) ,kuznec , SLOT(LoadFromFileActivated()));
connect(m_actionGrasshopperSave,SIGNAL(triggered()) ,kuznec , SLOT(SaveToFileActivated()));
kuznec = new KumKuznec(myResourcesDir());
kuznec->myModule = this;
connect(m_actionGrasshopperNewEnvironment, SIGNAL(triggered()), kuznec, SLOT(ClearPicture()));
connect(m_actionGrasshopperLoadEnvironment, SIGNAL(triggered()), kuznec, SLOT(LoadFromFileActivated()));
connect(m_actionGrasshopperSave, SIGNAL(triggered()), kuznec, SLOT(SaveToFileActivated()));
}
QString GrasshopperModule::initialize(const QStringList &configurationParameters, const ExtensionSystem::CommandLine &)
{
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
if (!configurationParameters.contains("tablesOnly")) {
createGui();
}
return "";
}
QVariantList GrasshopperModule::templateParameters() const{
QVariantList jumps;
jumps.append(kuznec->Fstep);
jumps.append(kuznec->Bstep);
return jumps;
};
QVariantList GrasshopperModule::templateParameters() const
{
QVariantList jumps;
jumps.append(kuznec->Fstep);
jumps.append(kuznec->Bstep);
return jumps;
};
/* public static */ QList<ExtensionSystem::CommandLineParameter> GrasshopperModule::acceptableCommandLineParameters()
{
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
return QList<ExtensionSystem::CommandLineParameter>();
// See "src/shared/extensionsystem/commandlineparameter.h" for constructor details
return QList<ExtensionSystem::CommandLineParameter>();
}
/* public slot */ void GrasshopperModule::changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current)
{
// Called when changed kumir state. The states are defined as enum ExtensionSystem::GlobalState:
/*
namespace ExtensionSystem {
enum GlobalState {
GS_Unlocked, // Edit mode
GS_Observe, // Observe mode
GS_Running, // Running mode
GS_Input, // User input required
GS_Pause // Running paused
};
}
*/
// TODO implement me
using namespace ExtensionSystem; // not to write "ExtensionSystem::" each time in this method scope
if(old==Shared::PluginInterface::GS_Running && current==Shared::PluginInterface::GS_Observe)kuznec->FindKuznec();
Q_UNUSED(old); // Remove this line on implementation
Q_UNUSED(current); // Remove this line on implementation
// Called when changed kumir state. The states are defined as enum ExtensionSystem::GlobalState:
/*
namespace ExtensionSystem {
enum GlobalState {
GS_Unlocked, // Edit mode
GS_Observe, // Observe mode
GS_Running, // Running mode
GS_Input, // User input required
GS_Pause // Running paused
};
}
*/
// TODO implement me
using namespace ExtensionSystem; // not to write "ExtensionSystem::" each time in this method scope
if (old == Shared::PluginInterface::GS_Running && current == Shared::PluginInterface::GS_Observe) {
kuznec->FindKuznec();
}
Q_UNUSED(old); // Remove this line on implementation
Q_UNUSED(current); // Remove this line on implementation
}
/* public slot */ void GrasshopperModule::loadActorData(QIODevice * source)
/* public slot */ void GrasshopperModule::loadActorData(QIODevice *source)
{
// Set actor specific data (like environment)
// The source should be ready-to-read QIODevice like QBuffer or QFile
Q_UNUSED(source); // By default do nothing
// Set actor specific data (like environment)
// The source should be ready-to-read QIODevice like QBuffer or QFile
Q_UNUSED(source); // By default do nothing
}
/* public */ QWidget* GrasshopperModule::mainWidget() const
/* public */ QWidget *GrasshopperModule::mainWidget() const
{
if (!kuznec) return 0;
// Returns module main view widget, or nullptr if there is no any views
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
// TODO implement me
return kuznec->mainWindow();
if (!kuznec) {
return 0;
}
// Returns module main view widget, or nullptr if there is no any views
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
// TODO implement me
return kuznec->mainWindow();
}
void GrasshopperModule::jumpsChanged()
{
emit notifyOnTemplateParametersChanged();
};
/* public */ QWidget* GrasshopperModule::pultWidget() const
{
if (!kuznec) return 0;
// Returns module control view widget, or nullptr if there is no control view
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
// TODO implement me
static QWidget * dummy = new AAA(kuznec->Kpult);
return dummy;
{
emit notifyOnTemplateParametersChanged();
};
/* public */ QWidget *GrasshopperModule::pultWidget() const
{
if (!kuznec) {
return 0;
}
// Returns module control view widget, or nullptr if there is no control view
// NOTE: the method is const and might be called at any time,
// so DO NOT create widget here, just return!
// TODO implement me
static QWidget *dummy = new AAA(kuznec->Kpult);
return dummy;
}
/* public slot */ void GrasshopperModule::reloadSettings(ExtensionSystem::SettingsPtr settings, const QStringList & keys)
/* public slot */ void GrasshopperModule::reloadSettings(ExtensionSystem::SettingsPtr settings, const QStringList &keys)
{
// Updates setting on module load, workspace change or appliyng settings dialog.
// If @param keys is empty -- should reload all settings, otherwise load only setting specified by @param keys
// TODO implement me
Q_UNUSED(settings); // Remove this line on implementation
Q_UNUSED(keys); // Remove this line on implementation
// Updates setting on module load, workspace change or appliyng settings dialog.
// If @param keys is empty -- should reload all settings, otherwise load only setting specified by @param keys
// TODO implement me
Q_UNUSED(settings); // Remove this line on implementation
Q_UNUSED(keys); // Remove this line on implementation
}
/* public slot */ void GrasshopperModule::reset()
{
// Resets module to initial state before program execution
// TODO implement me
kuznec->Reset();
// Resets module to initial state before program execution
// TODO implement me
kuznec->Reset();
}
/* public slot */ void GrasshopperModule::setAnimationEnabled(bool enabled)