Пример #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);
                }
            }
        }
    }
}
Пример #2
0
bool QFRDRTableDelegate::eventFilter(QObject *editor, QEvent *event) {
    QWidget* w=qobject_cast<QWidget*>(editor);
    QKeyEvent* key=dynamic_cast<QKeyEvent*>(event);
    //qDebug()<<"QFRDRTableDelegate::eventFilter(event="<<event->type()<<")";
    if (w && key && event->type()==QEvent::KeyPress) {
        //qDebug()<<"QFRDRTableDelegate::eventFilter(event=QEvent::KeyPress): key_modifiers="<<key->modifiers()<<"   key="<<key->key();
        if (key->modifiers()==Qt::NoModifier && (key->key()==Qt::Key_Enter || key->key()==Qt::Key_Return)) {
            emit commitData(w);
            emit closeEditorEnhanced(w, QFRDRTableDelegate::EditNextRow);
            return true;
        } else if (key->modifiers()==Qt::ControlModifier && (key->key()==Qt::Key_Enter || key->key()==Qt::Key_Return)) {
            emit commitData(w);
            emit closeEditorEnhanced(w, QFRDRTableDelegate::EditPreviousRow);
            return true;
        } else if (key->modifiers()==Qt::NoModifier && (key->key()==Qt::Key_Down)) {
            emit commitData(w);
            emit closeEditorEnhanced(w, QFRDRTableDelegate::EditOneRowDown);
            return true;
        } else if (key->modifiers()==Qt::NoModifier && (key->key()==Qt::Key_Up)) {
            emit commitData(w);
            emit closeEditorEnhanced(w, QFRDRTableDelegate::EditOneRowUp);
            return true;
        }
    }
    return QItemDelegate::eventFilter(editor, event);
}
Пример #3
0
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;
}
bool KoDocumentSectionDelegate::eventFilter(QObject *object, QEvent *event)
{
    switch (event->type()) {
    case QEvent::MouseButtonPress: {
        if (d->edit) {
            QMouseEvent *me = static_cast<QMouseEvent*>(event);
            if (!QRect(d->edit->mapToGlobal(QPoint()), d->edit->size()).contains(me->globalPos()))
                emit closeEditor(d->edit);
        }
    }
    break;
    case QEvent::KeyPress: {
        QLineEdit *edit = qobject_cast<QLineEdit*>(object);
        if (edit && edit == d->edit) {
            QKeyEvent *ke = static_cast<QKeyEvent*>(event);
            switch (ke->key()) {
            case Qt::Key_Escape:
                emit closeEditor(edit);
                return true;
            case Qt::Key_Tab:
                emit commitData(edit);
                emit closeEditor(edit,EditNextItem);
                return true;
            case Qt::Key_Backtab:
                emit commitData(edit);
                emit closeEditor(edit, EditPreviousItem);
                return true;
            case Qt::Key_Return:
            case Qt::Key_Enter:
                emit commitData(edit);
                emit closeEditor(edit);
                return true;
            default:
                break;
            }
        }
    }
    break;
    case QEvent::FocusOut : {
        QLineEdit *edit = qobject_cast<QLineEdit*>(object);
        if (edit && edit == d->edit) {
            emit commitData(edit);
            emit closeEditor(edit);
        }
    }
    default:
        break;
    }

    return QAbstractItemDelegate::eventFilter(object, event);
}
Пример #5
0
void PropertyEditor::setValue(int value)
{
    if (QComboBox *comboBox = qobject_cast<QComboBox *>(_widget)) {
        if (comboBox->currentIndex() != value) {
            comboBox->setCurrentIndex(value);
            emit commitData(this);
        }
    }
    if (QCheckBox *checkBox = qobject_cast<QCheckBox *>(_widget)) {
        if (checkBox->isChecked() != (value == 0 ? false:true)) {
            checkBox->setChecked(value == 0 ? false:true);
            emit commitData(this);
        }
    }
}
Пример #6
0
void RadioDelegate::commitMyData()
{
    QWidget *obj = qobject_cast<QWidget*>(sender());

    emit commitData(obj);
    emit closeEditor(obj);
}
Пример #7
0
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);
}
Пример #8
0
bool QmitkPropertyDelegate::eventFilter( QObject *o, QEvent *e )
{
  // filter all kind of events on our editor widgets
  // when certain events occur, repaint all render windows, because rendering relevant properties might have changed
  switch ( e->type() )
  {
    case QEvent::KeyRelease:
    case QEvent::MouseButtonRelease:
    case QEvent::MouseButtonDblClick:
    case QEvent::Wheel:
    case QEvent::FocusIn:
    {
      if( QWidget* editor = dynamic_cast<QWidget*>(o) )
      {
        emit commitData(editor);
      }

      mitk::RenderingManager::GetInstance()->RequestUpdateAll();
      break;
    }
    default:
    {
      break;
    }
  }

  return false;
}
Пример #9
0
void SystemViewsDelegate::commitAndCloseEditor() {
	QWidget* edit = qobject_cast<QWidget*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
Пример #10
0
QWidget *DynamicPropertiesDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
        QWidget *widget = QStyledItemDelegate::createEditor(parent, option, index);

        const DynamicPropertiesModel *model = qobject_cast<const DynamicPropertiesModel*>(index.model());

        model->connectionView()->allModelNodes();

//        PropertiesComboBox *dynamicPropertiesComboBox = qobject_cast<DynamicPropertiesComboBox*>(widget);

//        if (!dynamicPropertiesComboBox) {
//            return widget;
//        }

        if (!model) {
            qWarning() << "BindingDelegate::createEditor no model";
            return widget;
        }

        if (!model->connectionView()) {
            qWarning() << "BindingDelegate::createEditor no connection view";
            return widget;
        }

        BindingProperty bindingProperty = model->bindingPropertyForRow(index.row());

        switch (index.column()) {
        case DynamicPropertiesModel::TargetModelNodeRow: {
            return 0; //no editor
        } break;
        case DynamicPropertiesModel::PropertyNameRow: {
            return QStyledItemDelegate::createEditor(parent, option, index);
        } break;
        case DynamicPropertiesModel::PropertyTypeRow: {

            PropertiesComboBox *dynamicPropertiesComboBox = new PropertiesComboBox(parent);
            connect(dynamicPropertiesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() {
                auto delegate = const_cast<DynamicPropertiesDelegate*>(this);
                emit delegate->commitData(dynamicPropertiesComboBox);
            });

            dynamicPropertiesComboBox->addItem(QLatin1String("alias"));
            //dynamicPropertiesComboBox->addItem(QLatin1String("Item"));
            dynamicPropertiesComboBox->addItem(QLatin1String("real"));
            dynamicPropertiesComboBox->addItem(QLatin1String("int"));
            dynamicPropertiesComboBox->addItem(QLatin1String("string"));
            dynamicPropertiesComboBox->addItem(QLatin1String("bool"));
            dynamicPropertiesComboBox->addItem(QLatin1String("url"));
            dynamicPropertiesComboBox->addItem(QLatin1String("color"));
            dynamicPropertiesComboBox->addItem(QLatin1String("variant"));
            return dynamicPropertiesComboBox;
        } break;
        case DynamicPropertiesModel::PropertyValueRow: {
            return QStyledItemDelegate::createEditor(parent, option, index);
        } break;
        default: qWarning() << "BindingDelegate::createEditor column" << index.column();
        }

        return 0;
}
// =============================================================================
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);
}
Пример #13
0
void ComInterfacesDelegate::commitAndCloseEditor() {
	QWidget* edit = qobject_cast<QWidget*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
Пример #14
0
bool DocumentLoader::maybeCreateArchive()
{
    // Only the top-frame can load MHTML.
    if (m_frame->tree().parent())
        return false;

    // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
    if (!isArchiveMIMEType(m_response.mimeType()))
        return false;

    ASSERT(m_mainResource);
    m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceBuffer());
    // Invalid MHTML.
    if (!m_archive || !m_archive->mainResource()) {
        m_archive.clear();
        return false;
    }

    addAllArchiveResources(m_archive.get());
    ArchiveResource* mainResource = m_archive->mainResource();

    // The origin is the MHTML file, we need to set the base URL to the document encoded in the MHTML so
    // relative URLs are resolved properly.
    ensureWriter(mainResource->mimeType(), m_archive->mainResource()->url());

    // The Document has now been created.
    document()->enforceSandboxFlags(SandboxAll);

    commitData(mainResource->data()->data(), mainResource->data()->size());
    return true;
}
Пример #15
0
void DocumentLoader::dataReceived(Resource* resource, const char* data, unsigned length)
{
    ASSERT(data);
    ASSERT(length);
    ASSERT_UNUSED(resource, resource == m_mainResource);
    ASSERT(!m_response.isNull());
    ASSERT(!mainResourceLoader() || !mainResourceLoader()->defersLoading());

    // Both unloading the old page and parsing the new page may execute JavaScript which destroys the datasource
    // by starting a new load, so retain temporarily.
    RefPtrWillBeRawPtr<LocalFrame> protectFrame(m_frame);
    RefPtr<DocumentLoader> protectLoader(this);

    m_applicationCacheHost->mainResourceDataReceived(data, length);
    m_timeOfLastDataReceived = monotonicallyIncreasingTime();

    if (isArchiveMIMEType(response().mimeType()))
        return;
    commitIfReady();
    if (!frameLoader())
        return;
    commitData(data, length);

    // If we are sending data to MediaDocument, we should stop here
    // and cancel the request.
    if (m_frame && m_frame->document()->isMediaDocument())
        cancelMainResourceLoad(ResourceError::cancelledError(m_request.url()));
}
Пример #16
0
void ComboListDelegate::onCurrentIndexChanged(int index)
{
    QComboBox* cb = static_cast<QComboBox*>(sender());
    if (cb) {
        emit commitData(cb);
    }
}
Пример #17
0
bool DataSource::setData(double *data, const int *dims, int num_dims)
{
    if (num_dims <= 0 || num_dims > 3) {
        qWarning("DataSource::setData invalid number of dimensions");
        return false;
    }

    bool num_dims_changed = (m_num_dims != num_dims);
    bool size_changed = num_dims_changed;
    m_num_dims = num_dims;
    for (int i = 0; i < 3; ++i) {
        if (i < num_dims) {
            size_changed = size_changed || (m_dims[i] != dims[i]);
            m_dims[i] = dims[i];
        } else {
            m_dims[i] = 0;
        }
    }
    m_data = data;
    if (num_dims_changed) {
        emit dataimensionsChanged();
    }
    if (size_changed) {
        emit dataSizeChanged();
    }
    commitData();
    return true;
}
Пример #18
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);
  }

}
Пример #19
0
void DocumentLoader::finishedLoading(double finishTime) {
  DCHECK(m_frame->loader().stateMachine()->creatingInitialEmptyDocument() ||
         !m_frame->page()->defersLoading() ||
         InspectorInstrumentation::isDebuggerPaused(m_frame));

  double responseEndTime = finishTime;
  if (!responseEndTime)
    responseEndTime = m_timeOfLastDataReceived;
  if (!responseEndTime)
    responseEndTime = monotonicallyIncreasingTime();
  timing().setResponseEnd(responseEndTime);

  commitIfReady();
  if (!frameLoader())
    return;

  if (!maybeCreateArchive()) {
    // If this is an empty document, it will not have actually been created yet.
    // Commit dummy data so that DocumentWriter::begin() gets called and creates
    // the Document.
    if (!m_writer)
      commitData(0, 0);
  }

  if (!m_frame)
    return;

  m_applicationCacheHost->finishedLoadingMainResource();
  endWriting();
  if (m_state < MainResourceDone)
    m_state = MainResourceDone;
  clearMainResourceHandle();
}
void CameraPropertyModelDelegate::onCheckBoxStateChanged(int)
{
	   QCheckBox *editor = qobject_cast<QCheckBox *>(sender());
    emit commitData(editor);
 //   emit closeEditor(editor);

}
Пример #21
0
void SqlDelegate::editor_closeEditor()
{
	SqlDelegateUi *ed = qobject_cast<SqlDelegateUi*>(sender());
	emit commitData(ed);
    emit dataChanged();
	emit closeEditor(ed);
}
Пример #22
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);
	}
}
Пример #23
0
void QmitkPropertyDelegate::ComboBoxCurrentIndexChanged( int  /*index*/ )
{
  if(QComboBox *comboBox = qobject_cast<QComboBox *>(sender()))
  {
    emit commitData(comboBox);
    emit closeEditor(comboBox);
  }
}
Пример #24
0
//-----------------------------------------------------------------------------
// Function: LineEditDelegate::commitAndCloseEditor()
//-----------------------------------------------------------------------------
void LineEditDelegate::commitAndCloseEditor()
{
	QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
	Q_ASSERT(edit);

	emit commitData(edit);
	emit closeEditor(edit);
}
Пример #25
0
void AntennaDelegate::commitAndCloseEditor()
{
	QDoubleSpinBox * editor = qobject_cast<QDoubleSpinBox *>(sender());
	// Commit data to the QTreeWidget
	emit commitData(editor);
	// Close the editor
	emit closeEditor(editor);
}
Пример #26
0
void OptionWidget::markAsModified()
{
	if (m_resetButton)
	{
		m_resetButton->setEnabled(m_defaultValue != getValue());
	}

	emit commitData(this);
}
Пример #27
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;
    }
}
Пример #28
0
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);
  }
}
/// Re-implemented to resolve an issue: if the parent dialog closes with
/// the editor is active any changes in it get ignored.
bool LocalParameterItemDelegate::eventFilter(QObject * obj, QEvent * ev)
{
  if ( ev->type() == QEvent::WindowDeactivate )
  {
    // Force to save the changes to the underlying model.
    emit commitData(m_currentEditor);
    return true;
  }
  return QStyledItemDelegate::eventFilter(obj,ev);
}
Пример #30
-1
void KWQTableDelegate::commitAndCloseEditor()
{
  QWidget *editor = qobject_cast<QWidget *>(sender());

  emit commitData(editor);
  emit closeEditor(editor, QAbstractItemDelegate::NoHint);
}