Logo Search packages:      
Sourcecode: packagesearch version File versions

void PackageSearchImpl::onSearchChanged ( NPlugin::SearchPlugin *  pPlugin  )  [protected, virtual, slot]

Evaluates the plugin search results and displays them in the GUI.

This is called whenever the search of a SearchPlugin changes.

Parameters:
pPlugin the plugin where the search changed or 0 if no originator is known

Definition at line 570 of file packagesearchimpl.cpp.

References _packages, _pHandleMaker, _searchPlugins, reportBusy(), reportReady(), and updateShortInformation().

Referenced by addPlugin(), and onPackageViewContextMenu().

{
      reportBusy(0, tr("Evaluating searches"));
      using namespace NPlugin;
      Tagcoll::OpSet<int> result;
      bool first = true;      // keeps track if this is the first search which produces results
      // evaluate plugins which do not uses filter technique
      for (SearchPluginContainer::iterator it = _searchPlugins.begin(); it != _searchPlugins.end(); ++it)
      {
            SearchPlugin* pPlugin = *it;
            if (!pPlugin->isInactive())
            {
                  if (!pPlugin->usesFilterTechnique())
                  {
                        if (first)
                        {
                              result = pPlugin->searchResult();
                              first = false;
                        }
                        else
                              result ^= pPlugin->searchResult();  // create the intersection
                  }
            }
      }
      // filter the resulting packages through the filter plugins
      for (SearchPluginContainer::iterator it = _searchPlugins.begin(); it != _searchPlugins.end(); ++it)
      {
            SearchPlugin* pPlugin = *it;
            if (!pPlugin->isInactive())
            {
                  // if we had no search which returned a result set
                  if (first) 
                  {
                        // the result set are all packages available
                        for (set<string>::const_iterator it = _packages.begin(); it != _packages.end(); ++it)
                              result.insert(_pHandleMaker->getHandle(*it));
                        first = false;
                  }
                  if (pPlugin->usesFilterTechnique())
                  {
                        Tagcoll::OpSet<int> newResult;
                        FilterPackages fp(pPlugin);
                        // copy the packages which are matched by the package filter to newResult
                        NExtStd::copy_if( result.begin(), result.end(), inserter(newResult, newResult.begin()), fp );
                        swap(newResult, result);
                  }
            }
      }
      // if at least one search was active
      if (!first)
            setPackagesFound(result.size());
      else
      {
            setPackagesFound(-1);
            result.clear();
      }
      updateShortInformation(result);
      reportReady(0);
}


Generated by  Doxygen 1.6.0   Back to index