/[svn]/gigedit/trunk/src/gigedit/mainwindow.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3814 by schoenebeck, Fri Aug 14 12:29:01 2020 UTC revision 3826 by schoenebeck, Tue Oct 6 16:45:17 2020 UTC
# Line 3976  void MainWindow::on_instrument_selection Line 3976  void MainWindow::on_instrument_selection
3976              find(children.begin(), children.end(), item);              find(children.begin(), children.end(), item);
3977          if (it != children.end()) {          if (it != children.end()) {
3978              int index = it - children.begin();              int index = it - children.begin();
3979              m_TreeViewInstruments.get_selection()->select(Gtk::TreePath(ToString(index)));  
3980                // convert index of model to index of visual presentation (i.e. if filtered)
3981                Gtk::TreeModel::Path path = m_refInstrumentsModelFilter->convert_child_path_to_path(Gtk::TreePath(ToString(index)));
3982    
3983                if (path)
3984                    m_TreeViewInstruments.get_selection()->select(path);
3985                else
3986                    m_TreeViewInstruments.get_selection()->unselect_all();
3987    
3988              m_RegionChooser.set_instrument(file->GetInstrument(index));              m_RegionChooser.set_instrument(file->GetInstrument(index));
3989          }          }
# Line 5056  void MainWindow::on_action_remove_unused Line 5063  void MainWindow::on_action_remove_unused
5063      if (!file) return;      if (!file) return;
5064    
5065      // collect all samples that are not referenced by any instrument      // collect all samples that are not referenced by any instrument
5066      std::list<gig::Sample*> lsamples;      std::list<gig::Sample*> lsamples = unusedSamples(file);
     for (int iSample = 0; file->GetSample(iSample); ++iSample) {  
         gig::Sample* sample = file->GetSample(iSample);  
         bool isUsed = false;  
         for (gig::Instrument* instrument = file->GetFirstInstrument(); instrument;  
                               instrument = file->GetNextInstrument())  
         {  
             for (gig::Region* rgn = instrument->GetFirstRegion(); rgn;  
                               rgn = instrument->GetNextRegion())  
             {  
                 for (int i = 0; i < 256; ++i) {  
                     if (!rgn->pDimensionRegions[i]) continue;  
                     if (rgn->pDimensionRegions[i]->pSample != sample) continue;  
                     isUsed = true;  
                     goto endOfRefSearch;  
                 }  
             }  
         }  
         endOfRefSearch:  
         if (!isUsed) lsamples.push_back(sample);  
     }  
   
5067      if (lsamples.empty()) return;      if (lsamples.empty()) return;
5068    
5069      // notify everybody that we're going to remove these samples      // notify everybody that we're going to remove these samples

Legend:
Removed from v.3814  
changed lines
  Added in v.3826

  ViewVC Help
Powered by ViewVC