|
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 void setGuiElementColor( int guiElementIndex, const QColor &color ); 00074 00075 // Obtains indices of selected adapters from the view 00076 void selectedAdaptersInView( std::vector<int> &indices ); 00077 00078 // Creating and removing elements 00079 00080 // Returns the created element, or NULL is none was created. 00081 hydroqguielementutil::IGuiElement* createGuiElement( const QString &elementType, 00082 QStringList &elementDetails ); 00083 void removeAndDeleteGuiElement( hydroqguielementutil::IGuiElement *guiElement ); 00084 00085 // Inherited from PlatformFocusChangeReceiver 00086 void platformFocusChanged( const QString &newPlatformName ); 00087 00088 QColor platformColor( const QString &platformName ) 00089 { return platformColorMap_.getColor(platformName); } 00090 00091 bool isElementRemovable( int guiElementIndex ); 00092 00093 // const access to entire gui element set 00094 const hydroqgui::GuiElementSet &guiElementSet() const { return guiElementSet_; } 00095 00096 00097 signals: 00098 void newPlatform( const QString& ); 00099 void platformNeedsRemoval( const QString& ); 00100 00101 public slots: 00102 void removeAllGuiElements(); 00103 void createGuiElementFromSelection( const QList<QStringList> & ); 00104 00105 private: 00106 00107 // returns true if supported by a factory otherwise false 00108 bool instantiateFromFactories( hydroqguielementutil::IGuiElement* &element, 00109 const QString &elementType, 00110 const QColor &platformColor, 00111 const QStringList &elementDetails ); 00112 00113 void determinePlatform( QStringList &elementDetails, 00114 QString &platform ); 00115 00116 hydroqgui::GuiElementSet &guiElementSet_; 00117 00118 const QList<hydroqguielementutil::IGuiElement*> &elements() const { return guiElementSet_.elements(); } 00119 00120 const std::vector<hydroqgui::IGuiElementFactory*> factories_; 00121 QStringList headers_; 00122 hydroqguielementutil::IHumanManager &humanManager_; 00123 hydroqguielementutil::MouseEventManager &mouseEventManager_; 00124 hydroqguielementutil::ShortcutKeyManager &shortcutKeyManager_; 00125 hydroqgui::CoordinateFrameManager &coordinateFrameManager_; 00126 hydroqgui::PlatformFocusManager &platformFocusManager_; 00127 bool doesPlatformExist( QString &platformName ); 00128 bool doesElementExist( const QStringList& elementDetails, int numElements ); 00129 00130 hydroqgui::IStringToColorMap &platformColorMap_; 00131 00132 GuiElementView* view_; 00133 00134 QString lookupTypeFromFactories( QStringList &ids ); 00135 }; 00136 00137 00138 } 00139 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)
1.4.5