Ejemplo n.º 1
0
bool QT4_GuiDialog::setup(QWidget *parentWindow) {
  GWEN_WIDGET_TREE *wtree;
  GWEN_WIDGET *w;
  int rv;

  wtree=GWEN_Dialog_GetWidgets(_dialog);
  if (wtree==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No widget tree in dialog");
    return false;
  }
  w=GWEN_Widget_Tree_GetFirst(wtree);
  if (w==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No widgets in dialog");
    return false;
  }

  rv=setupTree(w);
  if (rv<0) {
    DBG_ERROR(GWEN_LOGDOMAIN, "here (%d)", rv);
    return false;
  }

  _mainWidget=(QT4_DialogBox*) GWEN_Widget_GetImplData(w, QT4_DIALOG_WIDGET_REAL);

  rv=GWEN_Dialog_EmitSignalToAll(_dialog, GWEN_DialogEvent_TypeInit, "");
  if (rv<0) {
    DBG_INFO(0, "Error initializing dialog: %d", rv);
    return false;
  }


  return true;
}
MarkingDataSetupWidget::MarkingDataSetupWidget(QList <class MarkingItemDefinition *> *markingItemDefinitionList, QList <class StudentData *> *studentList, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MarkingDataSetupWidget)
{
    ui->setupUi(this);

    ui->treeWidget->setColumnWidth(0,110);
    ui->treeWidget->setColumnWidth(1,50);
    ui->treeWidget->setColumnWidth(2,50);
    ui->treeWidget->setColumnWidth(3,50);
    ui->treeWidget->setColumnWidth(4,60);
    ui->treeWidget->setColumnWidth(5,60);

    //---- Has been passed existing data, so setup
    markingItemDefinitions = markingItemDefinitionList;
    students = studentList;
    setupTree();

    connect(ui->treeWidget,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(doubleclicked(QTreeWidgetItem*,int)));

    connect(ui->AddButton,SIGNAL(clicked()),this,SLOT(add_clicked()));
    connect(ui->UpButton,SIGNAL(clicked()),this,SLOT(up_clicked()));
    connect(ui->DownButton,SIGNAL(clicked()),this,SLOT(down_clicked()));
    connect(ui->DeleteButton,SIGNAL(clicked()),this,SLOT(remove_clicked()));
}
void MarkingDataSetupWidget::remove_clicked()
{
    bool OK=false;
    if (!students) OK = true; //---- Don't check if we are in wizard
    else
    {
        if (QMessageBox::question(this,"Delete item","Really delete this data item? Any data input to it will be lost.",QMessageBox::Yes | QMessageBox::No)==QMessageBox::Yes)
            OK=true;
    }
    if (OK)
    {
        QList<QTreeWidgetItem *> selected= ui->treeWidget->selectedItems();
        if (selected.count()!=1) return;
        int selindex=selected[0]->data(0,Qt::UserRole).toInt();

        //sort out the student data
        if (students)
        {
            for (int i=0; i<students->count(); i++)
            {
                //swap data
                StudentMarkingData *tempA = students->at(i)->data.value(selindex,0);
                if (tempA) students->at(i)->data.remove(selindex);
             }

        }

         markingItemDefinitions->removeAt(selindex);
        //fix all indices
        for (int i=0; i< markingItemDefinitions->count(); i++)
            markingItemDefinitions->at(i)->index=i;
        setupTree();
    }
}
Ejemplo n.º 4
0
ramActor::ramActor()
{
	type = RAM_NODEARRAY_TYPE_ACTOR;
	
	nodes.resize(NUM_JOINTS);
	for (int i = 0; i < nodes.size(); i++)
	{
		nodes[i].node_id = i;
	}
	
	setupTree();
}
void MarkingDataSetupWidget::add_clicked()
{
    MarkingItemDefinition *MID = new MarkingItemDefinition(markingItemDefinitions->count());
    MID->mark=true;
    MID->bullets=false;
    MID->text=true;
    MID->title="Untitled";
    MID->weight=1;
    MID->markMax=100;
    markingItemDefinitions->append(MID);
    setupTree();
}
Ejemplo n.º 6
0
LabelWidget::LabelWidget(QWidget *parent, bool showManageLabelsBtn)
	: QWidget(parent)
{
	layout = new QGridLayout;
	layout->setContentsMargins(0, 0, 0, 0);
	setupTree();
	connect(labeltree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(itemActivated(QTreeWidgetItem*, int)));

	manageLabelsBtn = new QPushButton(i18n("Manage Labels"));
	manageLabelsBtn->setVisible(showManageLabelsBtn);
	connect(manageLabelsBtn, SIGNAL(clicked()), this, SLOT(manageLabels()));
	layout->addWidget(manageLabelsBtn, 0, 1, 1, 1, Qt::AlignTop);
	setLayout(layout);
}
Ejemplo n.º 7
0
ComponentDock::ComponentDock(QWidget *Par) :
	QDockWidget("Components Editor", Par),
	eman(nullptr), mtypes(new QMenu(this))
{
	setObjectName("Components Editor");
	setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	setStyleSheet("QDockWidget { border: 3px solid; }");

	setupActions();
	setupTree();
	actionsControl(AS_ON_INITE);
	setupHTools();

	Kite::registerKiteMeta(&mman);
}
Ejemplo n.º 8
0
ResourceDock::ResourceDock(QWidget *Parrent) :
	QDockWidget("Resource Explorer", Parrent),
	fwatcher(new QFileSystemWatcher(this))
{
	setObjectName("Resources");
	setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	setStyleSheet("QDockWidget { border: 3px solid; }");
	setMinimumWidth(120);
	setFocusPolicy(Qt::StrongFocus);

	setupTree();
	setupActions();
	setupHTools();
	setupCategories();
	this->setDisabled(true);
}
Ejemplo n.º 9
0
//-----------------------------------------------------------------------------
// Function: ParameterReferenceTree::ParameterReferenceTree()
//-----------------------------------------------------------------------------
ParameterReferenceTree::ParameterReferenceTree(QSharedPointer<Component> component,
    QSharedPointer<ExpressionFormatter> expressionFormatter, QString const& targetID, QWidget *parent /* = 0 */):
QTreeWidget(parent),
component_(component),
targetID_(targetID),
expressionFormatter_(expressionFormatter)
{
    QStringList labels;
    labels << "Referencing elements" << "Referencing expression";
    setHeaderLabels(labels);

    setColumnCount(COLUMN_COUNT);
    uniformRowHeights();

    setupTree();

    setColumnWidth(ITEM_NAME, 240);
}
Ejemplo n.º 10
0
void ANNModelWrapper::setArtificialNeuralNetwork(ArtificialNeuralNetwork *ann)
{
	this->ann = ann;

	switch(ann->getType()){
		case ann_base::ArtificialNeuralNetwork::NoType:

			break;
		case ann_base::ArtificialNeuralNetwork::Adaline:
			adaline = (Adaline*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::SimplePerceptron:
			sp = (SimplePerceptron*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::MultilayerPerceptron:
			mlp = (MultilayerPerceptron*)ann;

			connect(mlp, SIGNAL(weightsChanged()), SLOT(onWeightsChanged()));
//			connect(mlp, SIGNAL(trainingAboutStart()), SLOT(onTrainingAboutStart()));
//			connect(mlp, SIGNAL(trainingFinished()), SLOT(onTrainingFinished()));
			connect(mlp, SIGNAL(layerCountChanged(int, int)), SLOT(onLayerCountChanged(int, int)));
			connect(mlp, SIGNAL(layerRemoved(int)), SLOT(onLayerRemoved(int)));
			connect(mlp, SIGNAL(layerSizeChanged(int, int, int)), SLOT(onLayerSizeChanged(int, int, int)));
			break;
		case ann_base::ArtificialNeuralNetwork::Hopfiel:
			hopfield = (Hopfield*)ann;

			//TODO: 27/4/16 put connections here
			break;
		case ann_base::ArtificialNeuralNetwork::Kohonen:
			kohonen = (Kohonen*)ann;

			//TODO: 27/4/16 put connections here
			break;

	}

	setupTree();
}
Ejemplo n.º 11
0
/*  Functions extracted out of readFromFile to enhance readability.  */
bool VertexBufferRoot::_constructFromPly( const std::string& filename )
{
    MESHINFO << "Constructing new from PLY file." << std::endl;
    
    VertexData data;
    if( _invertFaces )
        data.useInvertedFaces();
    if( !data.readPlyFile( filename ) )
    {
        MESHERROR << "Unable to load PLY file." << std::endl;
        return false;
    }

    data.calculateNormals();
    data.scale( 2.0f );
    setupTree( data );
    if( !writeToFile( filename ))
        MESHWARN << "Unable to write binary representation." << std::endl;
    
    return true;
}
Ejemplo n.º 12
0
TreeView::TreeView(const QString &title, QWidget *parent, Qt::WindowFlags flags)
	: QDockWidget(title, parent, flags)
{
	setAllowedAreas(Qt::AllDockWidgetAreas);
	setObjectName("TreeView");

	setupTree();
	setupQuestionFrame();
	setupToolbar();


	frame = new QFrame();
	layout = new QVBoxLayout;  
	layout->setContentsMargins(4, 0, 4, 4);
	layout->addWidget(toolbar);
	layout->addWidget(questionFrame);
	layout->addWidget(tree);
	frame->setLayout(layout);
	setWidget(frame);

	updateActions();
}
void MarkingDataSetupWidget::down_clicked()
{
    //---- Find selected
    QList<QTreeWidgetItem *> selected= ui->treeWidget->selectedItems();
    if (selected.count()!=1) return;
    int selindex=selected[0]->data(0,Qt::UserRole).toInt();

    if (selindex>=(markingItemDefinitions->count()-1)) return; //not if at bottom


    //---- Sort out the student data
    if (students)
    {
        for (int i=0; i<students->count(); i++)
        {
            //---- Swap data
            StudentMarkingData *tempA = students->at(i)->data.value(selindex,0);
            StudentMarkingData *tempB = students->at(i)->data.value(selindex+1,0);

            if (tempA) students->at(i)->data.remove(selindex);
            if (tempB) students->at(i)->data.remove(selindex+1);

            if (tempA) students->at(i)->data[selindex+1] = tempA;
            if (tempB) students->at(i)->data[selindex] = tempB;
        }
    }


    //now do the move down - just a swap, fixing indices
    markingItemDefinitions->swap(selindex,selindex+1);
    markingItemDefinitions->at(selindex)->index = selindex;
    markingItemDefinitions->at(selindex+1)->index = selindex+1;
    setupTree();
    ui->treeWidget->topLevelItem(selindex+1)->setSelected(true);

}
Ejemplo n.º 14
0
/****************************************************************************
Desc:	Split the root block and make two new non-leaf blocks.
		The secret here is that the root block never moves (cheers!).
		This takes a little longer but is worth the work because the
		root block never goes out to disk and is not in the cache.
****************************************************************************/
RCODE F_BtreeRoot::split(
    void *			pvCurEntry,
    FLMUINT			uiCurChildAddr)
{
    RCODE				rc = NE_FLM_OK;
    FLMBYTE *		pucEntry;
    FLMBYTE *		pucChildAddr;
    F_BtreeBlk *		pLeftBlk;
    F_BtreeBlk *		pRightBlk;
    F_BtreeBlk *		pBlk;
    FLMUINT			uiChildAddr;
    FLMUINT			uiPos;
    FLMUINT			uiEntryCount = entryCount();
    FLMUINT			uiMid = (uiEntryCount + 1) >> 1;

    if (RC_BAD( rc = setupTree( NULL, ACCESS_BTREE_NON_LEAF,
                                &pLeftBlk, &pRightBlk)))
    {
        goto Exit;
    }

    // Call search entry once just to setup for insert.

    (void) pLeftBlk->searchEntry( ENTRY_POS( 0));

    // Take the entries from the root block and move into leafs.

    for (uiPos = 0; uiPos <= uiMid; uiPos++)
    {
        pucEntry = ENTRY_POS( uiPos);
        pucChildAddr = pucEntry + m_uiEntrySize;
        uiChildAddr = (FLMUINT)FB2UD(pucChildAddr);

        if (RC_BAD( rc = pLeftBlk->insertEntry( pucEntry, uiChildAddr)))
        {
            goto Exit;
        }
    }

    // Call search entry once just to setup for insert.

    (void) pRightBlk->searchEntry( ENTRY_POS( 0));

    for (uiPos = uiMid + 1; uiPos < uiEntryCount; uiPos++)
    {
        pucEntry = ENTRY_POS( uiPos);
        pucChildAddr = pucEntry + m_uiEntrySize;
        uiChildAddr = (FLMUINT)FB2UD(pucChildAddr);

        if ((rc = pRightBlk->searchEntry( pucEntry )) != NE_FLM_NOT_FOUND)
        {
            rc = RC_SET_AND_ASSERT( NE_FLM_FAILURE);
            goto Exit;
        }

        if (RC_BAD( rc = pRightBlk->insertEntry( pucEntry, uiChildAddr)))
        {
            goto Exit;
        }
    }

    // Reset the root block and insert new midpoint.

    entryCount( 0);
    lemBlk( pRightBlk->blkAddr());	// Duplicated just in case.
    pucEntry = ENTRY_POS( uiMid);

    if ((rc = searchEntry( pucEntry )) != NE_FLM_NOT_FOUND)
    {
        rc = RC_SET_AND_ASSERT( NE_FLM_FAILURE);
        goto Exit;
    }

    if (RC_BAD( rc = insertEntry( pucEntry, pLeftBlk->blkAddr() )))
    {
        goto Exit;
    }

    // Insert the current entry (parameters) into the left or right blk.
    // This could be done a number of different ways.
    (void) searchEntry( pvCurEntry, &uiChildAddr);
    if (RC_BAD( rc = readBlk( uiChildAddr, ACCESS_BTREE_NON_LEAF, &pBlk)))
    {
        goto Exit;
    }
    (void) pBlk->searchEntry( pvCurEntry);
    if (RC_BAD( rc = pBlk->insertEntry( pvCurEntry, uiCurChildAddr)))
    {
        goto Exit;
    }

Exit:

    return( rc);
}
void MarkingDataSetupWidget::doubleclicked(QTreeWidgetItem* item, int col)
{
    //find index
    int index=item->data(0,Qt::UserRole).toInt();

    if (col==0) //title
    {
        bool ok;
        QString newtext = QInputDialog::getText(0,
                                              "Title",
                                              "New title for this item",
                                              QLineEdit::Normal,
                                              markingItemDefinitions->at(index)->title
                                              ,&ok);

            if (ok && !newtext.isEmpty())
                   markingItemDefinitions->at(index)->title = newtext;
            setupTree();
    }

    if (col==1) //text bool
    {
        markingItemDefinitions->at(index)->text = !markingItemDefinitions->at(index)->text;
        setupTree();
    }

    if (col==2) //bullet bool
    {
        markingItemDefinitions->at(index)->bullets = !markingItemDefinitions->at(index)->bullets;
        setupTree();
    }

    if (col==3) //mark bool
    {
        markingItemDefinitions->at(index)->mark = !markingItemDefinitions->at(index)->mark;
        setupTree();
    }

    if (col==4 && markingItemDefinitions->at(index)->mark)
    {
        bool ok;
        int newmax=QInputDialog::getInt(0,
                                              "Maximum Mark",
                                              "New maximum mark for this item",
                                              markingItemDefinitions->at(index)->markMax,1,10000,1,
                                              &ok);

            if (ok) markingItemDefinitions->at(index)->markMax = newmax;

            setupTree();
    }

    if (col==5 && markingItemDefinitions->at(index)->mark)
    {
        bool ok;
        int newweight=QInputDialog::getInt(0,
                                              "Weight",
                                              "New weight for this mark",
                                              markingItemDefinitions->at(index)->weight,0,10000,1,
                                              &ok);

            if (ok) markingItemDefinitions->at(index)->weight = newweight;

            setupTree();
    }
}
Ejemplo n.º 16
0
DeviceSelectDialog::DeviceSelectDialog(QWidget *parent)
    : QDialog(parent)
{
	setupUi(this);
	setupTree();
}
Ejemplo n.º 17
0
int QT4_GuiDialog::setupTree(GWEN_WIDGET *w) {
  int rv;
  Qt4_W_Widget *xw=NULL;

  switch(GWEN_Widget_GetType(w)) {
  case GWEN_Widget_TypeDialog:
    xw=new Qt4_W_Dialog(w);
    break;
  case GWEN_Widget_TypeVLayout:
    xw=new Qt4_W_VLayout(w);
    break;
  case GWEN_Widget_TypeHLayout:
    xw=new Qt4_W_HLayout(w);
    break;
  case GWEN_Widget_TypeGridLayout:
    xw=new Qt4_W_GridLayout(w);
    break;
  case GWEN_Widget_TypeLabel:
    xw=new Qt4_W_Label(w);
    break;
  case GWEN_Widget_TypeLineEdit:
    xw=new Qt4_W_LineEdit(w);
    break;
  case GWEN_Widget_TypeVSpacer:
  case GWEN_Widget_TypeHSpacer:
    /* abuse widget */
    xw=new Qt4_W_Widget(w);
    break;
  case GWEN_Widget_TypePushButton:
    xw=new Qt4_W_PushButton(w);
    break;
  case GWEN_Widget_TypeHLine:
    xw=new Qt4_W_HLine(w);
    break;
  case GWEN_Widget_TypeVLine:
    xw=new Qt4_W_VLine(w);
    break;
  case GWEN_Widget_TypeTextEdit:
    xw=new Qt4_W_TextEdit(w);
    break;
  case GWEN_Widget_TypeComboBox:
    xw=new Qt4_W_ComboBox(w);
    break;
  case GWEN_Widget_TypeTabBook:
    xw=new Qt4_W_TabBook(w);
    break;
  case GWEN_Widget_TypeTabPage:
    xw=new Qt4_W_VLayout(w);
    break;
  case GWEN_Widget_TypeCheckBox:
    xw=new Qt4_W_CheckBox(w);
    break;
  case GWEN_Widget_TypeGroupBox:
    xw=new Qt4_W_GroupBox(w);
    break;
  case GWEN_Widget_TypeWidgetStack:
    xw=new Qt4_W_WidgetStack(w);
    break;
  case GWEN_Widget_TypeTextBrowser:
    xw=new Qt4_W_TextBrowser(w);
    break;
  case GWEN_Widget_TypeScrollArea:
    xw=new Qt4_W_ScrollArea(w);
    break;
  case GWEN_Widget_TypeProgressBar:
    xw=new Qt4_W_ProgressBar(w);
    break;
  case GWEN_Widget_TypeListBox:
    xw=new Qt4_W_ListBox(w);
    break;
  case GWEN_Widget_TypeRadioButton:
    xw=new Qt4_W_RadioButton(w);
    break;
  case GWEN_Widget_TypeSpinBox:
    xw=new Qt4_W_SpinBox(w);
    break;
  default:
    DBG_ERROR(GWEN_LOGDOMAIN, "Unhandled widget type %d (%s)",
              GWEN_Widget_GetType(w), GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
    break;
  }

  if (xw==NULL) {
    DBG_ERROR(GWEN_LOGDOMAIN, "No widget created.");
    return GWEN_ERROR_INTERNAL;
  }

  rv=xw->setup();
  if (rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
    return rv;
  }
  else {
    GWEN_WIDGET *wChild;

    if (GWEN_Widget_GetType(w)==GWEN_Widget_TypeDialog)
      _mainWidget=(QT4_DialogBox*) GWEN_Widget_GetImplData(xw->getCInterface(), QT4_DIALOG_WIDGET_REAL);

    /* handle children */
    wChild=GWEN_Widget_Tree_GetFirstChild(w);
    while(wChild) {
      /* recursion */
      rv=setupTree(wChild);
      if (rv<0) {
        DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
        return rv;
      }
      wChild=GWEN_Widget_Tree_GetNext(wChild);
    }
  }

  return 0;
}