~jibel/synaptic/bugs.290524.502582

« back to all changes in this revision

Viewing changes to common/rpackageview.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-02-11 19:58:40 UTC
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20100211195840-boor3ejy4wpp84iz
Tags: 0.63.1
* po/pt_BR.po:
  - Updated pt_BR.po, thanks to Sergio Cipolla (closes: #561853)
* po/sk.po:
  - Updated sk.po, thanks to helix84 (closes: #559283)
* po/uk.po
  - add ukrainian translation, thanks to Serhij Dubyk 
* common/rpackageview.{cc,h}:
  - remember search history accross package transactions
* make the origin filter more fine grained
* gtk/rgsummarywindow.cc:
  - move the gtk_tree_view_set_model() down to speed up the
    operation
* gtk/rgdebinstallprogress.cc:
  - on error, set error string into status label
  - when the recovery is run (dpkg --configure -a) display a 
    proper status label for that
* gtk/rgaboutpanel.cc:
  - fix FTBFS with gcc-4.5 (closes: #565077)
* additions to the (internal) API
* gtk/rgdebinstallprogress.cc:
  - make the dpkg progress code less cpu intensive

Show diffs side-by-side

added added

removed removed

Lines of Context:
183
183
   const char *tmp=NULL;
184
184
   bool global_found=true;
185
185
 
186
 
   if(!pkg || searchStrings.empty())
 
186
   if(!pkg || _currentSearchItem.searchStrings.empty())
187
187
      return;
188
188
 
189
189
   // build the string
190
 
   switch(searchType) {
 
190
   switch(_currentSearchItem.searchType) {
191
191
   case RPatternPackageFilter::Name:
192
192
      tmp = pkg->name();
193
193
      break;
222
222
      str = tmp;
223
223
      
224
224
   // find the search pattern in the string "str"
225
 
   for(unsigned int i=0;i<searchStrings.size();i++) {
226
 
      string searchString = searchStrings[i];
 
225
   for(unsigned int i=0;i<_currentSearchItem.searchStrings.size();i++) {
 
226
      string searchString = _currentSearchItem.searchStrings[i];
227
227
 
228
228
      if(!str.empty() && strcasestr(str.c_str(), searchString.c_str())) {
229
229
         global_found &= true;
232
232
      }
233
233
   }
234
234
   if(global_found) {
235
 
      _view[searchName].push_back(pkg);
 
235
      _view[_currentSearchItem.searchName].push_back(pkg);
236
236
      found++;
237
237
   }
238
238
 
242
242
   //_view[searchString].push_back(NULL);
243
243
}
244
244
 
 
245
bool RPackageViewSearch::setSelected(string name)
 
246
{
 
247
   // if we do not have the search name in the current view, 
 
248
   // check if we only have it in the searchHistory and if so,
 
249
   // redo the search
 
250
   if (_view.find(name) == _view.end()) {
 
251
      map<string, searchItem>::iterator J = searchHistory.find(name);
 
252
      if (J != searchHistory.end()) {
 
253
         cerr << "found in search histroy, reapplying search" << endl;
 
254
         string s;
 
255
         OpProgress progress;
 
256
         for(int i=0;i < (*J).second.searchStrings.size();i++)
 
257
            s += string(" ") + (*J).second.searchStrings[i];
 
258
         // do search but do not add to history (we have it there already)
 
259
         setSearch((*J).second.searchName, (*J).second.searchType, s, 
 
260
                   // FIXME: re-use progress from setSearch()
 
261
                   progress);
 
262
      }
 
263
   }
 
264
 
 
265
   // call parent
 
266
   return RPackageView::setSelected(name);
 
267
}
 
268
 
 
269
vector<string> RPackageViewSearch::getSubViews()
 
270
{
 
271
   vector<string> subviews;
 
272
   for(map<string, searchItem>::iterator I = searchHistory.begin();
 
273
       I != searchHistory.end();
 
274
       I++)
 
275
     subviews.push_back((*I).first);
 
276
   return subviews;
 
277
}
 
278
 
245
279
int RPackageViewSearch::setSearch(string aSearchName, 
246
280
                                  int type, 
247
281
                                  string searchString, 
248
282
                                  OpProgress &searchProgress)
249
283
{
250
284
   found = 0;
251
 
   searchType = type;
252
 
   searchName = aSearchName;
253
 
 
254
 
   _view[searchName].clear();
255
 
   searchStrings.clear();
 
285
 
 
286
   _currentSearchItem.searchType = type;
 
287
   _currentSearchItem.searchName = aSearchName;
 
288
 
 
289
   _view[_currentSearchItem.searchName].clear();
 
290
   _currentSearchItem.searchStrings.clear();
256
291
 
257
292
   // tokenize the str and add to the searchString vector
258
293
   stringstream sstream(searchString);
259
294
   string s;
260
295
   while(!sstream.eof()) {
261
296
      sstream >> s;
262
 
      searchStrings.push_back(s);
 
297
      _currentSearchItem.searchStrings.push_back(s);
263
298
   }
264
299
 
 
300
   // overwrite existing ones
 
301
   searchHistory[aSearchName] =  _currentSearchItem;
 
302
   
265
303
   // setup search progress (0 done, _all.size() in total, 1 subtask)
266
304
   searchProgress.OverallProgress(0, _all.size(), 1, _("Searching"));
267
305
   // reapply search when a new search strng is given
512
550
 
513
551
void RPackageViewOrigin::addPackage(RPackage *package)
514
552
{
 
553
   string subview;
515
554
   string component =  package->component();
516
 
   string origin = package->getCanidateOrigin();
517
 
   if(origin == "")
518
 
      origin = _("Local");
 
555
   string origin_url = package->getCandidateOriginSiteUrl();
 
556
   string suite  = package->getCandidateOriginSuite();
 
557
   string origin_str  = package->getCandidateOriginStr();
 
558
 
 
559
   // local origins are all put under local (no matter what component, section)
 
560
   if(origin_url == "") {
 
561
      origin_url = _("Local");
 
562
      _view[origin_url].push_back(package);
 
563
      return;
 
564
   }
 
565
 
 
566
   // PPAs are special too
 
567
   if(origin_str.find("LP-PPA-") != string::npos) {
 
568
     _view[origin_str+"/"+suite].push_back(package);
 
569
     return;
 
570
   }
 
571
 
519
572
   if(component == "")
520
573
      component = _("Unknown");
521
 
   _view[origin+"/"+component].push_back(package);
 
574
   if(suite == "now")
 
575
      suite = "";
 
576
 
 
577
   subview = suite+"/"+component+" ("+origin_url+")";
 
578
   _view[subview].push_back(package);
522
579
 };
523
580
 
524
581
// vim:sts=3:sw=3