void SimpleEditableLabelWidget::swapMode() {
	if(m_isInEditionMode) {
		toStandardMode();
	} else {
		toEditionMode();
	}
}
void SimpleEditableLabelWidget::keyPressEvent(QKeyEvent *event) {
	if(m_isInEditionMode && event->key() == Qt::Key_Escape) {
		QString prevText = m_label->text();
		toStandardMode();
		setText(prevText);
	}
	QFrame::keyPressEvent(event);
}
Beispiel #3
0
void AbstractEditableLabelWidget::informEditionCompleted() {
	if(m_isInEditionMode) {
		m_undoStack->push(new QUndoCommand("Dummy parts editor command"));
		m_edited = true;
		emit editionCompleted(editionText());
		toStandardMode();
	}
}
void SingleConnectorInfoWidget::editionCompleted() {
	if(m_isInEditionMode) {
		m_undoStack->push(new QUndoCommand("Dummy parts editor command"));
		m_nameLabel->setText(m_nameEdit->text());
		m_descLabel->setText(m_descEdit->toPlainText());
		toStandardMode();

		emit editionFinished();
	}
}
SimpleEditableLabelWidget::SimpleEditableLabelWidget(QUndoStack *undoStack, QWidget *parent, const QString &text, bool edited)
	: QFrame(parent)
{
	setObjectName("partsBinTitle");
	m_label = new QLabel(this);
	m_lineEdit = new QLineEdit(this);
	connect(m_lineEdit,SIGNAL(editingFinished()),this,SLOT(toStandardMode()));

	QHBoxLayout *lo = new QHBoxLayout(this);
	lo->setMargin(3);
	lo->setSpacing(0);

	m_hasBeenEdited = edited;
	m_isInEditionMode = false;
	m_label->setText(text);

	m_undoStack = undoStack;
	updateUndoStackIfNecessary();

	toStandardMode(edited);
}
void SingleConnectorInfoWidget::editionCanceled() {
	m_type->cancel();
	toStandardMode();

	emit editionFinished();
}
SingleConnectorInfoWidget::SingleConnectorInfoWidget(ConnectorsInfoWidget *topLevelContainer, WaitPushUndoStack *undoStack, Connector* connector, QWidget *parent)
	: AbstractConnectorInfoWidget(topLevelContainer,parent)
{
	static QString EMPTY_CONN_NAME = QObject::tr("no name yet");
	static QString EMPTY_CONN_DESC = QObject::tr("no description yet");
	static Connector::ConnectorType EMPTY_CONN_TYPE = Connector::Male;

	QString name;
	QString description;
	Connector::ConnectorType type;

	m_undoStack = undoStack;
	m_connector = connector;

	if(connector && connector->connectorShared()) {
		m_id = connector->connectorSharedID();
		name = connector->connectorSharedName();
		if (name.isEmpty()) name = EMPTY_CONN_NAME;
		description = connector->connectorSharedDescription();
		if (description.isEmpty()) description = EMPTY_CONN_DESC;
		type = connector->connectorType();
		if (type == Connector::Unknown) type = EMPTY_CONN_TYPE;
	} else {
		name = EMPTY_CONN_NAME;
		description = EMPTY_CONN_DESC;
		type = EMPTY_CONN_TYPE;
	}

	m_nameLabel = new QLabel(name,this);
	m_nameDescSeparator = new QLabel(" - ",this);
	m_descLabel = new QLabel(description,this);
	m_descLabel->setObjectName("description");

	m_type = new ConnectorTypeWidget(type, this);

	m_nameEdit = NULL;
	m_descEdit = NULL;

	m_nameEditContainer = new QFrame(this);
	QHBoxLayout *nameLO = new QHBoxLayout(m_nameEditContainer);
	nameLO->setSpacing(0);
	nameLO->setMargin(0);
	m_nameEditContainer->hide();

	m_descEditContainer = new QFrame(this);
	QVBoxLayout *descLO = new QVBoxLayout(m_descEditContainer);
	descLO->setSpacing(0);
	descLO->setMargin(0);
	m_descEditContainer->hide();

	m_acceptButton = NULL;
	m_cancelButton = NULL;

	setSelected(false);


	QLayout *layout = new QVBoxLayout(this);
	layout->setMargin(1);

	toStandardMode();
}
Beispiel #8
0
void AbstractEditableLabelWidget::editionCanceled() {
	toStandardMode();
}
EditableTextWidget::EditableTextWidget(QString text, WaitPushUndoStack *undoStack, QWidget *parent, QString title, bool edited, bool noSpacing)
	: AbstractEditableLabelWidget(text, undoStack, parent, title, edited, noSpacing) {
	m_textEdit = new QTextEdit(this);
	m_textEdit->setFixedHeight(70);
	toStandardMode();
}
EditableDateWidget::EditableDateWidget(QDate date, WaitPushUndoStack *undoStack, QWidget *parent, QString title, bool edited, bool noSpacing)
	: AbstractEditableLabelWidget(date.toString(Qt::ISODate), undoStack, parent, title, edited, noSpacing) {
	m_dateEdit = new QDateEdit(this);
	toStandardMode();
}