kexi

formmanager.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003    Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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 //static FormManager* FormManager_static = 0;
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 }; //todo
00096 
00103         ActionList createActions(WidgetLibrary *lib, KActionCollection* collection, KXMLGUIClient *client);
00104 
00108         virtual void enableAction( const char* name, bool enable ) = 0;
00109 
00111         virtual KAction* action(const char* name) = 0;
00112 
00113         bool isPasteEnabled();
00114 
00115 //      //! \return A pointer to the WidgetLibrary owned by this Manager.
00116 //      WidgetLibrary* lib() const { return m_lib; }
00117 
00119         WidgetPropertySet* propertySet() const { return m_propSet; }
00120 
00123         bool isInserting() const { return m_inserting; }
00124 
00127         QCString selectedClass() const { return m_selectedClass; }
00128 
00130         void setInsertPoint(const QPoint &p);
00131 
00133         bool isCreatingConnection() { return m_drawingSlot; }
00134 
00136         Connection* createdConnection() { return m_connection; }
00137 
00141         void resetCreatedConnection();
00142 
00144         void createSignalMenu(QWidget *w);
00145 
00147         void createSlotMenu(QWidget *w);
00148 
00150         void  emitCreateSlot(const QString &widget, const QString &value)
00151             { emit createFormSlot(m_active, widget, value); }
00152 
00155         Form* activeForm() const;
00156 
00159         Form* formForWidget(QWidget *w);
00160 
00164         bool isTopLevel(QWidget *w);
00165 
00167         //unused KoProperty::Editor* propertyEditor() const { return m_editor; }
00168 
00175         virtual void showPropertySet(WidgetPropertySet *set, bool forceReload = false, 
00176             const QCString& propertyToSelect = QCString());
00177 
00178         void blockPropertyEditorUpdating(void *blockingObject);
00179 
00180         void unblockPropertyEditorUpdating(void *blockingObject, WidgetPropertySet *set);
00181 
00183         void setEditor(KoProperty::Editor *editor);
00184 
00188         void setObjectTreeView(ObjectTreeView *treeview);
00189 
00191         void previewForm(Form *form, QWidget *w, Form *toForm=0);
00192 
00194         void importForm(Form *form=0, bool preview=false);
00195 
00197         void deleteForm(Form *form);
00198 
00202         void  createContextMenu(QWidget *w, Container *container, bool popupAtCursor = true);
00203 
00205         bool  snapWidgetsToGrid();
00206 
00208         int contextMenuKey() const { return m_contextMenuKey; }
00209 
00211         void emitWidgetSelected( KFormDesigner::Form* form, bool multiple );
00213         void emitFormWidgetSelected( KFormDesigner::Form* form );
00215         void emitNoFormSelected();
00216 
00220         bool isRedoing() const { return m_isRedoing; }
00221 
00222     public slots:
00224         void deleteWidget();
00225 
00227         void copyWidget();
00228 
00231         void cutWidget();
00232 
00236         void pasteWidget();
00237 
00239         void selectAll();
00240 
00242         void clearWidgetContent();
00243 
00244         void undo();
00245         void redo();
00246 
00249         void editTabOrder();
00250 
00252         void adjustWidgetSize();
00253 
00255         void editFormPixmapCollection();
00256 
00258         void editConnections();
00259 
00261         void layoutHBox();
00263         void layoutVBox();
00265         void layoutGrid();
00267         void  layoutHSplitter();
00269         void  layoutVSplitter();
00271         void layoutHFlow();
00273         void layoutVFlow();
00274 
00276         void breakLayout();
00277 
00278         void alignWidgetsToLeft();
00279         void alignWidgetsToRight();
00280         void alignWidgetsToTop();
00281         void alignWidgetsToBottom();
00282         void alignWidgetsToGrid();
00283 
00284         void adjustSizeToGrid();
00285 
00287         void adjustWidthToSmall();
00288 
00290         void adjustWidthToBig();
00291 
00293         void adjustHeightToSmall();
00294 
00296         void adjustHeightToBig();
00297 
00298         void bringWidgetToFront();
00299         void sendWidgetToBack();
00300 
00305         void insertWidget(const QCString &classname);
00306 
00308         void stopInsert();
00309 
00311         void slotPointerClicked();
00312 
00314         void startCreatingConnection();
00315 
00317         void stopCreatingConnection();
00318 
00323         void windowChanged(QWidget *w);
00324 
00326         void deleteWidgetLater( QWidget *w );
00327 
00330         void showFormUICode();
00331 
00333         void changeFont();
00334 
00335     signals:
00339         void propertySetSwitched(KoProperty::Set *set, bool forceReload = false, const QCString& propertyToSelect = QCString());
00340 
00343         void dirty(KFormDesigner::Form *form, bool isDirty=true);
00344 
00348         void widgetSelected(KFormDesigner::Form *form, bool multiple);
00349 
00352         void formWidgetSelected(KFormDesigner::Form *form);
00353 
00356         void noFormSelected();
00357 
00360         void undoEnabled(bool enabled, const QString &text = QString::null);
00361 
00364         void redoEnabled(bool enabled, const QString &text = QString::null);
00365 
00369         void createFormSlot(KFormDesigner::Form *form, const QString &widget, const QString &signal);
00370 
00374         void connectionCreated(KFormDesigner::Form *form, KFormDesigner::Connection &connection);
00375 
00377         void connectionAborted(KFormDesigner::Form *form);
00378 
00380         void autoTabStopsSet(KFormDesigner::Form *form, bool set);
00381 
00384         void aboutToDeleteForm(KFormDesigner::Form *form);
00385 
00387         void formCreated(KFormDesigner::Form *form);
00388 
00389     protected slots:
00390         void deleteWidgetLaterTimeout();
00391 
00393         void buddyChosen(int id);
00394 
00398         void menuSignalChosen(int id);
00399 
00401         void slotStyle();
00402 
00403         void slotConnectionCreated(KFormDesigner::Form*, KFormDesigner::Connection&);
00404 
00405         void slotSettingsChanged(int category);
00406 
00407     protected:
00409         void initForm(Form *form);
00410 
00411 #if 0
00412 
00414         virtual bool loadFormFromDomInternal(Form *form, QWidget *container, QDomDocument &inBuf);
00415 
00418         virtual bool saveFormToStringInternal(Form *form, QString &dest, int indent = 0);
00419 #endif
00420 
00423         void createLayout(int layoutType);
00424 
00426         void alignWidgets(int type);
00427 
00428         void enableFormActions();
00429         void disableWidgetActions();
00430         void emitUndoEnabled(bool enabled, const QString &text);
00431         void emitRedoEnabled(bool enabled, const QString &text);
00432 
00435         bool m_emitSelectionSignalsUpdatesPropertySet : 1;
00436 
00437     private:
00438         static FormManager* _self;
00439 
00441         enum { MenuTitle = 200, MenuCopy, MenuCut, MenuPaste, MenuDelete, MenuHBox = 301,
00442             MenuVBox, MenuGrid, MenuHSplitter, MenuVSplitter, MenuNoBuddy = 501 };
00443 
00444         WidgetPropertySet *m_propSet;
00445 //      WidgetLibrary *m_lib;
00446         QGuardedPtr<KoProperty::Editor>  m_editor;
00447         QGuardedPtr<ObjectTreeView>  m_treeview;
00448         // Forms
00449         QPtrList<Form> m_forms;
00450         QPtrList<Form> m_preview;
00451         QGuardedPtr<Form> m_active;
00452 
00453         // Copy/Paste
00454         QDomDocument m_domDoc;
00455         KPopupMenu *m_popup;
00456         QPoint m_insertPoint;
00457         QGuardedPtr<QWidget> m_menuWidget;
00458 
00459         // Insertion
00460         bool m_inserting;
00461         QCString m_selectedClass;
00462 
00463         // Connection stuff
00464         bool m_drawingSlot;
00465         Connection *m_connection;
00466         KPopupMenu *m_sigSlotMenu;
00467 
00468         // Actions
00469         KActionCollection *m_collection;
00470         KToggleAction *m_pointer, *m_dragConnection, *m_snapToGrid;
00471 
00473         QTimer m_deleteWidgetLater_timer;
00474         QPtrList<QWidget> m_deleteWidgetLater_list;
00475 
00476 #ifdef KEXI_DEBUG_GUI
00477         KDialogBase *m_uiCodeDialog;
00478         KTextEdit *m_currentUICodeDialogEditor;
00479         KTextEdit *m_originalUICodeDialogEditor;
00480 #endif
00481 
00482         int m_options; 
00483         int m_contextMenuKey; 
00484 
00485         void *m_objectBlockingPropertyEditorUpdating;
00486         bool m_isRedoing : 1;
00487 
00488         friend class PropertyCommand;
00489         friend class GeometryPropertyCommand;
00490         friend class CutWidgetCommand;
00491         friend class Form;
00492 };
00493 
00494 }
00495 
00496 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys