00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FORMMANAGER_H
00022 #define FORMMANAGER_H
00023
00024 #include <qobject.h>
00025 #include <qdom.h>
00026 #include <qptrlist.h>
00027 #include <qtimer.h>
00028 #include <qguardedptr.h>
00029 #include <qstringlist.h>
00030
00031 class QWidget;
00032 class QWorkspace;
00033 class KPopupMenu;
00034 class KActionCollection;
00035 class KAction;
00036 class KToggleAction;
00037 class KDialogBase;
00038 class KTextEdit;
00039 class KXMLGUIClient;
00040 class KMainWindow;
00041
00042 namespace KoProperty {
00043 class Editor;
00044 class Set;
00045 class Property;
00046 class Widget;
00047 }
00048
00049 namespace KFormDesigner {
00050
00051 class WidgetPropertySet;
00052 class Form;
00053 class Container;
00054 class WidgetLibrary;
00055 class ObjectTreeView;
00056 class Connection;
00057 class FormManager;
00058 typedef QPtrList<KAction> ActionList;
00059
00061
00062
00064
00072 class KFORMEDITOR_EXPORT FormManager : public QObject
00073 {
00074 Q_OBJECT
00075
00076 public:
00079 FormManager(QObject *parent = 0, int options = 0, const char *name = 0);
00080
00081 virtual ~FormManager();
00082
00085 static WidgetLibrary* createWidgetLibrary(FormManager* m,
00086 const QStringList& supportedFactoryGroups);
00087
00089 static FormManager* self();
00090
00094 enum Options { HideEventsInPopupMenu = 1, SkipFileActions = 2,
00095 HideSignalSlotConnections = 4 };
00096
00102 ActionList createActions(WidgetLibrary *lib, KActionCollection *parent);
00103
00107 virtual void enableAction( const char* name, bool enable ) = 0;
00108
00110 virtual KAction* action(const char* name) = 0;
00111
00112 bool isPasteEnabled();
00113
00114
00115
00116
00118 WidgetPropertySet* propertySet() const { return m_propSet; }
00119
00122 bool isInserting() const { return m_inserting; }
00123
00126 QCString selectedClass() const { return m_selectedClass; }
00127
00129 void setInsertPoint(const QPoint &p);
00130
00132 bool isCreatingConnection() { return m_drawingSlot; }
00133
00135 Connection* createdConnection() { return m_connection; }
00136
00140 void resetCreatedConnection();
00141
00143 void createSignalMenu(QWidget *w);
00144
00146 void createSlotMenu(QWidget *w);
00147
00149 void emitCreateSlot(const QString &widget, const QString &value)
00150 { emit createFormSlot(m_active, widget, value); }
00151
00154 Form* activeForm() const;
00155
00158 Form* formForWidget(QWidget *w);
00159
00163 bool isTopLevel(QWidget *w);
00164
00166 KoProperty::Editor* propertyEditor() const { return m_editor; }
00167
00172 virtual void showPropertySet(WidgetPropertySet *list, bool forceReload = false);
00173
00174 void blockPropertyEditorUpdating(void *blockingObject);
00175
00176 void unblockPropertyEditorUpdating(void *blockingObject, WidgetPropertySet *propSet);
00177
00179 void setEditor(KoProperty::Editor *editor);
00180
00184 void setObjectTreeView(ObjectTreeView *treeview);
00185
00187 void previewForm(Form *form, QWidget *w, Form *toForm=0);
00188
00190 void importForm(Form *form=0, bool preview=false);
00191
00193 void deleteForm(Form *form);
00194
00198 void createContextMenu(QWidget *w, Container *container, bool popupAtCursor = true);
00199
00201 bool snapWidgetsToGrid();
00202
00204 int contextMenuKey() const { return m_contextMenuKey; }
00205
00207 void emitWidgetSelected( KFormDesigner::Form* form, bool multiple );
00209 void emitFormWidgetSelected( KFormDesigner::Form* form );
00211 void emitNoFormSelected();
00212
00216 bool isRedoing() const { return m_isRedoing; }
00217
00218 public slots:
00220 void deleteWidget();
00221
00223 void copyWidget();
00224
00227 void cutWidget();
00228
00232 void pasteWidget();
00233
00235 void selectAll();
00236
00238 void clearWidgetContent();
00239
00240 void undo();
00241 void redo();
00242
00245 void editTabOrder();
00246
00248 void adjustWidgetSize();
00249
00251 void editFormPixmapCollection();
00252
00254 void editConnections();
00255
00257 void layoutHBox();
00259 void layoutVBox();
00261 void layoutGrid();
00263 void layoutHSplitter();
00265 void layoutVSplitter();
00267 void layoutHFlow();
00269 void layoutVFlow();
00270
00272 void breakLayout();
00273
00274 void alignWidgetsToLeft();
00275 void alignWidgetsToRight();
00276 void alignWidgetsToTop();
00277 void alignWidgetsToBottom();
00278 void alignWidgetsToGrid();
00279
00280 void adjustSizeToGrid();
00281
00283 void adjustWidthToSmall();
00284
00286 void adjustWidthToBig();
00287
00289 void adjustHeightToSmall();
00290
00292 void adjustHeightToBig();
00293
00294 void bringWidgetToFront();
00295 void sendWidgetToBack();
00296
00301 void insertWidget(const QCString &classname);
00302
00304 void stopInsert();
00305
00307 void slotPointerClicked();
00308
00310 void startCreatingConnection();
00311
00313 void stopCreatingConnection();
00314
00319 void windowChanged(QWidget *w);
00320
00322 void deleteWidgetLater( QWidget *w );
00323
00326 void showFormUICode();
00327
00329 void changeFont();
00330
00331 signals:
00335 void propertySetSwitched(KoProperty::Set *list, bool forceReload = false);
00336
00339 void dirty(KFormDesigner::Form *form, bool isDirty=true);
00340
00344 void widgetSelected(KFormDesigner::Form *form, bool multiple);
00345
00348 void formWidgetSelected(KFormDesigner::Form *form);
00349
00352 void noFormSelected();
00353
00356 void undoEnabled(bool enabled, const QString &text = QString::null);
00357
00360 void redoEnabled(bool enabled, const QString &text = QString::null);
00361
00365 void createFormSlot(KFormDesigner::Form *form, const QString &widget, const QString &signal);
00366
00370 void connectionCreated(KFormDesigner::Form *form, KFormDesigner::Connection &connection);
00371
00373 void connectionAborted(KFormDesigner::Form *form);
00374
00376 void autoTabStopsSet(KFormDesigner::Form *form, bool set);
00377
00380 void aboutToDeleteForm(KFormDesigner::Form *form);
00381
00383 void formCreated(KFormDesigner::Form *form);
00384
00385 protected slots:
00386 void deleteWidgetLaterTimeout();
00387
00389 void buddyChoosed(int id);
00390
00394 void menuSignalChoosed(int id);
00395
00397 void slotStyle();
00398
00399 void slotConnectionCreated(KFormDesigner::Form*, KFormDesigner::Connection&);
00400
00401 void slotSettingsChanged(int category);
00402
00403 protected:
00405 void initForm(Form *form);
00406
00407 #if 0
00408
00410 virtual bool loadFormFromDomInternal(Form *form, QWidget *container, QDomDocument &inBuf);
00411
00414 virtual bool saveFormToStringInternal(Form *form, QString &dest, int indent = 0);
00415 #endif
00416
00419 void createLayout(int layoutType);
00420
00422 void alignWidgets(int type);
00423
00424 void enableFormActions();
00425 void disableWidgetActions();
00426 void emitUndoEnabled(bool enabled, const QString &text);
00427 void emitRedoEnabled(bool enabled, const QString &text);
00428
00429 private:
00430 static FormManager* _self;
00431
00433 enum { MenuTitle = 200, MenuCopy, MenuCut, MenuPaste, MenuDelete, MenuHBox = 301,
00434 MenuVBox, MenuGrid, MenuHSplitter, MenuVSplitter, MenuNoBuddy = 501 };
00435
00436 WidgetPropertySet *m_propSet;
00437
00438 QGuardedPtr<KoProperty::Editor> m_editor;
00439 QGuardedPtr<ObjectTreeView> m_treeview;
00440
00441 QPtrList<Form> m_forms;
00442 QPtrList<Form> m_preview;
00443 QGuardedPtr<Form> m_active;
00444
00445
00446 QDomDocument m_domDoc;
00447 KPopupMenu *m_popup;
00448 QPoint m_insertPoint;
00449 QGuardedPtr<QWidget> m_menuWidget;
00450
00451
00452 bool m_inserting;
00453 QCString m_selectedClass;
00454
00455
00456 bool m_drawingSlot;
00457 Connection *m_connection;
00458 KPopupMenu *m_sigSlotMenu;
00459
00460
00461 KActionCollection *m_collection;
00462 KToggleAction *m_pointer, *m_dragConnection, *m_snapToGrid;
00463
00465 QTimer m_deleteWidgetLater_timer;
00466 QPtrList<QWidget> m_deleteWidgetLater_list;
00467
00468 #ifdef KEXI_SHOW_DEBUG_ACTIONS
00469 KDialogBase *m_uiCodeDialog;
00470 KTextEdit *m_currentUICodeDialogEditor;
00471 KTextEdit *m_originalUICodeDialogEditor;
00472 #endif
00473
00474 int m_options;
00475 int m_contextMenuKey;
00476
00477 void *m_objectBlockingPropertyEditorUpdating;
00478 bool m_isRedoing : 1;
00479
00480 friend class PropertyCommand;
00481 friend class GeometryPropertyCommand;
00482 friend class CutWidgetCommand;
00483 friend class Form;
00484 };
00485
00486 }
00487
00488 #endif