Added facilities for viewing the loaded actions.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-07-02 22:27:04 +02:00
parent 0d9022226c
commit 085c1b41b9
8 changed files with 178 additions and 0 deletions

View file

@ -68,6 +68,8 @@ namespace NLGUI
return _GlobalInstance; return _GlobalInstance;
} }
void getActionHandlers( std::vector< std::string > &handlers );
/// return pointer to action handler or null if it doesn't exist /// return pointer to action handler or null if it doesn't exist
IActionHandler *getActionHandler(const std::string &name) const IActionHandler *getActionHandler(const std::string &name) const
{ {

View file

@ -111,6 +111,18 @@ namespace NLGUI
} }
} }
void CAHManager::getActionHandlers( std::vector< std::string > &handlers )
{
handlers.clear();
std::map< string, IActionHandler* >::iterator itr = FactoryMap.begin();
while( itr != FactoryMap.end() )
{
handlers.push_back( itr->first );
++itr;
}
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
IActionHandler* CAHManager::getAH(const std::string &name, std::string &params) IActionHandler* CAHManager::getAH(const std::string &name, std::string &params)
{ {

View file

@ -30,6 +30,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_HDR
add_widget_widget.h add_widget_widget.h
editor_selection_watcher.h editor_selection_watcher.h
editor_message_processor.h editor_message_processor.h
action_list.h
) )
SET(OVQT_PLUGIN_GUI_EDITOR_UIS SET(OVQT_PLUGIN_GUI_EDITOR_UIS
@ -45,6 +46,7 @@ SET(OVQT_PLUGIN_GUI_EDITOR_UIS
new_property_widget.ui new_property_widget.ui
new_widget_widget.ui new_widget_widget.ui
add_widget_widget.ui add_widget_widget.ui
action_list.ui
) )
SET(QT_USE_QTGUI TRUE) SET(QT_USE_QTGUI TRUE)

View file

@ -0,0 +1,31 @@
#include "action_list.h"
#include "nel/gui/action_handler.h"
#include <vector>
#include <string>
ActionList::ActionList( QDialog *parent ) :
QDialog( parent )
{
setupUi( this );
}
ActionList::~ActionList()
{
}
void ActionList::load()
{
actionList->clear();
NLGUI::CAHManager *am = NLGUI::CAHManager::getInstance();
std::vector< std::string > handlers;
am->getActionHandlers( handlers );
std::vector< std::string >::const_iterator itr = handlers.begin();
while( itr != handlers.end() )
{
actionList->addItem( itr->c_str() );
++itr;
}
}

View file

@ -0,0 +1,18 @@
#ifndef ACTION_LIST_H
#define ACTION_LIST_H
#include "ui_action_list.h"
class ActionList : public QDialog, public Ui::ActionListDialog
{
Q_OBJECT
public:
ActionList( QDialog *parent = NULL );
~ActionList();
void load();
};
#endif

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ActionListDialog</class>
<widget class="QDialog" name="ActionListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>359</width>
<height>258</height>
</rect>
</property>
<property name="windowTitle">
<string>Action List</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="actionList"/>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>ActionListDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>278</x>
<y>253</y>
</hint>
<hint type="destinationlabel">
<x>96</x>
<y>254</y>
</hint>
</hints>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>ActionListDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>369</x>
<y>253</y>
</hint>
<hint type="destinationlabel">
<x>179</x>
<y>282</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -44,6 +44,7 @@
#include "editor_selection_watcher.h" #include "editor_selection_watcher.h"
#include "editor_message_processor.h" #include "editor_message_processor.h"
#include "add_widget_widget.h" #include "add_widget_widget.h"
#include "action_list.h"
namespace GUIEditor namespace GUIEditor
{ {
@ -70,6 +71,8 @@ namespace GUIEditor
widgetInfoTree = new CWidgetInfoTree; widgetInfoTree = new CWidgetInfoTree;
actionList = new ActionList();
createMenus(); createMenus();
readSettings(); readSettings();
@ -115,6 +118,9 @@ namespace GUIEditor
removeMenus(); removeMenus();
delete actionList;
actionList = NULL;
delete messageProcessor; delete messageProcessor;
messageProcessor = NULL; messageProcessor = NULL;
@ -341,6 +347,11 @@ namespace GUIEditor
} }
void GUIEditorWindow::test_actionList()
{
actionList->load();
actionList->show();
}
void GUIEditorWindow::hideEvent( QHideEvent *evnt ) void GUIEditorWindow::hideEvent( QHideEvent *evnt )
{ {
@ -400,6 +411,10 @@ namespace GUIEditor
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onAddWidgetClicked() ) );
m->addAction( a ); m->addAction( a );
a = new QAction( "Test actionlist", this );
connect( a, SIGNAL( triggered( bool ) ), this, SLOT( test_actionList() ) );
m->addAction( a );
menu = m; menu = m;
} }
} }

View file

@ -27,6 +27,7 @@
class QtTreePropertyBrowser; class QtTreePropertyBrowser;
class QMenu; class QMenu;
class ActionList;
namespace GUIEditor namespace GUIEditor
{ {
@ -66,6 +67,8 @@ private Q_SLOTS:
void onAddWidgetClicked(); void onAddWidgetClicked();
void onTreeChanged(); void onTreeChanged();
void test_actionList();
protected: protected:
void hideEvent( QHideEvent *evnt ); void hideEvent( QHideEvent *evnt );
void showEvent( QShowEvent *evnt ); void showEvent( QShowEvent *evnt );
@ -91,6 +94,7 @@ private:
CWidgetInfoTree *widgetInfoTree; CWidgetInfoTree *widgetInfoTree;
CEditorMessageProcessor *messageProcessor; CEditorMessageProcessor *messageProcessor;
AddWidgetWidget *addWidgetWidget; AddWidgetWidget *addWidgetWidget;
ActionList *actionList;
CPropBrowserCtrl browserCtrl; CPropBrowserCtrl browserCtrl;
QString currentProject; QString currentProject;