Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved. 00003 ** 00004 ** This file is part of Qt Designer. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00012 ** licenses may use this file in accordance with the Qt Commercial License 00013 ** Agreement provided with the Software. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00020 ** information about Qt Commercial License Agreements. 00021 ** 00022 ** Contact info@trolltech.com if any conditions of this licensing are 00023 ** not clear to you. 00024 ** 00025 **********************************************************************/ 00026 00027 #ifndef COMMAND_H 00028 #define COMMAND_H 00029 00030 #include "metadatabase.h" 00031 #include "layout.h" 00032 00033 #include <qstring.h> 00034 #include <qrect.h> 00035 #include <qvaluelist.h> 00036 #include <qvariant.h> 00037 #include <qobject.h> 00038 #include <qlistview.h> 00039 #include <qptrlist.h> 00040 #include <qmap.h> 00041 #include <qiconset.h> 00042 00043 class QWizard; 00044 class QTabWidget; 00045 class Command; 00046 class QWidget; 00047 class FormWindow; 00048 class PropertyEditor; 00049 class QListBox; 00050 class QIconView; 00051 class QTable; 00052 class QAction; 00053 class QDesignerToolBar; 00054 class QMainWindow; 00055 class QTextEdit; 00056 struct LanguageInterface; 00057 class QToolBox; 00058 00059 class MenuBarEditor; 00060 class MenuBarEditorItem; 00061 class PopupMenuEditor; 00062 class PopupMenuEditorItem; 00063 class ActionEditor; 00064 00065 class Command : public Qt 00066 { 00067 public: 00068 Command( const QString &n, FormWindow *fw ); 00069 virtual ~Command(); 00070 00071 enum Type { 00072 Resize, 00073 Insert, 00074 Move, 00075 Delete, 00076 SetProperty, 00077 LayoutHorizontal, 00078 LayoutVertical, 00079 LayoutHorizontalSplitter, 00080 LayoutVerticalSplitter, 00081 LayoutGrid, 00082 BreakLayout, 00083 Macro, 00084 AddTabPage, 00085 DeleteTabPage, 00086 MoveTabPage, 00087 AddWidgetStackPage, 00088 DeleteWidgetStackPage, 00089 AddWizardPage, 00090 DeleteWizardPage, 00091 SwapWizardPages, 00092 MoveWizardPage, 00093 RenameWizardPage, 00094 AddConnection, 00095 RemoveConnection, 00096 Lower, 00097 Raise, 00098 Paste, 00099 TabOrder, 00100 PopulateListBox, 00101 PopulateIconView, 00102 PopulateListView, 00103 PopulateMultiLineEdit, 00104 PopulateTable, 00105 AddActionToToolBar, 00106 RemoveActionFromToolBar, 00107 AddToolBar, 00108 RemoveToolBar, 00109 AddFunction, 00110 ChangeFunctionAttrib, 00111 RemoveFunction, 00112 AddVariable, 00113 SetVariables, 00114 RemoveVariable, 00115 EditDefinitions, 00116 AddContainerPage, 00117 DeleteContainerPage, 00118 RenameContainerPage, 00119 AddActionToPopup, 00120 RemoveActionFromPopup, 00121 ExchangeActionInPopup, 00122 //MoveActionInPopup, 00123 RenameAction, 00124 SetActionIcons, 00125 AddMenu, 00126 RemoveMenu, 00127 ExchangeMenu, 00128 MoveMenu, 00129 RenameMenu, 00130 AddToolBoxPage, 00131 DeleteToolBoxPage 00132 }; 00133 00134 QString name() const; 00135 00136 virtual void execute() = 0; 00137 virtual void unexecute() = 0; 00138 virtual Type type() const = 0; 00139 virtual void merge( Command *c ); 00140 virtual bool canMerge( Command *c ); 00141 00142 FormWindow *formWindow() const; 00143 00144 private: 00145 QString cmdName; 00146 FormWindow *formWin; 00147 00148 }; 00149 00150 class CommandHistory : public QObject 00151 { 00152 Q_OBJECT 00153 00154 public: 00155 CommandHistory( int s ); 00156 00157 void addCommand( Command *cmd, bool tryCompress = FALSE ); 00158 void undo(); 00159 void redo(); 00160 00161 void emitUndoRedo(); 00162 00163 void setModified( bool m ); 00164 bool isModified() const; 00165 00166 public slots: 00167 void checkCompressedCommand(); 00168 00169 signals: 00170 void undoRedoChanged( bool undoAvailable, bool redoAvailable, 00171 const QString &undoCmd, const QString &redoCmd ); 00172 void modificationChanged( bool m ); 00173 00174 private: 00175 QPtrList<Command> history; 00176 int current, steps; 00177 bool modified; 00178 int savedAt; 00179 Command *compressedCommand; 00180 00181 }; 00182 00183 class ResizeCommand : public Command 00184 { 00185 public: 00186 ResizeCommand( const QString &n, FormWindow *fw, 00187 QWidget *w, const QRect &oldr, const QRect &nr ); 00188 00189 void execute(); 00190 void unexecute(); 00191 Type type() const { return Resize; } 00192 00193 private: 00194 QWidget *widget; 00195 QRect oldRect, newRect; 00196 00197 }; 00198 00199 class InsertCommand : public Command 00200 { 00201 public: 00202 InsertCommand( const QString &n, FormWindow *fw, QWidget *w, const QRect &g ); 00203 00204 void execute(); 00205 void unexecute(); 00206 Type type() const { return Insert; } 00207 00208 private: 00209 QWidget *widget; 00210 QRect geometry; 00211 00212 }; 00213 00214 class MoveCommand : public Command 00215 { 00216 public: 00217 MoveCommand( const QString &n, FormWindow *fw, 00218 const QWidgetList &w, 00219 const QValueList<QPoint> op, 00220 const QValueList<QPoint> np, 00221 QWidget *opr, QWidget *npr ); 00222 void execute(); 00223 void unexecute(); 00224 Type type() const { return Move; } 00225 void merge( Command *c ); 00226 bool canMerge( Command *c ); 00227 00228 private: 00229 QWidgetList widgets; 00230 QValueList<QPoint> oldPos, newPos; 00231 QWidget *oldParent, *newParent; 00232 00233 }; 00234 00235 class DeleteCommand : public Command 00236 { 00237 public: 00238 DeleteCommand( const QString &n, FormWindow *fw, 00239 const QWidgetList &w ); 00240 void execute(); 00241 void unexecute(); 00242 Type type() const { return Delete; } 00243 00244 private: 00245 QWidgetList widgets; 00246 QMap< QWidget*, QValueList<MetaDataBase::Connection> > connections; 00247 00248 }; 00249 00250 class SetPropertyCommand : public Command 00251 { 00252 public: 00253 SetPropertyCommand( const QString &n, FormWindow *fw, 00254 QObject *w, PropertyEditor *e, 00255 const QString &pn, const QVariant &ov, 00256 const QVariant &nv, const QString &ncut, 00257 const QString &ocut, 00258 bool reset = FALSE ); 00259 00260 void execute(); 00261 void unexecute(); 00262 Type type() const { return SetProperty; } 00263 void merge( Command *c ); 00264 bool canMerge( Command *c ); 00265 bool checkProperty(); 00266 00267 private: 00268 void setProperty( const QVariant &v, const QString ¤tItemText, bool select = TRUE ); 00269 00270 QGuardedPtr<QObject> widget; 00271 PropertyEditor *editor; 00272 QString propName; 00273 QVariant oldValue, newValue; 00274 QString oldCurrentItemText, newCurrentItemText; 00275 bool wasChanged; 00276 bool isResetCommand; 00277 00278 }; 00279 00280 class LayoutHorizontalCommand : public Command 00281 { 00282 public: 00283 LayoutHorizontalCommand( const QString &n, FormWindow *fw, 00284 QWidget *parent, QWidget *layoutBase, 00285 const QWidgetList &wl ); 00286 00287 void execute(); 00288 void unexecute(); 00289 Type type() const { return LayoutHorizontal; } 00290 00291 private: 00292 HorizontalLayout layout; 00293 00294 }; 00295 00296 class LayoutHorizontalSplitCommand : public Command 00297 { 00298 public: 00299 LayoutHorizontalSplitCommand( const QString &n, FormWindow *fw, 00300 QWidget *parent, QWidget *layoutBase, 00301 const QWidgetList &wl ); 00302 00303 void execute(); 00304 void unexecute(); 00305 Type type() const { return LayoutHorizontalSplitter; } 00306 00307 private: 00308 HorizontalLayout layout; 00309 00310 }; 00311 00312 class LayoutVerticalCommand : public Command 00313 { 00314 public: 00315 LayoutVerticalCommand( const QString &n, FormWindow *fw, 00316 QWidget *parent, QWidget *layoutBase, 00317 const QWidgetList &wl ); 00318 00319 void execute(); 00320 void unexecute(); 00321 Type type() const { return LayoutVertical; } 00322 00323 private: 00324 VerticalLayout layout; 00325 00326 }; 00327 00328 class LayoutVerticalSplitCommand : public Command 00329 { 00330 public: 00331 LayoutVerticalSplitCommand( const QString &n, FormWindow *fw, 00332 QWidget *parent, QWidget *layoutBase, 00333 const QWidgetList &wl ); 00334 00335 void execute(); 00336 void unexecute(); 00337 Type type() const { return LayoutVerticalSplitter; } 00338 00339 private: 00340 VerticalLayout layout; 00341 00342 }; 00343 00344 class LayoutGridCommand : public Command 00345 { 00346 public: 00347 LayoutGridCommand( const QString &n, FormWindow *fw, 00348 QWidget *parent, QWidget *layoutBase, 00349 const QWidgetList &wl, int xres, int yres ); 00350 00351 void execute(); 00352 void unexecute(); 00353 Type type() const { return LayoutGrid; } 00354 00355 private: 00356 GridLayout layout; 00357 00358 }; 00359 00360 class BreakLayoutCommand : public Command 00361 { 00362 public: 00363 BreakLayoutCommand( const QString &n, FormWindow *fw, 00364 QWidget *layoutBase, const QWidgetList &wl ); 00365 00366 void execute(); 00367 void unexecute(); 00368 Type type() const { return BreakLayout; } 00369 00370 private: 00371 Layout *layout; 00372 int spacing; 00373 int margin; 00374 QWidget *lb; 00375 QWidgetList widgets; 00376 00377 }; 00378 00379 class MacroCommand : public Command 00380 { 00381 public: 00382 MacroCommand( const QString &n, FormWindow *fw, 00383 const QPtrList<Command> &cmds ); 00384 00385 void execute(); 00386 void unexecute(); 00387 Type type() const { return Macro; } 00388 00389 private: 00390 QPtrList<Command> commands; 00391 00392 }; 00393 00394 class AddTabPageCommand : public Command 00395 { 00396 public: 00397 AddTabPageCommand( const QString &n, FormWindow *fw, 00398 QTabWidget *tw, const QString &label ); 00399 00400 void execute(); 00401 void unexecute(); 00402 Type type() const { return AddTabPage; } 00403 00404 private: 00405 QTabWidget *tabWidget; 00406 int index; 00407 QWidget *tabPage; 00408 QString tabLabel; 00409 00410 }; 00411 00412 class DeleteTabPageCommand : public Command 00413 { 00414 public: 00415 DeleteTabPageCommand( const QString &n, FormWindow *fw, 00416 QTabWidget *tw, QWidget *page ); 00417 00418 void execute(); 00419 void unexecute(); 00420 Type type() const { return DeleteTabPage; } 00421 00422 private: 00423 QTabWidget *tabWidget; 00424 int index; 00425 QWidget *tabPage; 00426 QString tabLabel; 00427 00428 }; 00429 00430 class MoveTabPageCommand : public Command 00431 { 00432 public: 00433 MoveTabPageCommand(const QString &n, FormWindow *fw, 00434 QTabWidget *tw, QWidget *page, const QString& label, int nIndex, int oIndex ); 00435 00436 void execute(); 00437 void unexecute(); 00438 Type type() const { return MoveTabPage; } 00439 00440 private: 00441 QTabWidget *tabWidget; 00442 int newIndex, oldIndex; 00443 QWidget *tabPage; 00444 QString tabLabel; 00445 00446 }; 00447 class QDesignerWidgetStack; 00448 class AddWidgetStackPageCommand : public Command 00449 { 00450 public: 00451 AddWidgetStackPageCommand( const QString &n, FormWindow *fw, 00452 QDesignerWidgetStack *ws ); 00453 00454 void execute(); 00455 void unexecute(); 00456 Type type() const { return AddWidgetStackPage; } 00457 00458 private: 00459 QDesignerWidgetStack *widgetStack; 00460 int index; 00461 QWidget *stackPage; 00462 }; 00463 00464 class DeleteWidgetStackPageCommand : public Command 00465 { 00466 public: 00467 DeleteWidgetStackPageCommand( const QString &n, FormWindow *fw, 00468 QDesignerWidgetStack *ws, QWidget *page ); 00469 00470 void execute(); 00471 void unexecute(); 00472 Type type() const { return DeleteWidgetStackPage; } 00473 00474 private: 00475 QDesignerWidgetStack *widgetStack; 00476 int index; 00477 QWidget *stackPage; 00478 }; 00479 00480 00481 00482 class AddWizardPageCommand : public Command 00483 { 00484 public: 00485 AddWizardPageCommand( const QString &n, FormWindow *fw, 00486 QWizard *w, const QString &label, int index = -1, bool show = TRUE ); 00487 00488 void execute(); 00489 void unexecute(); 00490 Type type() const { return AddWizardPage; } 00491 00492 private: 00493 QWizard *wizard; 00494 int index; 00495 bool show; 00496 QWidget *page; 00497 QString pageLabel; 00498 00499 }; 00500 00501 class DeleteWizardPageCommand : public Command 00502 { 00503 public: 00504 DeleteWizardPageCommand( const QString &n, FormWindow *fw, 00505 QWizard *w, int index, bool show = TRUE ); 00506 00507 void execute(); 00508 void unexecute(); 00509 Type type() const { return DeleteWizardPage; } 00510 00511 private: 00512 QWizard *wizard; 00513 int index; 00514 bool show; 00515 QWidget *page; 00516 QString pageLabel; 00517 00518 }; 00519 00520 class RenameWizardPageCommand : public Command 00521 { 00522 public: 00523 RenameWizardPageCommand( const QString &n, FormWindow *fw, 00524 QWizard *w, int index, const QString& name ); 00525 00526 void execute(); 00527 void unexecute(); 00528 Type type() const { return RenameWizardPage; } 00529 00530 private: 00531 QWizard *wizard; 00532 int index; 00533 QWidget *page; 00534 QString label; 00535 00536 }; 00537 00538 class SwapWizardPagesCommand : public Command 00539 { 00540 public: 00541 SwapWizardPagesCommand( const QString &n, FormWindow *fw, 00542 QWizard *w, int index1, int index2 ); 00543 00544 void execute(); 00545 void unexecute(); 00546 Type type() const { return SwapWizardPages; } 00547 00548 private: 00549 QWizard *wizard; 00550 int index1, index2; 00551 00552 }; 00553 00554 class MoveWizardPageCommand : public Command 00555 { 00556 public: 00557 MoveWizardPageCommand( const QString &n, FormWindow *fw, 00558 QWizard *w, int index1, int index2 ); 00559 00560 void execute(); 00561 void unexecute(); 00562 Type type() const { return MoveWizardPage; } 00563 00564 private: 00565 QWizard *wizard; 00566 int index1, index2; 00567 00568 }; 00569 00570 class AddConnectionCommand : public Command 00571 { 00572 public: 00573 AddConnectionCommand( const QString &name, FormWindow *fw, 00574 MetaDataBase::Connection c ); 00575 00576 void execute(); 00577 void unexecute(); 00578 Type type() const { return AddConnection; } 00579 00580 private: 00581 MetaDataBase::Connection connection; 00582 00583 }; 00584 00585 class RemoveConnectionCommand : public Command 00586 { 00587 public: 00588 RemoveConnectionCommand( const QString &name, FormWindow *fw, 00589 MetaDataBase::Connection c ); 00590 00591 void execute(); 00592 void unexecute(); 00593 Type type() const { return RemoveConnection; } 00594 00595 private: 00596 MetaDataBase::Connection connection; 00597 00598 }; 00599 00600 00601 class AddFunctionCommand : public Command 00602 { 00603 public: 00604 AddFunctionCommand( const QString &name, FormWindow *fw, const QCString &f, const QString& spec, 00605 const QString &a, const QString &t, const QString &l, const QString &rt ); 00606 00607 void execute(); 00608 void unexecute(); 00609 Type type() const { return AddFunction; } 00610 00611 private: 00612 QCString function; 00613 QString specifier; 00614 QString access; 00615 QString functionType; 00616 QString language; 00617 QString returnType; 00618 }; 00619 00620 class ChangeFunctionAttribCommand : public Command 00621 { 00622 public: 00623 ChangeFunctionAttribCommand( const QString &name, FormWindow *fw, MetaDataBase::Function f, 00624 const QString &on, const QString &os, const QString &oa, 00625 const QString &ot, const QString &ol, const QString &ort ); 00626 00627 void execute(); 00628 void unexecute(); 00629 Type type() const { return ChangeFunctionAttrib; } 00630 00631 private: 00632 QString oldName, newName; 00633 QString oldSpec, newSpec; 00634 QString oldAccess, newAccess; 00635 QString oldType, newType; 00636 QString oldLang, newLang; 00637 QString oldReturnType, newReturnType; 00638 }; 00639 00640 class RemoveFunctionCommand : public Command 00641 { 00642 public: 00643 RemoveFunctionCommand( const QString &name, FormWindow *fw, const QCString &f, const QString& spec, 00644 const QString &a, const QString &t, const QString &l, const QString &rt ); 00645 00646 void execute(); 00647 void unexecute(); 00648 Type type() const { return RemoveFunction; } 00649 00650 private: 00651 QCString function; 00652 QString specifier; 00653 QString access; 00654 QString functionType; 00655 QString language; 00656 QString returnType; 00657 }; 00658 00659 class AddVariableCommand : public Command 00660 { 00661 public: 00662 AddVariableCommand( const QString &name, FormWindow *fw, const QString &vn, const QString &a ); 00663 void execute(); 00664 void unexecute(); 00665 Type type() const { return AddVariable; } 00666 00667 private: 00668 QString varName; 00669 QString access; 00670 }; 00671 00672 class SetVariablesCommand : public Command 00673 { 00674 public: 00675 SetVariablesCommand( const QString &name, FormWindow *fw, QValueList<MetaDataBase::Variable> lst ); 00676 void execute(); 00677 void unexecute(); 00678 Type type() const { return SetVariables; } 00679 00680 private: 00681 QValueList<MetaDataBase::Variable> oldList, newList; 00682 }; 00683 00684 class RemoveVariableCommand : public Command 00685 { 00686 public: 00687 RemoveVariableCommand( const QString &name, FormWindow *fw, const QString &vn ); 00688 void execute(); 00689 void unexecute(); 00690 Type type() const { return RemoveVariable; } 00691 00692 private: 00693 QString varName; 00694 QString access; 00695 }; 00696 00697 class EditDefinitionsCommand : public Command 00698 { 00699 public: 00700 EditDefinitionsCommand( const QString &name, FormWindow *fw, LanguageInterface *lf, 00701 const QString &n, const QStringList &l ); 00702 void execute(); 00703 void unexecute(); 00704 Type type() const { return EditDefinitions; } 00705 00706 private: 00707 LanguageInterface *lIface; 00708 QString defName; 00709 QStringList newList, oldList; 00710 }; 00711 00712 class LowerCommand : public Command 00713 { 00714 public: 00715 LowerCommand( const QString &name, FormWindow *fw, const QWidgetList &w ); 00716 00717 void execute(); 00718 void unexecute(); 00719 Type type() const { return Lower; } 00720 00721 private: 00722 QWidgetList widgets; 00723 00724 }; 00725 00726 class RaiseCommand : public Command 00727 { 00728 public: 00729 RaiseCommand( const QString &name, FormWindow *fw, const QWidgetList &w ); 00730 00731 void execute(); 00732 void unexecute(); 00733 Type type() const { return Raise; } 00734 00735 private: 00736 QWidgetList widgets; 00737 00738 }; 00739 00740 class PasteCommand : public Command 00741 { 00742 public: 00743 PasteCommand( const QString &n, FormWindow *fw, const QWidgetList &w ); 00744 00745 void execute(); 00746 void unexecute(); 00747 Type type() const { return Paste; } 00748 00749 private: 00750 QWidgetList widgets; 00751 00752 }; 00753 00754 class TabOrderCommand : public Command 00755 { 00756 public: 00757 TabOrderCommand( const QString &n, FormWindow *fw, const QWidgetList &ol, const QWidgetList &nl ); 00758 00759 void execute(); 00760 void unexecute(); 00761 Type type() const { return TabOrder; } 00762 void merge( Command *c ); 00763 bool canMerge( Command *c ); 00764 00765 private: 00766 QWidgetList oldOrder, newOrder; 00767 00768 }; 00769 00770 class PopulateListBoxCommand : public Command 00771 { 00772 public: 00773 struct Item 00774 { 00775 QString text; 00776 QPixmap pix; 00777 Q_DUMMY_COMPARISON_OPERATOR( Item ) 00778 }; 00779 00780 PopulateListBoxCommand( const QString &n, FormWindow *fw, 00781 QListBox *lb, const QValueList<Item> &items ); 00782 void execute(); 00783 void unexecute(); 00784 Type type() const { return PopulateListBox; } 00785 00786 bool operator==( const PopulateListBoxCommand & ) const; 00787 00788 private: 00789 QValueList<Item> oldItems, newItems; 00790 QListBox *listbox; 00791 00792 }; 00793 00794 class PopulateIconViewCommand : public Command 00795 { 00796 public: 00797 struct Item 00798 { 00799 QString text; 00800 QPixmap pix; 00801 Q_DUMMY_COMPARISON_OPERATOR( Item ) 00802 }; 00803 00804 PopulateIconViewCommand( const QString &n, FormWindow *fw, 00805 QIconView *iv, const QValueList<Item> &items ); 00806 void execute(); 00807 void unexecute(); 00808 Type type() const { return PopulateIconView; } 00809 00810 bool operator==( const PopulateIconViewCommand & ) const; 00811 00812 private: 00813 QValueList<Item> oldItems, newItems; 00814 QIconView *iconview; 00815 00816 }; 00817 00818 class PopulateListViewCommand : public Command 00819 { 00820 public: 00821 PopulateListViewCommand( const QString &n, FormWindow *fw, 00822 QListView *lv, QListView *from ); 00823 void execute(); 00824 void unexecute(); 00825 Type type() const { return PopulateListView; } 00826 static void transferItems( QListView *from, QListView *to ); 00827 00828 bool operator==( const PopulateListViewCommand & ) const; 00829 00830 private: 00831 QListView *oldItems, *newItems; 00832 QListView *listview; 00833 00834 }; 00835 00836 class PopulateMultiLineEditCommand : public Command 00837 { 00838 public: 00839 PopulateMultiLineEditCommand( const QString &n, FormWindow *fw, 00840 QTextEdit *mle, const QString &txt ); 00841 void execute(); 00842 void unexecute(); 00843 Type type() const { return PopulateMultiLineEdit; } 00844 00845 private: 00846 QString newText, oldText; 00847 QTextEdit *mlined; 00848 bool wasChanged; 00849 00850 }; 00851 00852 class PopulateTableCommand : public Command 00853 { 00854 public: 00855 struct Row 00856 { 00857 QString text; 00858 QPixmap pix; 00859 Q_DUMMY_COMPARISON_OPERATOR( Row ) 00860 }; 00861 00862 struct Column 00863 { 00864 QString text; 00865 QPixmap pix; 00866 QString field; 00867 Q_DUMMY_COMPARISON_OPERATOR( Column ) 00868 }; 00869 00870 PopulateTableCommand( const QString &n, FormWindow *fw, QTable *t, 00871 const QValueList<Row> &rows, 00872 const QValueList<Column> &columns ); 00873 00874 void execute(); 00875 void unexecute(); 00876 Type type() const { return PopulateTable; } 00877 00878 private: 00879 QValueList<Row> oldRows, newRows; 00880 QValueList<Column> oldColumns, newColumns; 00881 QTable *table; 00882 00883 }; 00884 00885 class AddActionToToolBarCommand : public Command 00886 { 00887 public: 00888 AddActionToToolBarCommand( const QString &n, FormWindow *fw, 00889 QAction *a, QDesignerToolBar *tb, int idx ); 00890 00891 void execute(); 00892 void unexecute(); 00893 Type type() const { return AddActionToToolBar; } 00894 00895 private: 00896 QAction *action; 00897 QDesignerToolBar *toolBar; 00898 int index; 00899 00900 }; 00901 00902 class RemoveActionFromToolBarCommand : public AddActionToToolBarCommand 00903 { 00904 public: 00905 RemoveActionFromToolBarCommand( const QString &n, FormWindow *fw, 00906 QAction *a, QDesignerToolBar *tb, int idx ) 00907 : AddActionToToolBarCommand( n, fw, a, tb, idx ) {} 00908 00909 void execute() { AddActionToToolBarCommand::unexecute(); } 00910 void unexecute() { AddActionToToolBarCommand::execute(); } 00911 Type type() const { return RemoveActionFromToolBar; } 00912 00913 }; 00914 00915 // MenuCommands 00916 00917 class AddToolBarCommand : public Command 00918 { 00919 public: 00920 AddToolBarCommand( const QString &n, FormWindow *fw, QMainWindow *mw ); 00921 00922 void execute(); 00923 void unexecute(); 00924 Type type() const { return AddToolBar; } 00925 00926 protected: 00927 QDesignerToolBar *toolBar; 00928 QMainWindow *mainWindow; 00929 00930 }; 00931 00932 class RemoveToolBarCommand : public AddToolBarCommand 00933 { 00934 public: 00935 RemoveToolBarCommand( const QString &n, FormWindow *fw, QMainWindow *mw, QDesignerToolBar *tb ) 00936 : AddToolBarCommand( n, fw, mw ) { toolBar = tb; } 00937 00938 void execute() { AddToolBarCommand::unexecute(); } 00939 void unexecute() { AddToolBarCommand::execute(); } 00940 Type type() const { return RemoveToolBar; } 00941 00942 }; 00943 00944 struct QWidgetContainerInterfacePrivate; 00945 00946 class AddContainerPageCommand : public Command 00947 { 00948 public: 00949 AddContainerPageCommand( const QString &n, FormWindow *fw, 00950 QWidget *c, const QString &label ); 00951 00952 ~AddContainerPageCommand(); 00953 00954 void execute(); 00955 void unexecute(); 00956 Type type() const { return AddContainerPage; } 00957 00958 private: 00959 QString wClassName; 00960 QWidget *container; 00961 int index; 00962 QString pageLabel; 00963 QWidget *page; 00964 QWidgetContainerInterfacePrivate *wiface; 00965 00966 }; 00967 00968 class DeleteContainerPageCommand : public Command 00969 { 00970 public: 00971 DeleteContainerPageCommand( const QString &n, FormWindow *fw, 00972 QWidget *container, int index ); 00973 ~DeleteContainerPageCommand(); 00974 00975 void execute(); 00976 void unexecute(); 00977 Type type() const { return DeleteContainerPage; } 00978 00979 private: 00980 QString wClassName; 00981 QWidget *container; 00982 int index; 00983 QString pageLabel; 00984 QWidget *page; 00985 QWidgetContainerInterfacePrivate *wiface; 00986 00987 }; 00988 00989 class RenameContainerPageCommand : public Command 00990 { 00991 public: 00992 RenameContainerPageCommand( const QString &n, FormWindow *fw, 00993 QWidget *container, int index, 00994 const QString &label ); 00995 ~RenameContainerPageCommand(); 00996 00997 void execute(); 00998 void unexecute(); 00999 Type type() const { return RenameContainerPage; } 01000 01001 private: 01002 QString wClassName; 01003 QWidget *container; 01004 int index; 01005 QString oldLabel, newLabel; 01006 QWidgetContainerInterfacePrivate *wiface; 01007 01008 }; 01009 01010 class AddActionToPopupCommand : public Command 01011 { 01012 public: 01013 AddActionToPopupCommand( const QString &n, 01014 FormWindow *fw, 01015 PopupMenuEditor *m, 01016 PopupMenuEditorItem *i, 01017 int idx = -1 ); 01018 void execute(); 01019 void unexecute(); 01020 Type type() const { return AddActionToPopup; } 01021 protected: 01022 QString constructName() const; 01023 PopupMenuEditor *menu; 01024 PopupMenuEditorItem *item; 01025 int index; 01026 private: 01027 }; 01028 01029 class RemoveActionFromPopupCommand : public AddActionToPopupCommand 01030 { 01031 public: 01032 RemoveActionFromPopupCommand( const QString &n, 01033 FormWindow *fw, 01034 PopupMenuEditor *m, 01035 int idx ); 01036 void execute(); 01037 void unexecute(); 01038 Type type() const { return RemoveActionFromPopup; } 01039 protected: 01040 private: 01041 }; 01042 01043 class ExchangeActionInPopupCommand : public Command 01044 { 01045 public: 01046 ExchangeActionInPopupCommand( const QString &n, 01047 FormWindow *fw, 01048 PopupMenuEditor *m, 01049 int a, 01050 int b ); 01051 void execute(); 01052 void unexecute(); 01053 Type type() const { return ExchangeActionInPopup; } 01054 protected: 01055 private: 01056 PopupMenuEditor *menu; 01057 int c; 01058 int d; 01059 }; 01060 /* 01061 class MoveActionInPopupCommand : public Command 01062 { 01063 public: 01064 MoveActionInPopupCommand( const QString &n, 01065 FormWindow *fw, 01066 PopupMenuEditor *m, 01067 int a, 01068 int b ); 01069 void execute(); 01070 void unexecute(); 01071 Type type() const { return MoveActionInPopup; } 01072 protected: 01073 private: 01074 PopupMenuEditor *menu; 01075 int from; 01076 int to; 01077 }; 01078 */ 01079 class ActionCommand : public Command 01080 { 01081 public: 01082 ActionCommand( const QString &n, 01083 FormWindow *fw, 01084 QAction *a ) 01085 : Command( n, fw ), action( a ) { } 01086 virtual Type type() const = 0; 01087 protected: 01088 ActionEditor *actionEditor(); 01089 QAction *action; 01090 }; 01091 01092 class RenameActionCommand : public ActionCommand 01093 { 01094 public: 01095 RenameActionCommand( const QString &n, 01096 FormWindow *fw, 01097 QAction *a, 01098 PopupMenuEditor *m, 01099 QString nm ); 01100 void execute(); 01101 void unexecute(); 01102 Type type() const { return RenameAction; } 01103 private: 01104 PopupMenuEditor *menu; 01105 QString newName; 01106 QString oldName; 01107 }; 01108 01109 class SetActionIconsCommand : public ActionCommand 01110 { 01111 public: 01112 SetActionIconsCommand( const QString &n, 01113 FormWindow *fw, 01114 QAction *a, 01115 PopupMenuEditor *m, 01116 QIconSet &icons ); 01117 void execute(); 01118 void unexecute(); 01119 Type type() const { return SetActionIcons; } 01120 protected: 01121 void updateActionEditorItem(); 01122 private: 01123 PopupMenuEditor *menu; 01124 QIconSet newIcons; 01125 QIconSet oldIcons; 01126 }; 01127 01128 class AddMenuCommand : public Command 01129 { 01130 public: 01131 AddMenuCommand( const QString &n, 01132 FormWindow *fw, 01133 MenuBarEditor *b, 01134 MenuBarEditorItem *i, 01135 int idx = -1 ); 01136 01137 AddMenuCommand( const QString &n, 01138 FormWindow *fw, 01139 QMainWindow *mw, 01140 const QString &nm = "Menu" ); 01141 01142 void execute(); 01143 void unexecute(); 01144 Type type() const { return AddMenu; } 01145 protected: 01146 MenuBarEditor *mb; 01147 MenuBarEditorItem *item; 01148 QString name; 01149 int index; 01150 private: 01151 }; 01152 01153 class RemoveMenuCommand : public AddMenuCommand 01154 { 01155 public: 01156 RemoveMenuCommand( const QString &n, 01157 FormWindow *fw, 01158 MenuBarEditor *b, 01159 int idx ); 01160 void execute(); 01161 void unexecute(); 01162 Type type() const { return RemoveMenu; } 01163 protected: 01164 private: 01165 }; 01166 01167 class ExchangeMenuCommand : public Command 01168 { 01169 public: 01170 ExchangeMenuCommand( const QString &n, 01171 FormWindow *fw, 01172 MenuBarEditor *b, 01173 int i, 01174 int j ); 01175 void execute(); 01176 void unexecute(); 01177 Type type() const { return ExchangeMenu; } 01178 protected: 01179 private: 01180 MenuBarEditor *bar; 01181 int k; 01182 int l; 01183 }; 01184 01185 01186 class MoveMenuCommand : public Command 01187 { 01188 public: 01189 MoveMenuCommand( const QString &n, 01190 FormWindow *fw, 01191 MenuBarEditor *b, 01192 int i, 01193 int j ); 01194 void execute(); 01195 void unexecute(); 01196 Type type() const { return MoveMenu; } 01197 protected: 01198 private: 01199 MenuBarEditor *bar; 01200 int from; 01201 int to; 01202 }; 01203 01204 class RenameMenuCommand : public Command 01205 { 01206 public: 01207 RenameMenuCommand( const QString &n, 01208 FormWindow *fw, 01209 MenuBarEditor *m, 01210 QString nm, 01211 MenuBarEditorItem *i ); 01212 void execute(); 01213 void unexecute(); 01214 Type type() const { return RenameMenu; } 01215 static QString makeLegal( const QString &str ); 01216 private: 01217 MenuBarEditor *bar; 01218 MenuBarEditorItem *item; 01219 QString newName; 01220 QString oldName; 01221 }; 01222 01223 class AddToolBoxPageCommand : public Command 01224 { 01225 public: 01226 AddToolBoxPageCommand( const QString &n, FormWindow *fw, 01227 QToolBox *tw, const QString &label ); 01228 01229 void execute(); 01230 void unexecute(); 01231 Type type() const { return AddToolBoxPage; } 01232 01233 private: 01234 QToolBox *toolBox; 01235 int index; 01236 QWidget *toolBoxPage; 01237 QString toolBoxLabel; 01238 01239 }; 01240 01241 class DeleteToolBoxPageCommand : public Command 01242 { 01243 public: 01244 DeleteToolBoxPageCommand( const QString &n, FormWindow *fw, 01245 QToolBox *tw, QWidget *page ); 01246 01247 void execute(); 01248 void unexecute(); 01249 Type type() const { return DeleteToolBoxPage; } 01250 01251 private: 01252 QToolBox *toolBox; 01253 int index; 01254 QWidget *toolBoxPage; 01255 QString toolBoxLabel; 01256 01257 }; 01258 01259 #endif