Public Slots | Public Member Functions
ToolFactory Class Reference

#include <ToolFactory.h>

List of all members.

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)
GeopsyGuiInterfacetool (QString pluginTag)
 ToolFactory ()
 ~ToolFactory ()

Constructor & Destructor Documentation

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);
    }
  }
}

References TRACE.

{
  TRACE;
  // Save the list of popular tools
  QStringList l;
  int n=_popular.count();
  for(int i=0 ; i < n; i++ ) {
    l.append(action2Tag(_popular.at(i)));
  }
  QSettings reg;
  reg.beginGroup("Plugins");
  reg.beginGroup(GEOPSY_VERSION_TYPE);
  reg.setValue("popular", l);
}

Member Function Documentation

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);
  }
}

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::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());
  }
}

References TRACE.

{
  TRACE;
  QList<GeopsyGuiInterface *>::iterator it;
  for(it=_list.begin();it!=_list.end();++it) {
    (*it)->setHelp(h);
  }
}

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().

{
  TRACE;
  QAction * a=qobject_cast<QAction *>(sender());
  if(a) showTool(a);
}
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;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines