SVN commit 417547 by fedemar: Disable the matrix actions when the cursor isn't in a matrix element. M +8 -0 kformulacontainer.cc M +5 -0 kformulacontainer.h M +11 -6 kformuladocument.cc M +1 -0 kformuladocument.h M +1 -1 kformulaview.cc --- trunk/koffice/lib/kformula/kformulacontainer.cc #417546:417547 @@ -481,6 +481,14 @@ recalc(); } +void Container::updateMatrixActions() +{ + BasicElement *currentElement = activeCursor()->getElement(); + if ( ( currentElement = currentElement->getParent() ) != 0 ) + document()->wrapper()->enableMatrixActions( dynamic_cast(currentElement) ); + else + document()->wrapper()->enableMatrixActions( false ); +} void Container::save( QDomElement &root ) { --- trunk/koffice/lib/kformula/kformulacontainer.h #417546:417547 @@ -305,6 +305,11 @@ void setFontSizeDirect( int pointSize ); + /** + If the cursor is in a matrix, the matrix actions will be enabled, otherwise disabled. + */ + void updateMatrixActions(); + signals: /** --- trunk/koffice/lib/kformula/kformuladocument.cc #417546:417547 @@ -347,6 +347,7 @@ { if ( m_hasActions ) { createActions( collection ); + enableMatrixActions( false ); } setCommandStack( history ); } @@ -1150,12 +1151,6 @@ getAddGenericUpperAction()->setEnabled( enabled ); getAddGenericLowerAction()->setEnabled( enabled ); - getAppendColumnAction()->setEnabled( enabled ); - getInsertColumnAction()->setEnabled( enabled ); - getRemoveColumnAction()->setEnabled( enabled ); - getAppendRowAction()->setEnabled( enabled ); - getInsertRowAction()->setEnabled( enabled ); - getRemoveRowAction()->setEnabled( enabled ); if ( enabled ) { getAddGenericUpperAction()-> @@ -1178,6 +1173,16 @@ } } +void DocumentWrapper::enableMatrixActions( bool b) +{ + getAppendColumnAction()->setEnabled( b ); + getInsertColumnAction()->setEnabled( b ); + getRemoveColumnAction()->setEnabled( b ); + getAppendRowAction()->setEnabled( b ); + getInsertRowAction()->setEnabled( b ); + getRemoveRowAction()->setEnabled( b ); +} + void DocumentWrapper::updateConfig() { m_syntaxHighlightingAction-> --- trunk/koffice/lib/kformula/kformuladocument.h #417546:417547 @@ -333,6 +333,7 @@ KAction* getInsertRowAction() { return m_insertRowAction; } KAction* getRemoveRowAction() { return m_removeRowAction; } + void enableMatrixActions(bool); KSelectAction* getLeftBracketAction() { return m_leftBracket; } KSelectAction* getRightBracketAction() { return m_rightBracket; } SymbolAction* getSymbolNamesAction() { return m_symbolNamesAction; } --- trunk/koffice/lib/kformula/kformulaview.cc #417546:417547 @@ -340,7 +340,7 @@ void View::emitCursorChanged() { if (cursor()->hasChanged() || cursorHasChanged()) { - + getDocument()->updateMatrixActions(); cursor()->clearChangedFlag(); cursorHasChanged() = false; cursor()->calcCursorSize( contextStyle(), smallCursor() );