コード例 #1
0
ファイル: FormulaCursor.cpp プロジェクト: KDE/calligra
bool FormulaCursor::performMovement ( FormulaCursor& oldcursor )
{
    //handle selecting and not selecting case separately, which makes more clear
    if (isSelecting()) {
        while ( m_currentElement ) {
            if ( m_currentElement->moveCursor( *this, oldcursor ) ) {
                if (isAccepted()) {
                    return true;
                }
            } else {
                if ( m_currentElement->parentElement() ) {
                    bool ltr=m_mark<=m_position;
                    //update the starting point of the selection
                    m_mark=m_currentElement->parentElement()->positionOfChild(m_currentElement);
                    //move the cursor to the parent and place it before the old element
                    m_position=m_currentElement->parentElement()->positionOfChild(m_currentElement);
                    m_currentElement=m_currentElement->parentElement();
                    if (ltr) {
                        m_position++; //place the cursor behind
                    } else {
                        m_mark++; //place the selection beginning behind 
                    }
                    if (isAccepted()) {
                        return true;
                    }
                } else {
                    //we arrived at the toplevel element
                    return false;
                }
            }
        }
    } else {
        while ( m_currentElement ) {
            if ( m_currentElement->moveCursor( *this, oldcursor ) ) {
                if (isAccepted()) {
                    return true;
                }
            } else {
                if ( m_currentElement->parentElement() ) {
                    //move the cursor to the parent and place it before the old element
                    m_position=m_currentElement->parentElement()->positionOfChild(m_currentElement);
                    m_currentElement=m_currentElement->parentElement();
                    if (m_direction==MoveRight || m_direction==MoveDown) {
                        m_position++; //place the cursor behin
                    }
                    if (m_direction==MoveRight || m_direction==MoveLeft) {
                        if (isAccepted()) {
                            return true;
                        }
                    }   
                } else {
                    //We arrived at the top level element
                    return false;
                }
            }
        }
    }
    return false;
}
コード例 #2
0
ファイル: llfloateroutbox.cpp プロジェクト: hades187/singu
BOOL LLFloaterOutbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
										EDragAndDropType cargo_type,
										void* cargo_data,
										EAcceptance* accept,
										std::string& tooltip_msg)
{
	if ((mOutboxInventoryPanel.get() == NULL) ||
		//(mWindowShade && mWindowShade->isShown()) ||
		LLMarketplaceInventoryImporter::getInstance()->isImportInProgress() ||
		mOutboxId.isNull())
	{
		return FALSE;
	}

	LLView * handled_view = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
	BOOL handled = (handled_view != NULL);

	// Determine if the mouse is inside the inventory panel itself or just within the floater
	bool pointInInventoryPanel = false;
	bool pointInInventoryPanelChild = false;
	LLInventoryPanel* panel = mOutboxInventoryPanel.get();
	LLFolderView * root_folder = panel->getRootFolder();
	if (panel->getVisible())
	{
		S32 inv_x, inv_y;
		localPointToOtherView(x, y, &inv_x, &inv_y, panel);

		pointInInventoryPanel = panel->getRect().pointInRect(inv_x, inv_y);

		LLView * inventory_panel_child_at_point = panel->childFromPoint(inv_x, inv_y, true);
		pointInInventoryPanelChild = (inventory_panel_child_at_point != root_folder);
	}

	// Pass all drag and drop for this floater to the outbox inventory control
	if (!handled || !isAccepted(*accept))
	{
		// Handle the drag and drop directly to the root of the outbox if we're not in the inventory panel
		// (otherwise the inventory panel itself will handle the drag and drop operation, without any override)
		if (!pointInInventoryPanel)
		{
			handled = root_folder->handleDragAndDropToThisFolder(mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
		}

		mOutboxTopLevelDropZone->setBackgroundVisible(handled && !drop && isAccepted(*accept));
	}
	else
	{
		mOutboxTopLevelDropZone->setBackgroundVisible(!pointInInventoryPanelChild);
	}

	return handled;
}
BOOL LLFloaterMarketplaceListings::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
										EDragAndDropType cargo_type,
										void* cargo_data,
										EAcceptance* accept,
										std::string& tooltip_msg)
{
	// If there's no panel to accept drops or no existing marketplace listings folder, we refuse all drop
	if (!mPanelListings || mRootFolderId.isNull())
	{
		return FALSE;
	}

	tooltip_msg = "";

	// Pass to the children
	LLView * handled_view = childrenHandleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
	BOOL handled = (handled_view != NULL);

	// If no one handled it or it was not accepted and we drop on an empty panel, we try to accept it at the floater level
	// as if it was dropped on the marketplace listings root folder
	if ((!handled || !isAccepted(*accept)) && !mPanelListings->getVisible() && mRootFolderId.notNull())
	{
		if (!mPanelListingsSet)
		{
			setPanels();
		}
		LLFolderView* root_folder = mPanelListings->getRootFolder();
		handled = root_folder->handleDragAndDropToThisFolder(mask, drop, cargo_type, cargo_data, accept, tooltip_msg);
	}

	return handled;
}
コード例 #4
0
ファイル: SRM_508.cpp プロジェクト: poksion/human-learning
    int getLeast(int N, int M){
        if(M == 1){
            return 0;
        }

        queue< OpNode > opQueue;

        int currentLevel = 1;
        int currentItemCnt = addNextOp(opQueue, N, M);
        int nextItemCnt = 0;

        while(!opQueue.empty()){
            OpNode currentOp = opQueue.front();
            opQueue.pop();
            currentItemCnt--;

            int nextLastSlot, nextObjectLocated;
            if(isAccepted(currentOp, nextLastSlot, nextObjectLocated)){
                return currentLevel;
            }

            int added = addNextOp(opQueue, nextLastSlot, nextObjectLocated);
            nextItemCnt += added;

            if(currentItemCnt == 0){
                currentLevel += 1;
                currentItemCnt = nextItemCnt;
                nextItemCnt = 0;
            }
        }

        return 0;
    }
コード例 #5
0
ファイル: OSOutput.cpp プロジェクト: dariogladbach/OS
void OSOutputChannel::OSPrintf(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string str)
{
    if (isAccepted(area,level))
    {
        if (this->name == "stderr")
                fprintf(stderr, "%s\n", str.c_str());
        else if (this->name == "stdout")
                printf("%s\n", str.c_str());
        else
            if (this->file != NULL)
                fprintf(file, "%s\n", str.c_str());
            else
                throw ErrorClass("File not open for output");
        return;
    }
}
コード例 #6
0
/*!
    Returns true if the \a gesture is accepted; otherwise returns false.
*/
bool QGestureEvent::isAccepted(QGesture *gesture) const
{
    return gesture ? isAccepted(gesture->gestureType()) : false;
}