コード例 #1
0
ファイル: Property.cpp プロジェクト: zkaiwen/e2g
void
Property::accept(BaseVisitor & inoutVisitor) throw(Error) {
    try
    {
        runVisitor( *this, inoutVisitor );
    }
    catch( Error &e )
    {
        e.setCurrentLocation(
            __FUNCTION__, __FILE__, __LINE__ );
        throw;
    }
}
コード例 #2
0
ファイル: celldocument.cpp プロジェクト: cbhust/OMNotebook
/*!
 * \author Anders Fernström
 * \date 2005-11-29
 * \date 2006-03-03 (update)
 *
 * \brief Update the scrollarea so the correct area is displayed
 *
 * 2005-12-08 AF, remade function becuase the earlier version hade
 * some large bugs. Didn't calculate cells position correct, becuase
 * qt:s layout system reset position to 0 in every groupcell and
 * layout are probobly not set correctly.
 * 2006-03-03 AF, ignore move if the cursor it at the end of the
 * document
 */
void CellDocument::updateScrollArea()
{
    if( scroll_->verticalScrollBar()->isVisible() )
    {
        CellCursor *cursor = getCursor();
        if( cursor )
        {
            // ignore, if selected cell is a groupcell
            if( typeid( *cursor->currentCell() ) != typeid( CellGroup ) )
            {
                // calculate the position of the cursor, by adding the height
                // of all the cells before the cellcursor, using a visitor
                CursorPosVisitor visitor;
                runVisitor( visitor );
                int pos = visitor.position();

                // size of scrollarea
                int scrollTop = scroll_->widget()->visibleRegion().boundingRect().top();
                int scrollBottom = scroll_->widget()->visibleRegion().boundingRect().bottom();

                // cell height
                int height = cursor->currentCell()->height();

#ifndef QT_NO_DEBUG_OUTPUT

                cout << "*********************************************" << endl;
                cout << "SCROLL TOP: " << scrollTop << endl;
                cout << "SCROLL BOTTOM: " << scrollBottom << endl;
                cout << "CELL CURSOR: " << pos << endl;
                cout << "CELL HEIGHT: " << height << endl;
#endif



                // TO BIG
                if( height > (scrollBottom-scrollTop) )
                {
                    qDebug( "TO BIG" );
                    // cell so big that it span over entire viewarea
                    return;
                }
                // END OF DOCUMENT
                else if( pos > (scroll_->widget()->height() - 2 ) &&
                         scrollBottom > (scroll_->widget()->height() - 2 ) )
                {
#ifndef QT_NO_DEBUG_OUTPUT
                    cout << "END OF DOCUMENT, widget height(" << scroll_->widget()->height() << ")" << endl;
#endif
                    // 2006-03-03 AF, ignore if cursor at end of document
                    return;
                }
                // UP
                else if( (pos - height) < scrollTop )
                {
                    // cursor have moved above the viewarea of the
                    // scrollbar, move up the scrollbar

                    // remove cell height + a little extra
                    pos -= (height + 10);
                    if( pos < 0 )
                        pos = 0;

                    // set new scrollvalue
                    cout << "UP: old(" << scroll_->verticalScrollBar()->value() << "), new(" << pos << ")" << endl;
                    scroll_->verticalScrollBar()->setValue( pos );
                }
                // DOWN
                else if( pos > (scrollBottom - 10) )
                {
                    // cursor have moved below the viewarea of the
                    // scrollbar, move down the scrollbar

                    // add cell height + a little extra to scrollbar
                    //pos = height + 20 + scroll_->verticalScrollBar()->value();

                    // add differens between cell cursor position och scroll bottom
                    // to the scroll value
                    pos = scroll_->verticalScrollBar()->value() + (pos - (scrollBottom - 10));

                    if( pos >= scroll_->verticalScrollBar()->maximum() )
                    {
#ifndef QT_NO_DEBUG_OUTPUT
                        cout << "more then max!" << endl;
#endif
                        scroll_->verticalScrollBar()->triggerAction( QAbstractSlider::SliderToMaximum );
                        //pos = scroll_->verticalScrollBar()->maximum();

                        // a little extra to the max value of the scrollbar
                        //scroll_->verticalScrollBar()->setMaximum( 5 +
                        //  scroll_->verticalScrollBar()->maximum() );
                    }
                    else
                    {
                        // set new scrollvalue
#ifndef QT_NO_DEBUG_OUTPUT
                        cout << "DOWN: old(" << scroll_->verticalScrollBar()->value() << "), new(" << pos << ")" << endl;
#endif
                        scroll_->verticalScrollBar()->setValue( pos );
                    }
                }
            }
        }
    }
}