AbstractEditableLabelWidget::AbstractEditableLabelWidget(QString text, WaitPushUndoStack *undoStack, QWidget *parent, QString title, bool edited, bool noSpacing) : QFrame(parent) { m_noSpacing = noSpacing; m_edited = edited; m_isInEditionMode = false; m_undoStack = undoStack; QGridLayout *layout = new QGridLayout; if(!title.isNull() && !title.isEmpty()) { m_title = new QLabel(title, this); m_title->setObjectName("title"); layout->addWidget(m_title,0,0); } else { m_title = NULL; } setLayout(layout); m_label = new EditableLabel(text, this); connect(m_label,SIGNAL(editionStarted(QString)),this,SLOT(editionStarted(QString))); connect(this,SIGNAL(editionCompleted(QString)),m_label,SLOT(editionCompleted(QString))); m_acceptButton = new QPushButton(tr("Accept"), this); connect(m_acceptButton,SIGNAL(clicked()),this,SLOT(informEditionCompleted())); m_cancelButton = new QPushButton(tr("Cancel"), this); connect(m_cancelButton,SIGNAL(clicked()),this,SLOT(editionCanceled())); }
void SingleConnectorInfoWidget::toEditionMode() { hide(); setInEditionMode(true); hideIfNeeded(m_nameLabel); hideIfNeeded(m_nameDescSeparator); hideIfNeeded(m_descLabel); createInputs(); // first row QHBoxLayout *firstRowLayout = new QHBoxLayout(); firstRowLayout->addWidget(m_type); firstRowLayout->addSpacerItem(new QSpacerItem(10,0)); firstRowLayout->addWidget(m_nameEditContainer); firstRowLayout->addSpacerItem(new QSpacerItem(0,0,QSizePolicy::Expanding)); firstRowLayout->addWidget(m_removeButton); m_nameEditContainer->show(); // second row m_descEditContainer->show(); // third row if(!m_acceptButton) { m_acceptButton = new QPushButton(QObject::tr("Accept"),this); connect(m_acceptButton,SIGNAL(clicked()),this,SLOT(editionCompleted())); } m_acceptButton->show(); if(!m_cancelButton) { m_cancelButton = new QPushButton(QObject::tr("Cancel"),this); connect(m_cancelButton,SIGNAL(clicked()),this,SLOT(editionCanceled())); } m_cancelButton->show(); QHBoxLayout *thirdRowLayout = new QHBoxLayout(); thirdRowLayout->addSpacerItem(new QSpacerItem(0,0,QSizePolicy::Expanding)); thirdRowLayout->addWidget(m_acceptButton); thirdRowLayout->addWidget(m_cancelButton); QVBoxLayout *layout = (QVBoxLayout*)this->layout(); layout->addLayout(firstRowLayout); layout->addWidget(m_descEditContainer); layout->addLayout(thirdRowLayout); setFixedHeight(SingleConnectorHeight*4); setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); updateGeometry(); show(); setFocus(); emit editionStarted(); }