#include <ToolFactory.h>
Public Slots | |
void | newGraphicWindow (const SubSignalPool &subPool) |
void | showTool () |
Public Member Functions | |
void | addActions (QWidget *w) |
bool | addPopularActions (QMenu *menu, const QObject *receiver, const char *slot) |
QList< QAction * > | createImportActions (QObject *parent) const |
void | createPreferenceTabs (QTabWidget *tab) |
void | createToolActions () |
int | exec (SubSignalPool *subPool, GeopsyGuiInterface *info, int slot, int &argc, char **argv) |
void | infoTools () |
void | setHelp (ApplicationHelp *h) |
void | setPreferences () |
void | showTool (QAction *a) |
GeopsyGuiInterface * | tool (QString pluginTag) |
ToolFactory () | |
~ToolFactory () |
References GeopsyCore::GeopsyPlugins::at(), GeopsyCore::GeopsyPlugins::count(), GeopsyCore::geopsyCore, GeopsyCore::GeopsyCoreEngine::plugins(), and TRACE.
{ TRACE; // Build list of plugins that contains a GUI extension GeopsyPlugins * plugins=geopsyCore->plugins(); int n=plugins->count(); for(int i=0; i<n; i++) { GeopsyCoreInterface * pCore=plugins->at(i); if(pCore) { GeopsyGuiInterface * pGui=qobject_cast<GeopsyGuiInterface *>(pCore); if(pGui) { _list.append(pGui); } } else { _list.append(new ToolSeparator); } } // Build the list of popular tools QSettings reg; reg.beginGroup("Plugins"); reg.beginGroup(GEOPSY_VERSION_TYPE); if(reg.contains("popular")) { QStringList l=reg.value("popular").toStringList(); int n=l.count(); for(int i=0; i< n ;i++) { QAction * a=tag2Action(l.at(i)); if(a) _popular.append(a); } } }
void ToolFactory::addActions | ( | QWidget * | w | ) |
All actions made available by the plugins are added to widget w The original actions are received.
References TRACE.
Referenced by GeopsyMainWindow::setToolFactory().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; for(it=_list.begin();it!=_list.end();++it) { (*it)->addActions(w); } }
bool ToolFactory::addPopularActions | ( | QMenu * | menu, |
const QObject * | receiver, | ||
const char * | slot | ||
) |
The popular actions are copied and added to menu, and the trigerred() signal is connected to the slot or receiver. The data of the action is set to the pointer of the original action.
References TRACE.
Referenced by FileView::contextMenuEvent(), and GroupView::contextMenuEvent().
{ TRACE; QList<QAction *>::iterator it; for(it=_popular.begin();it!=_popular.end();++it) { const QAction& original=**it; QAction * a=new QAction(original.icon(), original.text(), menu); a->setToolTip(original.toolTip()); QByteArray p((char *) &(*it), sizeof(QAction *)); a->setData(p); connect(a, SIGNAL(triggered()), receiver, slot); menu->addAction(a); } return !_popular.empty(); }
QList< QAction * > ToolFactory::createImportActions | ( | QObject * | parent | ) | const |
Create actions for menu import
References TRACE.
Referenced by GeopsyMainWindow::setToolFactory().
{ TRACE; QList<QAction *> actions; if(Application::instance()->hasGui()) { QList<GeopsyGuiInterface *>::const_iterator it; for(it=_list.begin();it!=_list.end();++it) { actions << (*it)->createImportActions(parent); } } return actions; }
void ToolFactory::createPreferenceTabs | ( | QTabWidget * | tab | ) |
References TRACE.
Referenced by GeopsyMainWindow::setPreferences().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; for(it=_list.begin();it!=_list.end();++it) { (*it)->addPreferenceTab(tab); } }
void ToolFactory::createToolActions | ( | ) |
Create actions for menu tools
References TRACE.
Referenced by Engine::Engine().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; for(it=_list.begin();it!=_list.end();++it) { (*it)->createToolActions(this); } }
int ToolFactory::exec | ( | SubSignalPool * | subPool, |
GeopsyGuiInterface * | info, | ||
int | slot, | ||
int & | argc, | ||
char ** | argv | ||
) |
References GeopsyGui::ToolBase::closeChildren(), GeopsyGui::GeopsyGuiInterface::createTool(), GeopsyGui::ToolBase::initStations(), GeopsyGui::ToolBase::outputResults(), GeopsyGui::ToolBase::setParameters(), GeopsyGui::ToolBase::start(), tool(), TRACE, and GeopsyGui::ToolBase::waitFinished().
Referenced by modeTool().
{ TRACE; ToolBase * tool=info->createTool(slot, 0); if(tool->initStations(subPool)) { tool->setParameters(argc, argv); tool->start(); tool->waitFinished(); tool->outputResults(argc, argv); tool->closeChildren(); delete tool; return 0; } else { delete tool; return 2; } }
void ToolFactory::infoTools | ( | ) |
References GeopsyGui::GeopsyGuiInterface::slotCount(), GeopsyGui::GeopsyGuiInterface::slotText(), GeopsyCore::GeopsyCoreInterface::tag(), and TRACE.
{ TRACE; printf( "\nTools :\n\n" ); QList<GeopsyGuiInterface *>::iterator it; GeopsyGuiInterface * info; for(it=_list.begin();it!=_list.end();++it) { info=*it; printf( " %s : ", info->tag().toAscii().data()); int n=info->slotCount(); for(int i=0;i < n;i++ ) { if(i > 0) printf( ", " ); printf( "%s(%i)", info->slotText(i).toAscii().data(), i); } printf( "\n" ); } }
void ToolFactory::newGraphicWindow | ( | const SubSignalPool & | subPool | ) | [slot] |
References geopsyGui, showTool(), SigSelectionDnD::source(), and TRACE.
{ TRACE; SigSelectionDnD * dnd=qobject_cast<SigSelectionDnD *>(sender()); geopsyGui->newGraphicWindow(subPool); if(dnd) { QToolButton * b=qobject_cast<QToolButton *>(dnd->source()); if(b) showTool(b->defaultAction()); } }
void ToolFactory::setHelp | ( | ApplicationHelp * | h | ) |
void ToolFactory::setPreferences | ( | ) |
References TRACE.
Referenced by GeopsyMainWindow::setPreferences().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; for(it=_list.begin();it!=_list.end();++it) { (*it)->setPreferences(); } }
void ToolFactory::showTool | ( | QAction * | a | ) |
References showTool(), GeopsyGui::GeopsyGuiInterface::slotOf(), and TRACE.
Referenced by FileView::newTool(), and GroupView::newTool().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; GeopsyGuiInterface * info; int slot; for(it=_list.begin();it!=_list.end();++it) { info=*it; slot=info->slotOf(a); if(slot > -1) { showTool(info, slot); break; } } }
void ToolFactory::showTool | ( | ) | [slot] |
References TRACE.
Referenced by newGraphicWindow(), and showTool().
GeopsyGuiInterface * ToolFactory::tool | ( | QString | pluginTag | ) |
References GeopsyCore::GeopsyCoreInterface::tag(), and TRACE.
Referenced by exec(), and modeTool().
{ TRACE; QList<GeopsyGuiInterface *>::iterator it; GeopsyGuiInterface * info; for(it=_list.begin();it!=_list.end();++it) { info=*it; if(info->tag()==toolTag) { return info; } } return 0; }