Exemplo n.º 1
0
void KNFolder::removeArticles( KNLocalArticle::List &l, bool del )
{
  if( !isLoaded() || l.isEmpty() )
    return;

  int idx = 0, delCnt = 0, *positions;
  positions = new int[l.count()];
  KNLocalArticle *a = 0;

  for ( KNLocalArticle::List::Iterator it = l.begin(); it != l.end(); ++it, ++idx ) {
    if ( (*it)->isLocked() )
      positions[idx] = -1;
    else
      positions[idx] = a_rticles.indexForId( (*it)->id() );
  }

  for ( idx = 0; idx < (int)(l.count()); ++idx ) {
    if(positions[idx]==-1)
      continue;

    a=at(positions[idx]);

    //update
    knGlobals.artFactory->deleteComposerForArticle(a);
    ArticleWindow::closeAllWindowsForArticle( a );
    ArticleWidget::articleRemoved( a );
    delete a->listItem();

    //delete article
    a_rticles.remove( positions[idx], del );
    delCnt++;
    if(!del)
      a->setId(-1);
  }

  if(delCnt>0) {
    compact();
    c_ount-=delCnt;
    updateListItem();
    i_ndexDirty=true;
  }
  delete[] positions;
}
void KNFolder::removeArticles( KNLocalArticle::List &l, bool del )
{
  if( !isLoaded() || l.isEmpty() )
    return;

  int delCnt = 0;
  for ( int idx = 0; idx < l.count(); ++idx ) {
    KNLocalArticle::Ptr a = l[ idx ];
    if ( a->isLocked() ) {
      continue;
    }

    // check if this article belongs to this folder
    a = byId( a->id() );
    if ( !a ) {
      continue;
    }

    //update
    KNGlobals::self()->articleFactory()->deleteComposerForArticle(a);
    ArticleWindow::closeAllWindowsForArticle( a );
    ArticleWidget::articleRemoved( a );
    delete a->listItem();

    //delete article
    remove( a );
    delCnt++;
    if(!del)
      a->setId(-1);
  }

  if(delCnt>0) {
    compact();
    c_ount-=delCnt;
    updateListItem();
    i_ndexDirty=true;
  }
}