示例#1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int main (int argc, char  *argv[])
{
  QApplication app(argc, argv);

  FilterWidgetsLib::RegisterKnownQFilterWidgets();




  FilterWidgetManager::Pointer wm = FilterWidgetManager::Instance();

  FilterWidgetManager::Collection allFactories = wm->getFactories();


  for(FilterWidgetManager::Collection::iterator iter = allFactories.begin(); iter != allFactories.end(); ++iter)
  {
    QString filterName = QString::fromStdString((*iter).first);
    std::cout << "Writing " << filterName.toStdString() << std::endl;
    IFilterWidgetFactory::Pointer wf = (*iter).second;
    if (NULL == wf) { return EXIT_FAILURE;}
    QFilterWidget* w = wf->createWidget();
    QString filePath = QString("/tmp/") + filterName + QString(".ini");
    QSettings prefs(filePath, QSettings::IniFormat, NULL);
    prefs.beginGroup(QString("FILTER_NUMBER"));
    w->writeOptions(prefs);
    prefs.endGroup();

  }


  return EXIT_SUCCESS;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QWidget* FilterWidgetManager::createWidget(FilterParameter* parameter, AbstractFilter* filter)
{
  IFilterWidgetFactory::Pointer factory = m_Factories.value(parameter->getWidgetType());
  if(NULL != factory.get())
  {
    return factory->createWidget(parameter, filter, NULL);
  }
  UnknownWidget* unknownWidget = new UnknownWidget(parameter, filter, NULL);
  return unknownWidget;
}