Exemple #1
0
// solve state and return TRUE if Young
bool BrowserNode::solve()
{
    if (state != Unknown)
        return (state == Young);

    // note : parent can't be 0
    BrowserNode * p = (BrowserNode *) parent();

    if ((p->state == Unknown) ? p->solve() : (p->state == Young)) {
        state = Young;
        return TRUE;
    }
    else {
        state = Deleted;
        return FALSE;
    }
}
void BrowserView::update(const QList<BrowserView *> & lv)
{
    QHash<QString, Use*> all_nodes;//(DICT_SIZE);
    QList<BrowserView*>::const_iterator itv = lv.begin();

    //all_nodes.setAutoDelete(TRUE);

    // look at the revision in each view

    for (; itv != lv.end(); ++itv) {
        QHash<QString, BrowserNode*>::iterator itd = (*itv)->nodes.begin();

        for (; itd != (*itv)->nodes.end() ; ++itd) {
            BrowserNode * bn = *itd;
            int rev = bn->get_rev();
            Use * use = all_nodes.find(itd.key()).value();

            if (use == 0)
                all_nodes.insert(itd.key(), new Use(rev));
            else {
                if (rev < use->rev_min)
                    use->rev_min = rev;

                if (rev > use->rev_max)
                    use->rev_max = rev;

                use->count += 1;
            }
        }
    }

    // first solve step
    // only the package existing in all the view are solved

    int nviews = lv.count();
    QStringList deleted_or_new;

    QHash<QString, Use*>::iterator itu = all_nodes.begin();

    for (; itu!=all_nodes.end(); ++itu) {
        QString who = itu.key();
        Use * use = itu.value();

        if (use->count == nviews) {
            // exist in all views : solve the state
            if (use->rev_min == use->rev_max) {
                // up to date in all views
                itv = lv.begin();
                for (; itv != lv.end(); ++itv)
                    (*itv)->nodes.find(who).value()->set_state(UpToDate);
            }
            else {
                int max = use->rev_max;

                itv = lv.begin();
                for (; itv != lv.end(); ++itv) {
                    BrowserNode * pack = (*itv)->nodes.find(who).value();

                    pack->set_state((pack->get_rev() == max) ? Young : Old);
                }
            }
        }
        else {
            // deleted or new, mark it unknown for this step
            deleted_or_new.append(who);

            itv = lv.begin();
            for (; itv != lv.end(); ++itv) {
                BrowserNode * pack = (*itv)->nodes.find(who).value();

                if (pack != 0)
                    pack->set_state(Unknown);
            }
        }
    }
    itu = all_nodes.begin();
    for (; itu!=all_nodes.end(); ++itu)
    {
        delete itu.value();
    }
    all_nodes.clear();

    // solve packages marked unknown
    // a package is deleted if its parent is never 'Young'

    QStringList::Iterator it;

    for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) {
        QString who = *it;
        QList<BrowserNode *> images;
        bool young = FALSE;

        // set the state in each view without looking at the others
        itv = lv.begin();
        for (; itv != lv.end(); ++itv) {
            BrowserNode * pack = (*itv)->nodes.find(who).value();

            if (pack != 0) {
                images.append(pack);

                if (pack->solve())
                    young = TRUE;
            }
        }

        // set the final state if young, else all already marked deleted
        if (young) {
            ;

            foreach (BrowserNode * pack, images) {
                pack->set_state(Young);
            }
        }
    }
Exemple #3
0
void BrowserView::update(const Q3PtrList<BrowserView> & lv)
{
  Q3Dict<Use> all_nodes(DICT_SIZE);
  Q3PtrListIterator<BrowserView> itv(lv);
  
  all_nodes.setAutoDelete(TRUE);
  
  // look at the revision in each view
  
  for (; itv.current(); ++itv) {
    Q3DictIterator<BrowserNode> itd(itv.current()->nodes);

    for (; itd.current(); ++itd) {
      BrowserNode * bn = itd.current();
      int rev = bn->get_rev();
      Use * use = all_nodes.find(itd.currentKey());
      
      if (use == 0)
	all_nodes.insert(itd.currentKey(), new Use(rev));
      else {
	if (rev < use->rev_min)
	  use->rev_min = rev;
	if (rev > use->rev_max)
	  use->rev_max = rev;
	use->count += 1;
      }
    }
  }
  
  // first solve step
  // only the package existing in all the view are solved
  
  int nviews = lv.count();
  QStringList deleted_or_new;
  
  Q3DictIterator<Use> itu(all_nodes);
  
  for (; itu.current(); ++itu) {
    QString who = itu.currentKey();
    Use * use = itu.current();
	    
    if (use->count == nviews) {
      // exist in all views : solve the state
      if (use->rev_min == use->rev_max) {
	// up to date in all views
	for (itv.toFirst(); itv.current(); ++itv)
	  itv.current()->nodes.find(who)->set_state(UpToDate);
      }
      else {
	int max = use->rev_max;
	
	for (itv.toFirst(); itv.current(); ++itv) {
	  BrowserNode * pack = itv.current()->nodes.find(who);
	  
	  pack->set_state((pack->get_rev() == max) ? Young : Old);
	}
      }
    }
    else {
      // deleted or new, mark it unknown for this step
      deleted_or_new.append(who);
      
      for (itv.toFirst(); itv.current(); ++itv) {
	BrowserNode * pack = itv.current()->nodes.find(who);
	
	if (pack != 0)
	  pack->set_state(Unknown);
      }
    }
  }
  
  all_nodes.clear();
  
  // solve packages marked unknown
  // a package is deleted if its parent is never 'Young'
  
  QStringList::Iterator it;
  
  for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) {
    QString who = *it;
    Q3PtrList<BrowserNode> images;
    bool young = FALSE;
    
    // set the state in each view without looking at the others
    for (itv.toFirst(); itv.current(); ++itv) {
      BrowserNode * pack = itv.current()->nodes.find(who);
      
      if (pack != 0) {
	images.append(pack);
	if (pack->solve())
	  young = TRUE;
      }
    }
    
    // set the final state if young, else all already marked deleted
    if (young) {
      BrowserNode * pack;
      
      for (pack = images.first(); pack != 0; pack = images.next())
	pack->set_state(Young);
    }
  }
  
  // force update on views
  for (itv.toFirst(); itv.current(); ++itv)
    itv.current()->update_it();
}