// -----------------------------------------------------------------------------
// CTestSDKCFD::TestEHKEYConstructFromResourceL
// -----------------------------------------------------------------------------
//
TInt CTestSDKEIKHKEYT::TestEHKEYConstructFromResourceL( CStifItemParser& /*aItem*/ )
    {
    CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
    CleanupStack::PushL( hotkeytableptr );
    
    hotkeytableptr->ConstructFromResourceL( R_TEST_HOTKEYS );
    
    TResourceReader reader;
    CCoeEnv::Static()->CreateResourceReaderLC(reader,R_TEST_HOTKEYS);
    
    TInt numberPlain( KZero );
    numberPlain = reader.ReadInt16();
    if( numberPlain )
        {
        const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
        reader.Advance(numberPlain*sizeof(SEikHotKey));
        TBool flag(EFalse);
        TInt keycode( KZero );
        TInt commandId( KZero );
        TInt modifires( KZero );
        commandId = ptr->iCommandId;
        flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
        STIF_ASSERT_TRUE( flag );
        }
    
    TInt numberCtrl( KZero );
    numberCtrl = reader.ReadInt16();
    if( numberCtrl )
        {
        const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
        reader.Advance(numberCtrl*sizeof(SEikHotKey));
        TBool flag(EFalse);
        TInt keycode( KZero );
        TInt commandId( KZero );
        TInt modifires(EModifierCtrl);
        commandId = ptr->iCommandId;
        flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
        STIF_ASSERT_TRUE( flag );
        }
    
    TInt numberShiftCtrl( KZero );
    numberShiftCtrl = reader.ReadInt16();
    if( numberShiftCtrl )
        {
        const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr();
        reader.Advance(numberShiftCtrl*sizeof(SEikHotKey));
        TBool flag(EFalse);
        TInt keycode( KZero );
        TInt commandId( KZero );
        TInt modifires(EModifierShift|EModifierCtrl);
        commandId = ptr->iCommandId;
        flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires );
        STIF_ASSERT_TRUE( flag );
        }
    
    CleanupStack::PopAndDestroy( KTwo );//reader, hotkeytableptr
    return KErrNone;
    }
// -----------------------------------------------------------------------------
// CTestSDKCFD::TestEHKEYRemoveItem
// -----------------------------------------------------------------------------
//
TInt CTestSDKEIKHKEYT::TestEHKEYRemoveItemL( CStifItemParser& /*aItem*/ )
    {
    CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
    CleanupStack::PushL( hotkeytableptr );

    TInt commandId( KOne );
    TInt keycode( KTwo );
    TInt modifiers( KZero );
    hotkeytableptr->AddItemL( commandId, keycode, modifiers );
    
    TBool flag;
    TInt returnkeycode;
    TInt returncommandId;
    flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
        modifiers );
    returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
    
    STIF_ASSERT_TRUE( flag );
    STIF_ASSERT_EQUALS( keycode, returnkeycode );
    STIF_ASSERT_EQUALS( commandId, returncommandId );
    
    hotkeytableptr->RemoveItem( commandId );
    returnkeycode = 0;
    
    flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
        modifiers );
    returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
    STIF_ASSERT_FALSE( flag );
    STIF_ASSERT_NOT_EQUALS( keycode, returnkeycode );
    STIF_ASSERT_NOT_EQUALS( commandId, returncommandId );
    CleanupStack::PopAndDestroy( hotkeytableptr );
    
    return KErrNone;
    }
// -----------------------------------------------------------------------------
// CTestSDKCFD::TestEHKEYHotKeyFromCommandId
// -----------------------------------------------------------------------------
//
TInt CTestSDKEIKHKEYT::TestEHKEYHotKeyFromCommandIdL( CStifItemParser& /*aItem*/ )
    {
    CEikHotKeyTable* hotkeytableptr;
    hotkeytableptr = new( ELeave ) CEikHotKeyTable;
    CleanupStack::PushL( hotkeytableptr );

    TInt commandId( KOne );
    TInt keycode( KTwo );
    TInt modifiers( KZero );
    hotkeytableptr->AddItemL( commandId, keycode, modifiers );
    
    TInt commandId2( KTwo );
    TInt keycode2( KThree );
    TInt modifiers2( KZero );
    hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 );
    
    TInt returnkeycode;
    TInt returnkeycode2;
    TBool flag;
    TBool flag2;
    flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode,
        modifiers );
    STIF_ASSERT_TRUE( flag );
    flag2 = hotkeytableptr->HotKeyFromCommandId( commandId2, returnkeycode2,
        modifiers2 );
    STIF_ASSERT_TRUE( flag2 );
    STIF_ASSERT_NOT_EQUALS( returnkeycode, returnkeycode2 );
    
    CleanupStack::PopAndDestroy( hotkeytableptr );
    return KErrNone;
    }
// -----------------------------------------------------------------------------
// CTestSDKCFD::TestEHKEYCommandIdFromHotKey
// -----------------------------------------------------------------------------
//
TInt CTestSDKEIKHKEYT::TestEHKEYCommandIdFromHotKeyL( CStifItemParser& /*aItem*/ )
    {
    CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable;
    CleanupStack::PushL( hotkeytableptr );
    
    TInt commandId( KOne);
    TInt keycode( KTwo );
    TInt modifiers( KZero );
    hotkeytableptr->AddItemL( commandId, keycode, modifiers );
    
    TInt commandId2( KTwo );
    TInt keycode2( KThree );
    TInt modifiers2( KZero );
    hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 );
    
    TInt returncommandId;
    TInt returncommandId2;
    returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers );
    returncommandId2 = hotkeytableptr->CommandIdFromHotKey( keycode2,
        modifiers2 );
    STIF_ASSERT_NOT_EQUALS( returncommandId, returncommandId2 );
    CleanupStack::PopAndDestroy( hotkeytableptr );
    
    return KErrNone;
    }
示例#5
0
void RemoteSubscriber::queueTimeline(quint64 playerCommandID, const QByteArray& timelineData)
{
  QMutexLocker lk(&m_timelineLock);

  QDomDocument doc;
  if (doc.setContent(timelineData) && doc.firstChildElement("MediaContainer").isNull() == false)
  {
    QDomElement node = doc.firstChildElement("MediaContainer");
    node.setAttribute("commandID", commandId(playerCommandID));
    m_timeline = doc;
  }
  else
    QLOG_WARN() << "Failed to parse timeline data from player";
}
示例#6
0
文件: qnode.cpp 项目: RSATom/Qt
/*!
 * \brief Sends a command messages to the backend node
 *
 * Creates a QNodeCommand message and dispatches it to the backend node. The
 * command is given and a \a name and some \a data which can be used in the
 * backend node to performe various operations.
 * This returns a CommandId which can be used to identify the initial command
 * when receiving a message in reply. If the command message is to be sent in
 * reply to another command, \a replyTo contains the id of that command.
 *
 * \sa QNodeCommand, QNode::sendReply
 */
QNodeCommand::CommandId QNode::sendCommand(const QString &name,
                                           const QVariant &data,
                                           QNodeCommand::CommandId replyTo)
{
    Q_D(QNode);

    // Bail out early if we can to avoid operator new
    if (d->m_blockNotifications)
        return QNodeCommand::CommandId(0);

    auto e = QNodeCommandPtr::create(d->m_id);
    e->setName(name);
    e->setData(data);
    e->setReplyToCommandId(replyTo);
    d->notifyObservers(e);
    return e->commandId();
}
void LLFloaterToybox::onToolBarButtonEnter(LLView* button)
{
	std::string suffix = "";

	LLCommandId commandId(button->getName());
	LLCommand* command = LLCommandManager::instance().getCommand(commandId);

	if (command)
	{
		S32 command_loc = gToolBarView->hasCommand(commandId);

		switch(command_loc)
		{
		case LLToolBarView::TOOLBAR_BOTTOM:	suffix = LLTrans::getString("Toolbar_Bottom_Tooltip");	break;
		case LLToolBarView::TOOLBAR_LEFT:	suffix = LLTrans::getString("Toolbar_Left_Tooltip");	break;
		case LLToolBarView::TOOLBAR_RIGHT:	suffix = LLTrans::getString("Toolbar_Right_Tooltip");	break;

		default:
			break;
		}
	}

	mToolBar->setTooltipButtonSuffix(suffix);
}
示例#8
0
/// execute the given selection command
/// @param controller the controller to execute the selection for
void SelectionCommand::execute( TextEditorController* controller )
{
    // save the selection state
    TextDocument* document = controller->textDocument();
    TextRangeSet* currentSelection = dynamic_cast<TextRangeSet*>( controller->textSelection() );
    TextRangeSet* sel = new TextRangeSet(*currentSelection);  // start with the current selection

    bool resetAnchors = !keepSelection_;

    // handle the select operation
    switch( unit_ ) {
        // character movement
        case MoveCaretByCharacter:
            sel->moveCarets(amount_);
            break;

        // This results in clearing the selection if a selection is present or it results in a movement of the caret.
        // When clearing a selection the caret is placed next to the selection (which side depends on the direction)
        case MoveCaretsOrDeselect:
            if( keepSelection_ ) {
                sel->moveCarets(amount_);
            } else {
                sel->moveCaretsOrDeselect(amount_);
            }
            break;

        case MoveCaretByWord:
            sel->moveCaretsByCharGroup(amount_, document->config()->whitespaceWithoutNewline(), document->config()->charGroups() );
            break;

        case MoveCaretByLine:
            TextSelection::moveCaretsByLine( controller, sel, amount_ );
            break;

        case MoveCaretToLineBoundary:
            sel->moveCaretsToLineBoundary( amount_, document->config()->whitespaceWithoutNewline() );
            break;

        case MoveCaretToDocumentBegin:
            sel->toSingleRange();
            sel->range(0).setCaret(0);
            break;

        case MoveCaretToDocumentEnd:
            sel->toSingleRange();
            sel->range(0).setCaret( controller->textDocument()->length() );
            break;

        case MoveCaretByPage:
        {
            // make sure the first line of the window is scrolled
            TextRenderer* renderer   = controller->textRenderer();
            TextEditorWidget* widget = controller->widget();
            int firstVisibleLine = renderer->firstVisibleLine();
            int linesPerPage     = renderer->viewHeightInLines();

            sel->beginChanges();
            TextSelection::moveCaretsByPage( controller, sel, amount_ );
            if( !keepSelection_ ) {
                sel->resetAnchors();    // we must reset anchors here because de process-changes will merge carets
            }
            sel->endChanges();

            firstVisibleLine += linesPerPage * amount_;
            widget->scrollTopToLine( firstVisibleLine );

            break;
        }
        case MoveCaretToExactOffset:
            sel->toSingleRange();
            sel->range(0).setCaret(amount_);
            break;

        case SelectAll:
            sel->toSingleRange();
            sel->setRange(0, document->buffer()->length() );
            resetAnchors = false;   // do not reset the anchors
            break;

        case SelectWord:
            sel->expandToWords(document->config()->whitespaces(), document->config()->charGroups());
            resetAnchors = false;   // do not reset the anchors
            break;

        case SelectWordAt:
            sel->selectWordAt( amount_, document->config()->whitespaces(), document->config()->charGroups() );
            resetAnchors = false;
            break;

        case ToggleWordSelectionAt:
            sel->toggleWordSelectionAt( amount_, document->config()->whitespaces(), document->config()->charGroups() );
            resetAnchors = false;
            break;

        case SelectFullLine:
            sel->expandToFullLines( amount_);
            resetAnchors = false;
            break;

        case AddCaretAtOffset:
            sel->addRange( amount_, amount_ );
            resetAnchors = false;   // do not reset the anchors
            break;

        case AddCaretByLine:
            TextSelection::addRangesByLine( controller, sel, amount_ );
            break;

        case ResetSelection:

            // when there's a selection ESCAPE clears the selection
            if( sel->hasSelection() ) {
                sel->clearSelection();
            } else if( sel->rangeCount() > 1 ) {
                sel->toSingleRange();
            }
            resetAnchors = false;   // keep selection
            break;
    }

    if( resetAnchors ) {
        sel->resetAnchors();
    }

    // no change?
    if( currentSelection->equals( *sel ) ) {
        delete sel;
        return; // 0
    }

    controller->changeAndGiveTextSelection( sel, commandId() );
}
示例#9
0
TInt CRfsScript::ParseNextCommandL( CRfsCommand* aCommand )
    {
    const TDesC* commands[ KRfsNumberOfCommands ] =
        {    
        &KRfsCommand1,
        &KRfsCommand2,
        &KRfsCommand3,
        &KRfsCommand4,
        &KRfsCommand5,
        &KRfsCommand6,
        &KRfsCommand7,
        &KRfsCommand8
        };
    
    TInt startIndex;
    TInt endIndex;

    FOREVER
        {

        // check if index is beyond the descriptor already

        if ( iIndex >= iLength )
            {
            return KRfsEndOfScript;
            }

        // go to the beginning of the "command word"

        startIndex = iIndex;
        SkipSpace( startIndex );

        // go to the end of the "command word"

        endIndex = startIndex;
        FindEnd( endIndex );

        if ( endIndex - startIndex > 0 && !IsComment( startIndex ) )
            {
            break;
            }

        // if the line is commented out, skip it

        iIndex = NextLine( startIndex );
        }

    // create TPtrC to the "command word"

    TPtrC command( &iScript[ startIndex ], endIndex - startIndex );
    
    TRfsCommandId commandId( ERfsCommandUnknown );

    // determine the command id

    for ( TInt i = 0; i < KRfsNumberOfCommands ; i++ )
        {
        if ( !command.CompareF( *( commands[ i ] ) ) )
            {
            commandId = (TRfsCommandId)i;
            break;
            }
        }

    TInt ret( KErrGeneral ); // returns this if there is a syntax error in line

    if ( commandId != ERfsCommandUnknown )
        {
        TInt numberOfParams( 0 );        
        TInt start = endIndex;

        FOREVER
            {
            TBool quotes( EFalse );
            SkipSpace( start, &quotes );

            TInt end = start;
            if ( FindEnd( end, quotes ) )
                {
                if ( end - start > 0 && !IsComment( start) )
                    {
                    numberOfParams++;
                    start = end;
                    continue;
                    }
                }
            break;
            }

        if ( VerifyNumberOfParameters( commandId, numberOfParams ) )
            {
            // set command information if the command parameter has been given

            if ( aCommand )
                {
                TPtrC* params = new( ELeave ) TPtrC[ numberOfParams ];
                
                // fetch parameter information

                for ( TInt i = 0; i < numberOfParams ; i++ )
                    {
                    TInt paramStart = endIndex;
                    TBool quotes( EFalse );

                    SkipSpace( paramStart, &quotes );

                    TInt paramEnd = paramStart;
                    FindEnd( paramEnd, quotes );

                    TInt realStart( paramStart );
                    TInt realEnd( paramEnd );

                    if ( quotes )
                        {
                        realStart++;
                        realEnd--;
                        }

                    params[ i ].Set( &iScript[ realStart ], realEnd - realStart );

                    endIndex = paramEnd;
                    }

                // aCommand gets ownership of paramStarts and paramLengths

                aCommand->Set( commandId, numberOfParams, params );
                }

            iIndex = NextLine ( endIndex );
            ret = KErrNone;
            }
        }