Beispiel #1
0
void NotifyItemDelegate::commitAndCloseEditor()
{
    QLineEdit* editor = qobject_cast<QLineEdit*>(sender());
    if (editor) {
        emit commitData(editor);
        emit closeEditor(editor);
    } else {
        QComboBox* editor = qobject_cast<QComboBox*>(sender());
        if (editor)
        {
            emit commitData(editor);
            emit closeEditor(editor);
        } else {
            QSpinBox* editor = qobject_cast<QSpinBox*>(sender());
            if (editor)
            {
                emit commitData(editor);
                emit closeEditor(editor);
            } else {
                QCheckBox* editor = qobject_cast<QCheckBox*>(sender());
                if (editor)
                {
                    emit commitData(editor);
                    emit closeEditor(editor);
                }
            }
        }
    }
}
bool QPropertyDelegate::eventFilter(QObject *object, QEvent *event)
{
    QWidget *editor = ::qobject_cast<QWidget*>(object);

    if(!editor)
        return false;

    GD_ASSERT(editor == mActiveEditor);

    if(event->type() == QEvent::KeyPress) 
    {
        switch(static_cast<QKeyEvent *>(event)->key()) 
        {
        case Qt::Key_Tab:
            emit commitData(editor);
            emit closeEditor(editor, QAbstractItemDelegate::EditNextItem);
            mActiveEditor = 0;
            return true;
        case Qt::Key_Backtab:
            emit commitData(editor);
            emit closeEditor(editor, QAbstractItemDelegate::EditPreviousItem);
            mActiveEditor = 0;
            return true;
        case Qt::Key_Enter:
        case Qt::Key_Return:
            emit commitData(editor);
            emit closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
            mActiveEditor = 0;
            return true;
        case Qt::Key_Escape:
            // don't commit data
            emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
            mActiveEditor = 0;
            return true;
        default:
            break;
        }
    } 
    else if(event->type() == QEvent::FocusOut && !editor->isActiveWindow()) 
    {
#ifndef QT_NO_DRAGANDDROP
        // The window may loose focus during an drag operation.
        // i.e when dragging involves the task bar on Windows.
        //if(QDragManager::self() && QDragManager::self()->object != 0)
        //    return false;
#endif
        if( QApplication::activeModalWidget() && QApplication::activeModalWidget()->parent() == editor )
            return true;

        emit commitData(editor);
        emit closeEditor(editor, NoHint);
        mActiveEditor = 0;
        return true;
    }

    return false;
}
Beispiel #3
0
void SqlDelegate::editor_closeEditor()
{
	SqlDelegateUi *ed = qobject_cast<SqlDelegateUi*>(sender());
	emit commitData(ed);
    emit dataChanged();
	emit closeEditor(ed);
}
Beispiel #4
0
void SqlDelegateUi::nullButton_clicked(bool)
{
	lineEdit->setText(QString());
	m_sqlData = QString();
    emit textChanged();
	emit closeEditor();
}
Beispiel #5
0
bool DoubleDialogEditor::eventFilter(QObject *obj, QEvent *evt) {
  if (evt->type() == QEvent::FocusOut) {
    if (obj == m_editor) {
      if (!m_button->hasFocus()) {
        updateProperty();
        emit closeEditor();
      }
    } else if (obj == m_button) {
      if (!m_editor->hasFocus()) {
        updateProperty();
        emit closeEditor();
      }
    }
  }
  return QWidget::eventFilter(obj, evt);
}
Beispiel #6
0
void QmitkPropertyDelegate::commitAndCloseEditor()
{
  QWidget* editor = 0;
  if(QPushButton *pushBtn = qobject_cast<QPushButton *>(sender()))
  {
/*
    QColor result = QColorDialog::getColor(pushBtn->palette().color(QPalette::Window));
    if(result.isValid())
    {
      QPalette palette = pushBtn->palette();
      palette.setColor(QPalette::Window, result);
      pushBtn->setPalette(palette);
    }*/

    editor = pushBtn;
  }


/*
  else if(QCheckBox *chkBox = qobject_cast<QCheckBox *>(sender()))
  {
    editor = chkBox;
  }*/


  if(editor)
  {
    emit commitData(editor);
    emit closeEditor(editor);
  }

}
void ComInterfacesDelegate::commitAndCloseEditor() {
	QWidget* edit = qobject_cast<QWidget*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
// =============================================================================
void TableViewDelegate::commitAndCloseTimeEdit()
{

    QTimeEdit *editor = qobject_cast<QTimeEdit *>(sender());
    emit commitData(editor);
    emit closeEditor(editor);
}
void TableViewMenuEditorDelegate::editingFinished()
{
	TableViewMenuEditor *editor = qobject_cast<TableViewMenuEditor *>(sender());

	emit commitData(editor);
	emit closeEditor(editor);
}
Beispiel #10
0
void KWQTableDelegate::commitAndCloseEditor()
{
  QWidget *editor = qobject_cast<QWidget *>(sender());

  emit commitData(editor);
  emit closeEditor(editor, QAbstractItemDelegate::NoHint);
}
Beispiel #11
0
bool AeWindow::confirmCloseEditor(int tabindex) {
	AeEditor *e = (AeEditor*) m_tabs->widget(tabindex);

	if(e->dirty()) {
		QMessageBox confirm;
		confirm.setIcon(QMessageBox::Question);
		confirm.setText("The document `" + e->displayName() + "' has been modified");
		confirm.setInformativeText("Do you want to save your changes?");
		confirm.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
		QAbstractButton* diffButton = confirm.addButton("Show diff...", QMessageBox::ActionRole);

		int result = confirm.exec();
		while(confirm.clickedButton() == diffButton) {
			on_actionDiff_to_Saved_triggered();
			result = confirm.exec();
		}

		switch(result) {
		case QMessageBox::Save:
			if(!on_actionSave_triggered()) return false;
			break;
		case QMessageBox::Discard:
			break;
		case QMessageBox::Cancel:
			return false;
		default:
			ae_assert(false && "branch can't happen");
		}

	}

    return closeEditor(tabindex);
}
void ComboBoxDelegate::commitAndCloseEditor(int)
{
    // Emit the proper signals when editing has finished.
    QComboBox* const editor = qobject_cast<QComboBox*>(sender());
    emit commitData(editor);
    emit closeEditor(editor);
}
void RadioDelegate::commitMyData()
{
    QWidget *obj = qobject_cast<QWidget*>(sender());

    emit commitData(obj);
    emit closeEditor(obj);
}
Beispiel #14
0
//// Experimental ...
void MultiDelegate::closeEmittingEditor()
{
    QWidget*  ed = qobject_cast<QWidget*>( sender());
    Q_ASSERT(ed);
    // qDebug() << "Closing editor: type=" << ed->metaObject()->className();
    emit closeEditor( ed);
}
Beispiel #15
0
void SystemViewsDelegate::commitAndCloseEditor() {
	QWidget* edit = qobject_cast<QWidget*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
Beispiel #16
0
void BusPortsDelegate::commitAndCloseEditor() {
	// try to get pointer to editor in both cases
	QComboBox* combo = qobject_cast<QComboBox*>(sender());
	QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());

	// if the editor was combo box
	if (combo) {
		emit commitData(combo);
		emit closeEditor(combo);
	}

	// if editor was line edit
	else if (lineEdit) {
		emit commitData(lineEdit);
		emit closeEditor(lineEdit);
	}
}
Beispiel #17
0
void AntennaDelegate::commitAndCloseEditor()
{
	QDoubleSpinBox * editor = qobject_cast<QDoubleSpinBox *>(sender());
	// Commit data to the QTreeWidget
	emit commitData(editor);
	// Close the editor
	emit closeEditor(editor);
}
Beispiel #18
0
//-----------------------------------------------------------------------------
// Function: LineEditDelegate::commitAndCloseEditor()
//-----------------------------------------------------------------------------
void LineEditDelegate::commitAndCloseEditor()
{
	QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
void QmitkPropertyDelegate::ComboBoxCurrentIndexChanged( int  /*index*/ )
{
  if(QComboBox *comboBox = qobject_cast<QComboBox *>(sender()))
  {
    emit commitData(comboBox);
    emit closeEditor(comboBox);
  }
}
Beispiel #20
0
MashEditor::MashEditor(QWidget* parent) : QDialog(parent), mashObs(0)
{
   setupUi(this);

   connect(pushButton_fromEquipment, SIGNAL(clicked()), this, SLOT(fromEquipment()) );
   connect(this, SIGNAL(accepted()), this, SLOT(saveAndClose()) );
   connect(this, SIGNAL(rejected()), this, SLOT(closeEditor()) );

}
void QmitkPropertyDelegate::SpinBoxValueChanged( const QString&  /*value*/ )
{
  QAbstractSpinBox *spinBox = 0;
  if((spinBox = qobject_cast<QSpinBox *>(sender()))
    || (spinBox = qobject_cast<QDoubleSpinBox *>(sender())))
  {
    emit commitData(spinBox);
    emit closeEditor(spinBox);
  }
}
Beispiel #22
0
void LedgerDelegate::endEdit()
{
    if(d->m_editor) {
        if(d->m_editor->accepted()) {
            emit commitData(d->m_editor);
        }
        emit closeEditor(d->m_editor, NoHint);
        d->m_editorRow = -1;
    }
}
void toPLSQLEditor::closeAllEditor()
{
    int editorCount = Editors->count();
    while (editorCount > 0)
    {
        editorCount--;
        toPLSQLWidget *editor = dynamic_cast<toPLSQLWidget *>(Editors->widget(editorCount));
        if (editor)
            closeEditor(editor);
    }
}
Beispiel #24
0
void ItemDelegate::editorCancel()
{
    QAction *action = qobject_cast<QAction*>( sender() );
    Q_ASSERT(action != NULL);
    QObject *parent = action->parent();
    Q_ASSERT(parent != NULL);
    QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() );
    Q_ASSERT(editor != NULL);

    emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
}
Beispiel #25
0
/**
 * @brief commitAndCloseEditor commit value if changed.
 */
void DoubleSpinBoxDelegate::commitAndCloseEditor()
{
    QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender());
    SCASSERT(spinBox != nullptr);
    qreal value = spinBox->value();
    if (qFuzzyCompare ( lastValue, value ) == false)
    {
        lastValue = value;
        emit commitData(spinBox);
    }
    emit closeEditor(spinBox);
}
bool AMActionRunnerQueueItemDelegate3::eventFilter(QObject *object, QEvent *event)
{
	QWidget* widget = qobject_cast<QWidget*>(object);

	if(widget && event->type() == QEvent::KeyRelease) {
		QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
		if(keyEvent->key() == Qt::Key_Escape)
			emit closeEditor(widget);

	}
	return QObject::eventFilter(object, event);
}
Beispiel #27
0
void ItemDelegate::editorSave()
{
    QAction *action = qobject_cast<QAction*>( sender() );
    Q_ASSERT(action != NULL);
    QObject *parent = action->parent();
    Q_ASSERT(parent != NULL);
    QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() );
    Q_ASSERT(editor != NULL);

    emit commitData(editor);
    emit closeEditor(editor);
}
void ContactItemDelegate::editingFinished()
{
    QWidget *editor = qobject_cast<QWidget*>(sender());
    Q_ASSERT(editor);
    if (!editor)
        return;

    /* The actual editor is the container */
    editor = editor->parentWidget();

    emit commitData(editor);
    emit closeEditor(editor, QAbstractItemDelegate::SubmitModelCache);
}
Beispiel #29
0
void SqlDelegateUi::editButton_clicked(bool state)
{
	MultiEditDialog * dia = new MultiEditDialog(this);
	qApp->setOverrideCursor(Qt::WaitCursor);
	dia->setData(m_sqlData);
	qApp->restoreOverrideCursor();
	if (dia->exec())
	{
		m_sqlData = dia->data();
        emit textChanged();
	}
	emit closeEditor();
}
Beispiel #30
0
QWidget *SqlDelegate::createEditor(QWidget *parent,
								   const QStyleOptionViewItem &/* option */,
								   const QModelIndex &/* index */) const
{
	SqlDelegateUi *editor = new SqlDelegateUi(parent);
	editor->setFocus();
	editor->setFocusPolicy(Qt::StrongFocus);
	connect(editor, SIGNAL(closeEditor()),
			this, SLOT(editor_closeEditor()));
    connect(editor, SIGNAL(textChanged()),
            this, SLOT(editor_textChanged()));
	return editor;
}