INTRODUCTION Overview Download and Install Quick Start Documentation Publications NONFRAMEWORK CODE Driver Interfaces Drivers Libraries Utilities FRAMEWORK CODE Interfaces Components Libraries Utilities Full Software Listings DEVELOPER Tutorials Examples Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
guielementmodel.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp, Ben Upcroft 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCA_ORCAQGUI_GUI_ELEMENT_MODEL_H 00012 #define ORCA_ORCAQGUI_GUI_ELEMENT_MODEL_H 00013 00014 #include <QAbstractTableModel> 00015 #include <QStringList> 00016 #include <QColor> 00017 00018 #include <hydroqgui/iguielementfactory.h> 00019 #include <hydroqgui/platformfocusmanager.h> 00020 #include <hydroqgui/platformfocusmanager.h> 00021 #include <hydroqgui/coordinateframemanager.h> 00022 #include <hydroqgui/platformfocusmanager.h> 00023 #include <hydroqgui/guielementset.h> 00024 #include <hydroqgui/istringtocolormap.h> 00025 00026 namespace orcaqgemv 00027 { 00028 00029 class GuiElementView; 00030 00034 class GuiElementModel : public QAbstractTableModel, 00035 public hydroqgui::PlatformFocusChangeReceiver 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 00041 // AlexB: TODO: What is this gear for? 00042 enum Roles { 00043 InterfaceIdRole = Qt::UserRole + 1, 00044 ContextMenuRole, 00045 FocusRole 00046 }; 00047 00048 explicit GuiElementModel( const std::vector<hydroqgui::IGuiElementFactory*> &factories, 00049 hydroqguielementutil::IHumanManager &humanManager, 00050 hydroqguielementutil::MouseEventManager &mouseEventManager, 00051 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager, 00052 hydroqgui::CoordinateFrameManager &coordinateFrameManager, 00053 hydroqgui::PlatformFocusManager &platformFocusManager, 00054 hydroqgui::GuiElementSet &guiElementSet, 00055 hydroqgui::IStringToColorMap &platformColorMap, 00056 QSplitter *spaceBottomRight = 0, 00057 QObject *parent = 0); 00058 00059 // 00060 // STANDARD MODEL API 00061 // 00062 virtual int rowCount(const QModelIndex &parent) const; 00063 virtual int columnCount(const QModelIndex &parent) const; 00064 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00065 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; 00066 virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() ); 00067 00068 // 00069 // CUSTOM API 00070 // 00071 void setView( GuiElementView* view ); 00072 void updateGuiElements(); 00073 void executeGuiElement( int guiElementIndex, int actionIndex ); 00074 00075 // sets the coordinate frame to the guielement's platform 00076 void setCoordinateFramePlatform( int guiElementIndex ); 00077 void setOriginPlatform( int guiElementIndex ); 00078 00079 void setGuiElementColor( int guiElementIndex, const QColor &color ); 00080 00081 // Obtains indices of selected adapters from the view 00082 void selectedAdaptersInView( std::vector<int> &indices ); 00083 00084 // Creates the element from the factories. 00085 // Returns the created element, or NULL is none was created 00086 hydroqguielementutil::GuiElement* createGuiElement( const QString &elementType, 00087 const QString &elementDescription, 00088 const QString &platformName, 00089 const QString &uniqueId ); 00090 00091 // Adds an element which has been created externally. 00092 void addGuiElement( hydroqguielementutil::GuiElement *element ); 00093 00094 void removeAndDeleteGuiElement( hydroqguielementutil::GuiElement *guiElement ); 00095 00096 // Inherited from PlatformFocusChangeReceiver 00097 void platformFocusChanged( const QString &newPlatformName ); 00098 00099 QColor platformColor( const QString &platformName ) 00100 { return platformColorMap_.getColor(platformName); } 00101 00102 bool isElementRemovable( int guiElementIndex ); 00103 00104 // const access to entire gui element set 00105 const hydroqgui::GuiElementSet &guiElementSet() const { return guiElementSet_; } 00106 00107 00108 signals: 00109 void newPlatform( const QString& ); 00110 void platformNeedsRemoval( const QString& ); 00111 00112 public slots: 00113 void removeAllGuiElements(); 00114 void createGuiElementFromSelection( const QList<QStringList> & ); 00115 00116 private: 00117 00118 // returns true if supported by a factory otherwise false 00119 bool instantiateFromFactories( hydroqguielementutil::GuiElement* &element, 00120 const hydroqguielementutil::GuiElementInfo &guiElementInfo ); 00121 00122 hydroqgui::GuiElementSet &guiElementSet_; 00123 00124 const QList<hydroqguielementutil::GuiElement*> &elements() const { return guiElementSet_.elements(); } 00125 00126 const std::vector<hydroqgui::IGuiElementFactory*> factories_; 00127 QStringList headers_; 00128 hydroqguielementutil::IHumanManager &humanManager_; 00129 hydroqguielementutil::MouseEventManager &mouseEventManager_; 00130 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager_; 00131 hydroqgui::CoordinateFrameManager &coordinateFrameManager_; 00132 hydroqgui::PlatformFocusManager &platformFocusManager_; 00133 00134 bool doesPlatformExist( const QString &platformName ); 00135 bool doesElementExist( const QString& uniqueId ); 00136 00137 hydroqgui::IStringToColorMap &platformColorMap_; 00138 00139 GuiElementView* view_; 00140 00141 QString lookupTypeFromFactories( QStringList &ids ); 00142 }; 00143 00144 00145 } 00146 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)