Logo Search packages:      
Sourcecode: qlix version File versions  Download package

void MTP::Album::RemoveTrack ( count_t  in_index  ) 

Removes the track at the given index of the album. The caller must ensure that the album is then updated on the device

Parameters:
in_index the track to remove
updateInternalStruct condition whether or not to update the structure on the device

Definition at line 494 of file MtpObject.cpp.

{
  if (in_index > _childTracks.size())
    return;
//  cout << "before removal album size: " << _childTracks.size() << endl;
  Track* deletedTrack = _childTracks[in_index];
  vector<Track*>::iterator iter = _childTracks.begin();
  vector<Track*>::iterator backup_iter;
  int i =0;
  while (*iter !=  deletedTrack) 
  { 
    i++;
    iter++; 
    assert(iter != _childTracks.end());
  }
//  cout << "Iterator found index at: " << i << " vs " << in_index << endl;

  backup_iter = iter +1;
  //Ensure that objects below this object have the correct index
  while (backup_iter != _childTracks.end())
  {
    Track* currentTrack = (*backup_iter);
    int prevIdx =  (*backup_iter)->GetRowIndex( );
    assert(prevIdx != 0);
    (*backup_iter)->SetRowIndex( (*backup_iter)->GetRowIndex() -1);
    backup_iter++;
  }
  assert(*iter == deletedTrack); 
  _childTracks.erase(iter);
  delete deletedTrack;
//  cout << "after removal album size: " << TrackCount() << endl;
}


Generated by  Doxygen 1.6.0   Back to index