Commit e575ade1 authored by Ralf Habacker's avatar Ralf Habacker

Made 'Enable/Disable Undo' setting real working.

CCBUG: 329648
(cherry picked from commit 12815191)
parent 3882877e
......@@ -1833,8 +1833,8 @@ void ListPopupMenu::setupMenu(MenuType type)
if(m_TriggerObjectType == tot_View) {
bool bCutState = UMLApp::app()->isCutCopyState();
setActionEnabled(mt_Undo, UMLApp::app()->isUndoEnabled());
setActionEnabled(mt_Redo, UMLApp::app()->isRedoEnabled());
setActionEnabled(mt_Undo, UMLApp::app()->isUndoActionEnabled());
setActionEnabled(mt_Redo, UMLApp::app()->isRedoActionEnabled());
setActionEnabled(mt_Cut, bCutState);
setActionEnabled(mt_Copy, bCutState);
setActionEnabled(mt_Paste, UMLApp::app()->isPasteState());
......
......@@ -1019,6 +1019,7 @@ void UMLApp::readOptions()
fileOpenRecent->loadEntries(m_config->group("Recent Files"));
setImageMimeType(UmbrelloSettings::imageMimeType());
resize(UmbrelloSettings::geometry());
enableUndo(Settings::optionState().generalState.undo);
}
/**
......@@ -1710,28 +1711,6 @@ void UMLApp::enablePrint(bool enable)
printPreview->setEnabled(enable);
}
/**
* Set whether to allow Undo.
* It will enable/disable the menu/toolbar options.
*
* @param enable Set whether to allow printing.
*/
void UMLApp::enableUndo(bool enable)
{
editUndo->setEnabled(enable);
}
/**
* Set whether to allow Redo.
* It will enable/disable the menu/toolbar options.
*
* @param enable Set whether to allow printing.
*/
void UMLApp::enableRedo(bool enable)
{
editRedo->setEnabled(enable);
}
/**
* Initialize Qt's global clipboard support for the application.
*/
......@@ -1825,6 +1804,8 @@ void UMLApp::slotApplyPrefs()
if (m_settingsDlg) {
// we need this to sync both values
Settings::OptionState& optionState = Settings::optionState();
enableUndo(optionState.generalState.undo);
bool stackBrowsing = (m_layout->indexOf(m_tabWidget) != -1);
bool tabBrowsing = optionState.generalState.tabdiagrams;
DEBUG(DBG_SRC) << "stackBrowsing=" << stackBrowsing << " / tabBrowsing=" << tabBrowsing;
......@@ -1871,44 +1852,91 @@ void UMLApp::slotApplyPrefs()
}
}
/**
* Returns the paste state.
*
* @return True if Paste is enabled.
*/
bool UMLApp::isPasteState() const
{
return editPaste->isEnabled();
}
/**
* Returns the state on Cut/Copy.
*
* @return True if Cut/Copy is enabled.
*/
bool UMLApp::isCutCopyState() const
{
return editCopy->isEnabled();
}
/**
* Returns the state of undo support.
*
* @return True if undo is enabled.
*/
bool UMLApp::isUndoEnabled()
{
return m_undoEnabled;
}
/**
* Set the state of undo support.
*
*/
void UMLApp::enableUndo(bool enable)
{
m_undoEnabled = enable;
editRedo->setVisible(enable);
editUndo->setVisible(enable);
viewShowCmdHistory->setVisible(enable);
clearUndoStack();
slotShowCmdHistoryView(enable);
}
/**
* Returns the undo state. Is used for popupmenu of a view.
*
* @return True if Undo is enabled.
*/
bool UMLApp::isUndoEnabled() const
bool UMLApp::isUndoActionEnabled() const
{
return editUndo->isEnabled();
}
/**
* Returns the redo state.
* Set whether to allow Undo.
* It will enable/disable the menu/toolbar options.
*
* @return True if Redo is enabled. Is used for popupmenu of a view.
* @param enable Set whether to allow printing.
*/
bool UMLApp::isRedoEnabled() const
void UMLApp::enableUndoAction(bool enable)
{
return editRedo->isEnabled();
editUndo->setEnabled(enable);
}
/**
* Returns the paste state.
* Returns the redo state.
*
* @return True if Paste is enabled.
* @return True if Redo is enabled. Is used for popupmenu of a view.
*/
bool UMLApp::isPasteState() const
bool UMLApp::isRedoActionEnabled() const
{
return editPaste->isEnabled();
return editRedo->isEnabled();
}
/**
* Returns the state on Cut/Copy.
* Set whether to allow Redo.
* It will enable/disable the menu/toolbar options.
*
* @return True if Cut/Copy is enabled.
* @param enable Set whether to allow printing.
*/
bool UMLApp::isCutCopyState() const
void UMLApp::enableRedoAction(bool enable)
{
return editCopy->isEnabled();
editRedo->setEnabled(enable);
}
/**
......@@ -3002,17 +3030,20 @@ void UMLApp::clearUndoStack()
*/
void UMLApp::undo()
{
if (!isUndoEnabled())
return;
DEBUG(DBG_SRC) << m_pUndoStack->undoText() << " [" << m_pUndoStack->count() << "]";
m_pUndoStack->undo();
if (m_pUndoStack->canUndo()) {
UMLApp::app()->enableUndo(true);
UMLApp::app()->enableUndoAction(true);
}
else {
UMLApp::app()->enableUndo(false);
UMLApp::app()->enableUndoAction(false);
}
UMLApp::app()->enableRedo(true);
UMLApp::app()->enableRedoAction(true);
}
/**
......@@ -3020,17 +3051,20 @@ void UMLApp::undo()
*/
void UMLApp::redo()
{
if (!isUndoEnabled())
return;
DEBUG(DBG_SRC) << m_pUndoStack->redoText() << " [" << m_pUndoStack->count() << "]";
m_pUndoStack->redo();
if (m_pUndoStack->canRedo()) {
UMLApp::app()->enableRedo(true);
UMLApp::app()->enableRedoAction(true);
}
else {
UMLApp::app()->enableRedo(false);
UMLApp::app()->enableRedoAction(false);
}
UMLApp::app()->enableUndo(true);
UMLApp::app()->enableUndoAction(true);
}
/**
......@@ -3038,12 +3072,15 @@ void UMLApp::redo()
*/
void UMLApp::executeCommand(QUndoCommand* cmd)
{
if (cmd != NULL) {
if (cmd == NULL)
return;
if (isUndoEnabled()) {
m_pUndoStack->push(cmd);
DEBUG(DBG_SRC) << cmd->text() << " [" << m_pUndoStack->count() << "]";
UMLApp::app()->enableUndoAction(true);
} else {
cmd->redo();
}
UMLApp::app()->enableUndo(true);
}
/**
......@@ -3051,6 +3088,9 @@ void UMLApp::executeCommand(QUndoCommand* cmd)
*/
void UMLApp::beginMacro(const QString & text)
{
if (!isUndoEnabled()) {
return;
}
if (m_hasBegunMacro) {
return;
}
......@@ -3064,6 +3104,9 @@ void UMLApp::beginMacro(const QString & text)
*/
void UMLApp::endMacro()
{
if (!isUndoEnabled()) {
return;
}
if (m_hasBegunMacro) {
m_pUndoStack->endMacro();
}
......
......@@ -100,14 +100,19 @@ public:
void setModified(bool _m);
void enablePrint(bool enable);
void enableUndo(bool enable);
void enableRedo(bool enable);
bool isUndoEnabled() const;
bool isRedoEnabled() const;
bool isPasteState() const;
bool isCutCopyState() const;
bool isUndoEnabled();
void enableUndo(bool enable);
bool isUndoActionEnabled() const;
void enableUndoAction(bool enable);
bool isRedoActionEnabled() const;
void enableRedoAction(bool enable);
bool isSimpleCodeGeneratorActive();
void setGenerator(CodeGenerator* gen, bool giveWarning = true);
......@@ -428,6 +433,7 @@ private:
XhtmlGenerator* m_xhtmlGenerator;
KUndoStack* m_pUndoStack; ///< UndoStack used to store actions, to provide Undo/Redo feature.
bool m_undoEnabled; ///< Undo enabled flag
bool m_hasBegunMacro; ///< Macro creation flag.
......
......@@ -385,7 +385,7 @@ bool UMLDoc::newDocument()
setModified(false);
initSaveTimer();
UMLApp::app()->enableUndo(false);
UMLApp::app()->enableUndoAction(false);
UMLApp::app()->clearUndoStack();
return true;
......@@ -555,7 +555,7 @@ bool UMLDoc::openDocument(const KUrl& url, const char* format /* =0 */)
m_bLoading = false;
initSaveTimer();
UMLApp::app()->enableUndo(false);
UMLApp::app()->enableUndoAction(false);
UMLApp::app()->clearUndoStack();
// for compatibility
addDefaultStereotypes();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment