home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kommanderfactory.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-02-13  |  5.2 KB  |  161 lines

  1. /**********************************************************************
  2. ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
  3. **
  4. ** This file is part of Qt Designer.
  5. **
  6. ** This file may be distributed and/or modified under the terms of the
  7. ** GNU General Public License version 2 as published by the Free Software
  8. ** Foundation and appearing in the file LICENSE.GPL included in the
  9. ** packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  15. **
  16. ** Contact info@trolltech.com if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. **********************************************************************/
  20. /* Modifications by Marc Britton (c) 2002-2003 under GNU GPL, terms as above */
  21.  
  22. #ifndef _HAVE_KOMMANDERFACTORY_H_
  23. #define _HAVE_KOMMANDERFACTORY_H_
  24.  
  25. #include <qstring.h>
  26. #include <qptrlist.h>
  27. #include <qimage.h>
  28. #include <qpixmap.h>
  29. #include <qvaluelist.h>
  30. #include <qmap.h>
  31. #include <qaction.h>
  32. #include "kommander_export.h"
  33.  
  34. class QWidget;
  35. class QLayout;
  36. class QDomElement;
  37. class QListViewItem;
  38. class QTable;
  39. class QIconSet;
  40. class KommanderPlugin;
  41.  
  42. struct KommanderWidgetInfo
  43. {
  44.     KommanderWidgetInfo() {}
  45.     KommanderWidgetInfo( const QString &g, const QString &t, QIconSet *i, const QString &w = QString::null, bool c = FALSE )
  46.     : group( g ), toolTip( t ), iconSet(i), whatsThis( w ), isContainer( c )
  47.     {
  48.     }
  49.     QString group;
  50.     QString toolTip;
  51.     QIconSet *iconSet;
  52.     QString whatsThis;
  53.     bool isContainer;
  54. };
  55. typedef QMap<QString, KommanderWidgetInfo> FeatureList;
  56.  
  57. class KOMMANDER_EXPORT KommanderFactory
  58. {
  59. public:
  60.     KommanderFactory();
  61.     virtual ~KommanderFactory();
  62.  
  63.     static QWidget *create( const QString &uiFile, QObject *connector = 0, QWidget *parent = 0, const char *name = 0 );
  64.     static QWidget *create( QIODevice *dev, QObject *connector = 0, QWidget *parent = 0, const char *name = 0 );
  65.     static int loadPlugins( bool force = FALSE );
  66.     static void addPlugin( KommanderPlugin *plugin );
  67.     static void loadImages( const QString &dir );
  68.  
  69.     static QWidget *createWidget( const QString &className, QWidget *parent, const char *name );
  70.  
  71.     static FeatureList featureList();
  72. private:
  73.     enum LayoutType { HBox, VBox, Grid, NoLayout };
  74.     void loadImageCollection( const QDomElement &e );
  75.     void loadConnections( const QDomElement &e, QObject *connector );
  76.     void loadTabOrder( const QDomElement &e );
  77.     QWidget *createWidgetInternal( const QDomElement &e, QWidget *parent, QLayout* layout, const QString &classNameArg );
  78.     QLayout *createLayout( QWidget *widget, QLayout*  layout, LayoutType type );
  79.     LayoutType layoutType( QLayout *l ) const;
  80.     void setProperty( QObject* widget, const QString &prop, const QDomElement &e );
  81.     void createSpacer( const QDomElement &e, QLayout *layout );
  82.     QImage loadFromCollection( const QString &name );
  83.     QPixmap loadPixmap( const QDomElement &e );
  84.     QColorGroup loadColorGroup( const QDomElement &e );
  85.     void createColumn( const QDomElement &e, QWidget *widget );
  86.     void loadItem( const QDomElement &e, QPixmap &pix, QString &txt, bool &hasPixmap );
  87.     void createItem( const QDomElement &e, QWidget *widget, QListViewItem *i = 0 );
  88.     void loadChildAction( QObject *parent, const QDomElement &e );
  89.     void loadActions( const QDomElement &e );
  90.     void loadToolBars( const QDomElement &e );
  91.     void loadMenuBar( const QDomElement &e );
  92.     QAction *findAction( const QString &name );
  93.     QString translate( const QString& sourceText, const QString& comment = "" );
  94.  
  95. private:
  96.     struct Image {
  97.     QImage img;
  98.     QString name;
  99.     bool operator==(  const Image &i ) const {
  100.         return ( i.name == name &&
  101.              i.img == img );
  102.     }
  103.     };
  104.  
  105.     struct Field
  106.     {
  107.     Field() {}
  108.     Field( const QString &s1, const QPixmap &p, const QString &s2 ) : name( s1 ), pix( p ), field( s2 ) {}
  109.     QString name;
  110.     QPixmap pix;
  111.     QString field;
  112. #if defined(Q_FULL_TEMPLATE_INSTANTIATION)
  113.     bool operator==( const Field& ) const { return FALSE; }
  114. #endif
  115.     };
  116.  
  117.     struct EventFunction
  118.     {
  119.     EventFunction() {}
  120.     EventFunction( const QString &e, const QStringList &f )
  121.         : events( e ) { functions.append( f ); }
  122.     QStringList events;
  123.     QValueList<QStringList> functions;
  124.     };
  125.  
  126.     struct SqlWidgetConnection
  127.     {
  128.     SqlWidgetConnection() {}
  129.     SqlWidgetConnection( const QString &c, const QString &t )
  130.         : conn( c ), table( t ), dbControls( new QMap<QString, QString>() ) {}
  131.     QString conn;
  132.     QString table;
  133.     QMap<QString, QString> *dbControls;
  134.     };
  135.  
  136.     struct Functions
  137.     {
  138.     QString functions;
  139.     };
  140.  
  141.     QValueList<Image> images;
  142.     QWidget *toplevel;
  143.     QListViewItem *lastItem;
  144.     QMap<QString, QString> *dbControls;
  145.     QMap<QString, QStringList> dbTables;
  146.     QMap<QWidget*, SqlWidgetConnection> sqlWidgetConnections;
  147.     QMap<QString, QString> buddies;
  148.     QMap<QTable*, QValueList<Field> > fieldMaps;
  149.     QPtrList<QAction> actionList;
  150.    QMap<QObject *, EventFunction> eventMap;
  151.     QMap<QString, QString> languageSlots;
  152.     QMap<QString, Functions*> languageFunctions;
  153.     QStringList variables;
  154.     QStringList noDatabaseWidgets;
  155.     bool usePixmapCollection;
  156.     int defMargin, defSpacing;
  157.  
  158. };
  159.  
  160. #endif
  161.