orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca 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-2008 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 <hydroqguielementutil/hydroqguielementutil.h> 00019 #include <hydroqgui/hydroqgui.h> 00020 00021 namespace orcaqgemv 00022 { 00023 00024 class GuiElementView; 00025 00029 class GuiElementModel : public QAbstractTableModel, 00030 public hydroqgui::PlatformFocusChangeReceiver 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 00036 // AlexB: TODO: What is this gear for? 00037 enum Roles { 00038 InterfaceIdRole = Qt::UserRole + 1, 00039 ContextMenuRole, 00040 FocusRole 00041 }; 00042 00043 explicit GuiElementModel( const std::vector<hydroqgui::IGuiElementFactory*> &factories, 00044 hydroqguielementutil::IHumanManager &humanManager, 00045 hydroqguielementutil::MouseEventManager &mouseEventManager, 00046 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager, 00047 hydroqgui::CoordinateFrameManager &coordinateFrameManager, 00048 hydroqgui::PlatformFocusManager &platformFocusManager, 00049 hydroqgui::GuiElementSet &guiElementSet, 00050 hydroqgui::IStringToColorMap &platformColorMap, 00051 QObject *parent = 0); 00052 00053 // 00054 // STANDARD MODEL API 00055 // 00056 virtual int rowCount(const QModelIndex &parent) const; 00057 virtual int columnCount(const QModelIndex &parent) const; 00058 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00059 virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; 00060 virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() ); 00061 00062 // 00063 // CUSTOM API 00064 // 00065 void setView( GuiElementView* view ); 00066 void updateGuiElements(); 00067 void executeGuiElement( int guiElementIndex, int actionIndex ); 00068 00069 // sets the coordinate frame to the guielement's platform 00070 void setCoordinateFramePlatform( int guiElementIndex ); 00071 void setOriginPlatform( int guiElementIndex ); 00072 00073 // Obtains indices of selected adapters from the view 00074 void selectedAdaptersInView( std::vector<int> &indices ); 00075 00076 // Creating and removing elements 00077 00078 // Returns the created element, or NULL is none was created. 00079 hydroqguielementutil::IGuiElement* createGuiElement( const QString &elementType, 00080 QStringList &elementDetails ); 00081 void removeAndDeleteGuiElement( hydroqguielementutil::IGuiElement *guiElement ); 00082 00083 // Inherited from PlatformFocusChangeReceiver 00084 void platformFocusChanged( const QString &newPlatformName ); 00085 00086 QColor platformColor( const QString &platformName ) 00087 { return platformColorMap_.getColor(platformName); } 00088 00089 bool isElementRemovable( int guiElementIndex ); 00090 00091 // const access to entire gui element set 00092 const hydroqgui::GuiElementSet &guiElementSet() const { return guiElementSet_; } 00093 00094 00095 signals: 00096 void newPlatform( const QString& ); 00097 void platformNeedsRemoval( const QString& ); 00098 00099 public slots: 00100 void removeAllGuiElements(); 00101 void createGuiElementFromSelection( const QList<QStringList> & ); 00102 00103 private: 00104 00105 // returns true if supported by a factory otherwise false 00106 bool instantiateFromFactories( hydroqguielementutil::IGuiElement* &element, 00107 const QString &elementType, 00108 const QColor &platformColor, 00109 const QStringList &elementDetails ); 00110 00111 void determinePlatform( QStringList &elementDetails, 00112 QString &platform ); 00113 00114 hydroqgui::GuiElementSet &guiElementSet_; 00115 00116 const QList<hydroqguielementutil::IGuiElement*> &elements() const { return guiElementSet_.elements(); } 00117 00118 const std::vector<hydroqgui::IGuiElementFactory*> factories_; 00119 QStringList headers_; 00120 hydroqguielementutil::IHumanManager &humanManager_; 00121 hydroqguielementutil::MouseEventManager &mouseEventManager_; 00122 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager_; 00123 hydroqgui::CoordinateFrameManager &coordinateFrameManager_; 00124 hydroqgui::PlatformFocusManager &platformFocusManager_; 00125 bool doesPlatformExist( QString &platformName ); 00126 bool doesElementExist( const QStringList& elementDetails, int numElements ); 00127 00128 hydroqgui::IStringToColorMap &platformColorMap_; 00129 00130 GuiElementView* view_; 00131 00132 QString lookupTypeFromFactories( QStringList &ids ); 00133 }; 00134 00135 00136 } 00137 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)