Exemplo n.º 1
0
void FormulaCommandRemove::undo()
{
    FormulaCursor* cursor = new FormulaCursor( m_ownerElement );
    cursor->setPosition( m_positionInElement );
    
    foreach( BasicElement* tmp, m_removedElements )
        m_ownerElement->insertChild( cursor, tmp );
	
    delete cursor;
}
Exemplo n.º 2
0
bool TableRowElement::setCursorTo(FormulaCursor& cursor, QPointF point)
{
    if (cursor.isSelecting()) {
        if (m_data.isEmpty() || point.x()<0.0) {
            cursor.setCurrentElement(this);
            cursor.setPosition(0);
            return true;
        }
        //check if the point is behind all child elements
        if (point.x() >= width()) {
            cursor.setCurrentElement(this);
            cursor.setPosition(endPosition());
            return true;
        }
    }
    int i=0;
    qreal x=0.0;
    TableElement* parentTable = static_cast<TableElement*>( parentElement() );
    for (; i<m_data.count()-1; ++i) {
        //Find the child element the point is in
        x+=parentTable->columnWidth( i );
        if (x>=point.x()) {
            break;
        }
    }
    if (cursor.isSelecting()) {
        //we don't need to change current element because we are already in this element
        if (cursor.mark()<=i) {
            cursor.setPosition(i+1);
        }
        else {
            cursor.setPosition(i);
        }
        return true;
        } else {
        point-=m_data[i]->origin();
        return m_data[i]->setCursorTo(cursor,point);
    }
}
Exemplo n.º 3
0
void FormulaCommandReplace::redo()
{
    foreach( BasicElement* tmp, m_replacedElements )
        m_ownerElement->removeElement( tmp );

    FormulaCursor* cursor = new FormulaCursor( m_ownerElement );
    cursor->setPosition( m_positionInElement );
    
    foreach( BasicElement* tmp, m_replacingElements )
        m_ownerElement->insertChild( cursor, tmp );
	
    delete cursor;
}