コード例 #1
0
bool KNArticleManager::toggleIgnored(KNRemoteArticle::List &l)
{
  if(l.isEmpty())
    return true;

  KNRemoteArticle *ref = 0;
  bool ignore = !l.first()->isIgnored();
  KNGroup *g = static_cast<KNGroup*>( l.first()->collection() );
  int changeCnt = 0, idRef = 0;

  for ( KNRemoteArticle::List::Iterator it = l.begin(); it != l.end(); ++it ) {
    (*it)->setWatched(false);
    if ( (*it)->isIgnored() != ignore ) {
      (*it)->setIgnored( ignore );

      if ( !(*it)->getReadFlag() ) {
        changeCnt++;
        idRef = (*it)->idRef();

        while ( idRef != 0 ) {
          ref = g->byId( idRef );

          if ( ignore ) {
            ref->decUnreadFollowUps();
            if ( (*it)->isNew() )
              ref->decNewFollowUps();
          } else {
            ref->incUnreadFollowUps();
            if ( (*it)->isNew() )
              ref->incNewFollowUps();
          }

          if(ref->listItem() &&
             ((ref->unreadFollowUps()==0 || ref->unreadFollowUps()==1) ||
              (ref->newFollowUps()==0 || ref->newFollowUps()==1)))
            ref->updateListItem();

          idRef=ref->idRef();
        }

        if ( ignore ) {
          g->incReadCount();
          if ( (*it)->isNew() )
            g->decNewCount();
        } else {
          g->decReadCount();
          if ( (*it)->isNew() )
            g->incNewCount();
        }

      }
    }
    (*it)->updateListItem();
    (*it)->setChanged(true);
  }

  if(changeCnt>0) {
    g->updateListItem();
    if(g==g_roup)
      updateStatusString();
  }

  return ignore;
}
コード例 #2
0
void KNArticleManager::setRead(KNRemoteArticle::List &l, bool r, bool handleXPosts)
{
  if ( l.isEmpty() )
    return;

  KNRemoteArticle *ref = 0;
  KNGroup *g=static_cast<KNGroup*>( l.first()->collection() );
  int changeCnt=0, idRef=0;

  for ( KNRemoteArticle::List::Iterator it = l.begin(); it != l.end(); ++it ) {
    if( r && knGlobals.settings()->markCrossposts() &&
        handleXPosts && (*it)->newsgroups()->isCrossposted() ) {

      QList<QByteArray> groups = (*it)->newsgroups()->groups();
      KNGroup *targetGroup=0;
      KNRemoteArticle *xp=0;
      KNRemoteArticle::List al;
      QByteArray mid = (*it)->messageID()->as7BitString( false );

      for ( QList<QByteArray>::Iterator it2 = groups.begin(); it2 != groups.end(); ++it2 ) {
        targetGroup = knGlobals.groupManager()->group(*it2, g->account());
        if (targetGroup) {
          if (targetGroup->isLoaded() && (xp=targetGroup->byMessageId(mid)) ) {
            al.clear();
            al.append(xp);
            setRead(al, r, false);
          } else {
            targetGroup->appendXPostID(mid);
          }
        }
      }
    }

    else if ( (*it)->getReadFlag() != r ) {
      (*it)->setRead( r );
      (*it)->setChanged( true );
      (*it)->updateListItem();

      if ( !(*it)->isIgnored() ) {
        changeCnt++;
        idRef = (*it)->idRef();

        while ( idRef != 0 ) {
          ref=g->byId(idRef);
          if(r) {
            ref->decUnreadFollowUps();
            if ( (*it)->isNew() )
              ref->decNewFollowUps();
          }
          else {
            ref->incUnreadFollowUps();
            if ( (*it)->isNew() )
              ref->incNewFollowUps();
          }

          if(ref->listItem() &&
             ((ref->unreadFollowUps()==0 || ref->unreadFollowUps()==1) ||
              (ref->newFollowUps()==0 || ref->newFollowUps()==1)))
            ref->updateListItem();

          idRef=ref->idRef();
        }

        if(r) {
          g->incReadCount();
          if ( (*it)->isNew() )
            g->decNewCount();
        }
        else {
          g->decReadCount();
          if ( (*it)->isNew() )
            g->incNewCount();
        }
      }
    }
  }

  if(changeCnt>0) {
    g->updateListItem();
    if(g==g_roup)
      updateStatusString();
  }
}