bool MLModel::isSupportedAction( actions action, const QModelIndex &index ) const { switch ( action ) { case ACTION_ADDTOPLAYLIST: return index.isValid(); case ACTION_SORT: return false; case ACTION_PLAY: case ACTION_STREAM: case ACTION_SAVE: case ACTION_INFO: case ACTION_REMOVE: return index.isValid(); case ACTION_EXPLORE: if( index.isValid() ) return getURI( index ).startsWith( "file://" ); case ACTION_CREATENODE: return false; case ACTION_CLEAR: return rowCount() && canEdit(); case ACTION_ENQUEUEFILE: case ACTION_ENQUEUEDIR: case ACTION_ENQUEUEGENERIC: return canEdit(); default: return false; } return false; }
void ChatData::invalidateParticipants() { auto wasCanEdit = canEdit(); participants.clear(); admins.clear(); removeFlags(MTPDchat::Flag::f_admin); invitedByMe.clear(); botStatus = 0; if (wasCanEdit != canEdit()) { Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::ChatCanEdit); } Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::MembersChanged | Notify::PeerUpdate::Flag::AdminsChanged); }
bool Editor::handleEditingKeyboardEvent(KeyboardEvent* evt) { const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); // do not treat this as text input if it's a system key event if (!keyEvent || keyEvent->isSystemKey()) return false; String commandName = behavior().interpretKeyEvent(*evt); Command command = this->createCommand(commandName); if (keyEvent->type() == PlatformEvent::RawKeyDown) { // WebKit doesn't have enough information about mode to decide how // commands that just insert text if executed via Editor should be treated, // so we leave it upon WebCore to either handle them immediately // (e.g. Tab that changes focus) or let a keypress event be generated // (e.g. Tab that inserts a Tab character, or Enter). if (command.isTextInsertion() || commandName.isEmpty()) return false; return command.execute(evt); } if (command.execute(evt)) return true; if (!behavior().shouldInsertCharacter(*evt) || !canEdit()) return false; // Return true to prevent default action. e.g. Space key scroll. if (dispatchBeforeInputInsertText(evt->target(), evt->keyEvent()->text()) != DispatchEventResult::NotCanceled) return true; return insertText(evt->keyEvent()->text(), evt); }
bool Editor::deleteWithDirection(SelectionDirection direction, TextGranularity granularity, bool isTypingAction) { if (!canEdit()) return false; if (m_frame.selection().isRange()) { if (isTypingAction) { ASSERT(m_frame.document()); TypingCommand::deleteKeyPressed(*m_frame.document(), canSmartCopyOrDelete() ? TypingCommand::SmartDelete : 0, granularity); revealSelectionAfterEditingOperation(); } else { deleteSelectionWithSmartDelete(canSmartCopyOrDelete()); // Implicitly calls revealSelectionAfterEditingOperation(). } } else { TypingCommand::Options options = 0; if (canSmartCopyOrDelete()) options |= TypingCommand::SmartDelete; switch (direction) { case DirectionForward: case DirectionRight: ASSERT(m_frame.document()); TypingCommand::forwardDeleteKeyPressed(*m_frame.document(), options, granularity); break; case DirectionBackward: case DirectionLeft: ASSERT(m_frame.document()); TypingCommand::deleteKeyPressed(*m_frame.document(), options, granularity); break; } revealSelectionAfterEditingOperation(); } return true; }
bool Editor::executeCommand(const String& commandName, const String& value) { // moveToBeginningOfDocument and moveToEndfDocument are only handled by WebKit for editable nodes. if (!canEdit() && commandName == "moveToBeginningOfDocument") return m_frame.eventHandler().bubblingScroll(ScrollUp, ScrollByDocument); if (!canEdit() && commandName == "moveToEndOfDocument") return m_frame.eventHandler().bubblingScroll(ScrollDown, ScrollByDocument); if (commandName == "showGuessPanel") { spellChecker().showSpellingGuessPanel(); return true; } return command(commandName).execute(value); }
IntRect Editor::firstRectForCharacterInSelectedRange() { if (canEdit()) { return reinterpret_cast<EditView *>(m_editingView.get())->firstRectForCharacterInSelectedRange(); } return IntRect(); }
void TransformEditorWidget::setEditable( const Engine::ItemEntry& ent ) { delete m_translationEditor; TransformEditor::setEditable( ent ); if ( canEdit() ) { m_translationEditor = new VectorEditor(0, QString::fromStdString(getEntryName( Engine::RadiumEngine::getInstance(), m_currentEdit)), true ); connect(m_translationEditor, &VectorEditor::valueChanged, this, &TransformEditorWidget::onChangedPosition); } }
void TransformEditorWidget::updateValues() { if( canEdit() ) { getTransform(); CORE_ASSERT( m_translationEditor, "No edtitor widget !"); m_translationEditor->blockSignals( true ); m_translationEditor->setValue(m_transform.translation()); m_translationEditor->blockSignals( false ); } }
bool Editor::canPaste() const { // i want to check whether the clipboard has data before enabling the paste menu FrameLoaderClientApollo* const loaderClient = FrameLoaderClientApollo::clientApollo(m_frame); ASSERT(loaderClient); WTF::OwnPtr<ClipboardApolloHelper> clipboard(loaderClient->createGeneralClipboard()); bool clipboardHasData = !clipboard->types().isEmpty(); return canEdit() && clipboardHasData; }
bool Editor::insertLineBreak() { if (!canEdit()) return false; VisiblePosition caret = m_frame.selection().selection().visibleStart(); bool alignToEdge = isEndOfEditableOrNonEditableContent(caret); ASSERT(m_frame.document()); TypingCommand::insertLineBreak(*m_frame.document(), 0); revealSelectionAfterEditingOperation(alignToEdge ? ScrollAlignment::alignToEdgeIfNeeded : ScrollAlignment::alignCenterIfNeeded); return true; }
Qt::ItemFlags PLModel::flags( const QModelIndex &index ) const { Qt::ItemFlags flags = QAbstractItemModel::flags( index ); const PLItem *item = index.isValid() ? getItem( index ) : rootItem; if( canEdit() ) { vlc_playlist_locker pl_lock ( THEPL ); playlist_item_t *plItem = playlist_ItemGetById( p_playlist, item->i_playlist_id ); if ( plItem && ( plItem->i_children > -1 ) ) flags |= Qt::ItemIsDropEnabled; } flags |= Qt::ItemIsDragEnabled; return flags; }
void Editor::transpose() { if (!canEdit()) return; VisibleSelection selection = m_frame.selection().selection(); if (!selection.isCaret()) return; // Make a selection that goes back one character and forward two characters. VisiblePosition caret = selection.visibleStart(); VisiblePosition next = isEndOfParagraph(caret) ? caret : caret.next(); VisiblePosition previous = next.previous(); if (next == previous) return; previous = previous.previous(); if (!inSameParagraph(next, previous)) return; RefPtr<Range> range = makeRange(previous, next); if (!range) return; VisibleSelection newSelection(range.get(), DOWNSTREAM); // Transpose the two characters. String text = plainText(range.get()); if (text.length() != 2) return; String transposed = text.right(1) + text.left(1); // Select the two characters. if (newSelection != m_frame.selection().selection()) m_frame.selection().setSelection(newSelection); // Insert the transposed characters. replaceSelectionWithText(transposed, false, false); }
bool Editor::canPaste() const { return canEdit(); }
bool CLineEdit::canOpen() { return VirtualClusterLineEdit::canOpen() && !canEdit(); }
bool GtkInputMethodFilter::filterKeyEvent(GdkEventKey* event) { if (!canEdit() || !m_enabled) return sendSimpleKeyEvent(event); m_preeditChanged = false; m_filteringKeyEvent = true; unsigned int lastFilteredKeyPressCodeWithNoResults = m_lastFilteredKeyPressCodeWithNoResults; m_lastFilteredKeyPressCodeWithNoResults = GDK_KEY_VoidSymbol; bool filtered = gtk_im_context_filter_keypress(m_context.get(), event); m_filteringKeyEvent = false; bool justSentFakeKeyUp = m_justSentFakeKeyUp; m_justSentFakeKeyUp = false; if (justSentFakeKeyUp && event->type == GDK_KEY_RELEASE) return true; // Simple input methods work such that even normal keystrokes fire the // commit signal. We detect those situations and treat them as normal // key events, supplying the commit string as the key character. if (filtered && !m_composingTextCurrently && !m_preeditChanged && m_confirmedComposition.length() == 1) { bool result = sendSimpleKeyEvent(event, m_confirmedComposition); m_confirmedComposition = String(); return result; } if (filtered && event->type == GDK_KEY_PRESS) { if (!m_preeditChanged && m_confirmedComposition.isNull()) { m_composingTextCurrently = true; m_lastFilteredKeyPressCodeWithNoResults = event->keyval; return true; } bool result = sendKeyEventWithCompositionResults(event); if (!m_confirmedComposition.isEmpty()) { m_composingTextCurrently = false; m_confirmedComposition = String(); } return result; } // If we previously filtered a key press event and it yielded no results. Suppress // the corresponding key release event to avoid confusing the web content. if (event->type == GDK_KEY_RELEASE && lastFilteredKeyPressCodeWithNoResults == event->keyval) return true; // At this point a keystroke was either: // 1. Unfiltered // 2. A filtered keyup event. As the IME code in EditorClient.h doesn't // ever look at keyup events, we send any composition results before // the key event. // Both might have composition results or not. // // It's important to send the composition results before the event // because some IM modules operate that way. For example (taken from // the Chromium source), the latin-post input method gives this sequence // when you press 'a' and then backspace: // 1. keydown 'a' (filtered) // 2. preedit changed to "a" // 3. keyup 'a' (unfiltered) // 4. keydown Backspace (unfiltered) // 5. commit "a" // 6. preedit end if (!m_confirmedComposition.isEmpty()) confirmComposition(); if (m_preeditChanged) updatePreedit(); return sendSimpleKeyEvent(event); }