DlgUndoRedo.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #include "DlgUndoRedo.h"
00027 #include "Application.h"
00028 #include "MainWindow.h"
00029 #include "Document.h"
00030 #include "EditorView.h"
00031
00032 using namespace Gui::Dialog;
00033
00034
00035
00040 UndoDialog::UndoDialog( QWidget* parent )
00041 : QMenu( parent )
00042 {
00043 connect(this, SIGNAL(aboutToShow()), this, SLOT(onFetchInfo()));
00044 }
00045
00049 UndoDialog::~UndoDialog()
00050 {
00051
00052 }
00053
00058 void UndoDialog::onFetchInfo()
00059 {
00060 clear();
00061 Gui::Document* pcDoc = Application::Instance->activeDocument();
00062 if (pcDoc)
00063 {
00064 std::vector<std::string> vecUndos = pcDoc->getUndoVector();
00065 for (std::vector<std::string>::iterator i=vecUndos.begin(); i!=vecUndos.end(); i++)
00066 addAction(QString::fromUtf8((*i).c_str()), this, SLOT(onSelected()));
00067 }
00068 else
00069 {
00070 EditorView* view = qobject_cast<EditorView*>(getMainWindow()->activeWindow());
00071 if (view) {
00072 QStringList vecUndos = view->undoActions();
00073 for (QStringList::Iterator i=vecUndos.begin(); i!=vecUndos.end(); i++)
00074 addAction(*i, this, SLOT(onSelected()));
00075 }
00076 }
00077 }
00078
00080 void UndoDialog::onSelected()
00081 {
00082 QAction* a = static_cast<QAction*>(sender());
00083 QList<QAction*> acts = this->actions();
00084 for (QList<QAction*>::ConstIterator it = acts.begin(); it != acts.end(); ++it) {
00085 Gui::Application::Instance->sendMsgToActiveView("Undo");
00086 if (*it == a)
00087 break;
00088 }
00089 }
00090
00091
00092
00097 RedoDialog::RedoDialog( QWidget* parent )
00098 : QMenu( parent )
00099 {
00100 connect(this, SIGNAL(aboutToShow()), this, SLOT(onFetchInfo()));
00101 }
00102
00106 RedoDialog::~RedoDialog()
00107 {
00108
00109 }
00110
00115 void RedoDialog::onFetchInfo()
00116 {
00117 clear();
00118 Gui::Document* pcDoc = Application::Instance->activeDocument();
00119 if ( pcDoc )
00120 {
00121 std::vector<std::string> vecRedos = pcDoc->getRedoVector();
00122 for (std::vector<std::string>::iterator i=vecRedos.begin(); i!=vecRedos.end(); i++)
00123 addAction(QString::fromUtf8((*i).c_str()), this, SLOT(onSelected()));
00124 }
00125 else
00126 {
00127 EditorView* view = qobject_cast<EditorView*>(getMainWindow()->activeWindow());
00128 if (view) {
00129 QStringList vecRedos = view->redoActions();
00130 for (QStringList::Iterator i=vecRedos.begin(); i!=vecRedos.end(); i++)
00131 addAction(*i, this, SLOT(onSelected()));
00132 }
00133 }
00134 }
00135
00137 void RedoDialog::onSelected()
00138 {
00139 QAction* a = static_cast<QAction*>(sender());
00140 QList<QAction*> acts = this->actions();
00141 for (QList<QAction*>::ConstIterator it = acts.begin(); it != acts.end(); ++it) {
00142 Gui::Application::Instance->sendMsgToActiveView("Redo");
00143 if (*it == a)
00144 break;
00145 }
00146 }
00147
00148 #include "moc_DlgUndoRedo.cpp"