Beispiel #1
0
void TagViewer::mouseReleaseEvent(
    QMouseEvent* e
)
{
    if( !tagging_ || e->button() != Qt::LeftButton ) {
        return;
    }

    tag_end_ = e->pos();
    enforce_boundary_conditions( tag_end_ );

    float scale_f = scale_factor();

    // make a valid rectangle
    QRect tag( tag_start_ / scale_f, tag_end_ / scale_f );
    int left = tag.left();
    int top = tag.top();
    if( left > tag.right() ) {
        tag.setLeft( tag.right() );
        tag.setRight( left );
    }
    if( top > tag.bottom() ) {
        tag.setTop( tag.bottom() );
        tag.setBottom( top );
    }

    emit( tagged( tag ) );

    tag_start_ = QPoint( 0, 0 );
    tag_end_ = QPoint( 0, 0 );
}
Beispiel #2
0
void
ThreadedBlock::postInvoke(Context *ctx, InvokeContext *invoke_ctx) {
    Block::postInvoke(ctx, invoke_ctx);
    if (invoke_ctx->error()) {
        return;
    }

    bool show_elapsed_time = trb_data_->check_elapsed_time_ ? trb_data_->check_elapsed_time_ :
    OperationMode::instance()->checkDevelopmentVariable(ctx->request(), ThreadedBlockData::SHOW_ELAPSED_TIME);
       
    if (!show_elapsed_time || tagged()) {
        return;
    }
    
    xmlNodePtr node = xmlDocGetRootElement(invoke_ctx->resultDoc().get());
    if (NULL == node) {
        return;
    }
    
    const xmlChar* elapsed_attr = (const xmlChar*)"elapsed-time";
    std::string elapsed = boost::lexical_cast<std::string>(0.001*ctx->timer().elapsed());
    if (xmlHasProp(node, elapsed_attr) &&
        xmlUnsetProp(node, elapsed_attr) < 0) {
        log()->error("Cannot unset elapsed-time attribute");
        return;
    }
    xmlNewProp(node, elapsed_attr, (const xmlChar*)elapsed.c_str());
}
Beispiel #3
0
bool ClauseHead::toImplication(Solver& s) {
	ConstraintType t  = ClauseHead::type();
	uint32 sz         = isSentinel(head_[1]) ? 1 : 2 + (!s.isFalse(head_[2]) || s.level(head_[2].var()) > 0);
	ClauseRep rep     = ClauseRep::create(head_, sz, ClauseInfo(t).setLbd(2).setTagged(tagged()));
	bool   implicit   = s.allowImplicit(rep);
	bool   locked     = ClauseHead::locked(s) && s.decisionLevel() > 0;
	rep.prep          = 1;
	if ((locked || !implicit) && sz > 1) { return false; }
	s.add(rep, false);
	detach(s);
	return true;
}
Beispiel #4
0
void check_child(struct Node** G, int node_count, int current_id, int * sign, int max_id){
//    display_graph2(G, max_id + 1);
    struct Node* current_node = G[current_id];
//    printf("check %i has %i children should have id: %i\n", current_node->node_id, current_node->neighbour_count, current_id);
    for (int j = 0; j < current_node->neighbour_count; j ++) {
        int child_id = current_node->neighbours[j];
//        printf("!!!!!!!\n");
//        if (child_id == 0) {
//            display_graph2(G, max_id);
//        }
//        printf("index is %i the child id is %i\n", j, child_id);
        int in = tagged(sign, node_count, child_id, max_id);
        if (in == 1) {
            check_child(G, node_count, child_id, sign, max_id);
        }
    }
}
Beispiel #5
0
  unsigned long StatSample::add(cafe::Event* event, const std::string& name) {
    if (!event) {
      cerr << "StatSample ERROR!. Event pointer == 0." << endl ;
      return 0;
    }    

    if (!tagged(event)) return 0 ;

    vector<StatWeight*>::const_iterator it = _events.begin();
    for (; it != _events.end(); it++) if ((*it)->name() == name ) break ;

    if (it == _events.end()) {
      _events.push_back(new StatWeight(name, true)) ;  
      it = _events.end()-1 ;
    }

    (*it) ->applyWeight(_weight->weight(), _weight->weight_pos(), _weight->weight_neg()) ;
    return (*it)->nevents() ;
  }
Beispiel #6
0
/* main, menu */
void mydelete (void) {
	char buf [80];
	register struct file *p;
	register c;

	if (c = tagged ()) {
		/* delete group of files */

		sprintf (buf, "You have selected %d file%s.", c, c>1 ? "s" : "");
		if (getchoice (0, " Delete ", buf, NULL, " Delete ", " Cancel ", NULL))
			return;
		sprintf (buf, "You are DELETING %d selected file%s from", c, c>1 ? "s" : "");
		if (getchoice (1, " Delete ", buf, cur->d.cwd, " Ok ", " Cancel ", NULL))
			return;
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag && unlink (p->name) < 0)
				error ("Cannot delete %s", p->name);
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* delete directory */

		if (getchoice (0, " Delete ", "Do you wish to delete directory",
		    p->name, " Delete ", " Cancel ", NULL))
			return;
		if (runl(1, "/bin/rmdir", "rmdir", p->name, NULL)) {
			error ("Cannot delete directory %s", p->name);
			return;
		}
	} else if (c == S_IFREG) {
		/* delete regular file */

		if (getchoice (0, " Delete ", "Do you wish to delete",
		    p->name, " Delete ", " Cancel ", NULL))
			return;
		if (unlink (p->name) < 0) {
			error ("Cannot delete %s", p->name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}
Beispiel #7
0
int is_graph_connected(struct Node* G, int node_count, struct Node** id2Node, int max_node_id){
//    printf("in connecttion");
//    display_graph2(id2Node, max_node_id + 1);
//    exit(2);
    int* sign = (int *)malloc(sizeof(int) * (max_node_id + 1));
    for (int i = 0; i < max_node_id + 1; i++) {
        sign[i] = 0;
    }
    // start with a certain node, if all node visited, so that the graph is connected
    int start_id = G[0].node_id;
    tagged((int *)sign, node_count, start_id, max_node_id);
//    display_graph2(id2Node, max_node_id + 1);
    check_child(id2Node, node_count, start_id, sign, max_node_id);
    for (int i = 0; i < node_count; i ++) {
        if (sign[G[i].node_id] == 0) {
            free(sign);
            return 0;
        }
    }
    free(sign);
    return 1;
}
Beispiel #8
0
  double StatSample::applyWeight(cafe::Event* event, const std::string& name, 
				 double weight, double weight_pos, double weight_neg) {    
    if (!event) {
      cerr << "StatSample ERROR!. Event pointer == 0." << endl ;
      return 0;
    }    

    if (!tagged(event)) return 0.0 ;

    vector<StatWeight*>::const_iterator it = _events.begin();
    for (; it != _events.end(); it++) if ((*it)->name() == name ) break ;

    if (it == _events.end()) {
      _events.push_back(new StatWeight(name)) ;
      it = _events.end()-1 ;
    }

    // update global weight
    _weight->applyWeight(weight, weight_pos, weight_neg) ;

    // update specified weight
    return (*it) ->applyWeight(weight, weight_pos, weight_neg) ;
  }
Beispiel #9
0
/* main, menu */
void renmove (void) {
	char buf [MAXPATHLEN+20];
	char *name;
	register struct file *p;
	register c;
	int done, all, ch;
	int exd, exf;

	if (c = tagged ()) {
		/* move group of files */

		sprintf (buf, "Rename or move %d file%s to", c, c>1 ? "s" : "");
		if (! (name = getstring (60, (cur==left?right:left)->cwd,
		    " Rename ", buf)))
			return;
		runset (name);
		exd = exist (name);
		all = 0;
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag) {
				sprintf (buf, "%s/%s", name, p->name);
				exf = exd=='d' ? exist (buf) : 0;
				if (exd=='f' || exf=='f') {
					if (! all) {
						ch = getchoice (1, " Rename ", "File exists",
							exf=='f' ? buf : name,
							" Overwrite ", " All ", " Cancel ");
						switch (ch) {
						default:
						case 2:         /* cancel */
							continue;
						case 1:         /* all */
							all = 1;
						}
					}
				} else if (exf == 'd') {
					error ("%s is a directory", buf);
					continue;
				}
				runarg (p->name);
			}
		message (" Move ", "Moving %d file%s to %s ...", c, c>1 ? "s" : "", name);
		done = rundone ("/bin/mv", "mv");
		if (done) {
			endmesg ();
			message (" Move ", "Done");
		} else
			error ("Error while moving %d file%s to %s",
				c, c>1 ? "s" : "", name);
		endmesg ();
		name = 0;
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* rename directory */

		sprintf (buf, "Rename \"%s\" to", strtail (p->name, '/', 60));
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Rename ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("Directory %s exists", buf);
			return;
		}
		if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) {
			error ("Cannot move %s to %s", p->name, name);
			return;
		}
	} else if (c == S_IFREG) {
		/* move regular file */

		sprintf (buf, "Rename or move \"%s\" to", p->name);
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Rename ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("%s is a directory", buf);
			return;
		}
		if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) {
			error ("Cannot move %s to %s", p->name, name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
	if (name)
		findfile (cur, name);
}
Beispiel #10
0
/* menu */
void makeslink (void) {
	char buf [80];
	char *name;
	register struct file *p;
	register c;
	int done;
	int exd, exf;

	if (c = tagged ()) {
		/* symlink group of files */

		sprintf (buf, "Symlink %d file%s to", c, c>1 ? "s" : "");
		if (! (name = getstring (60, (cur==left?right:left)->cwd,
		    " Symlink ", buf)))
			return;
		runset (name);
		exd = exist (name);
		for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p)
			if (p->tag) {
				sprintf (buf, "%s/%s", name, p->name);
				exf = exd=='d' ? exist (buf) : 0;
				if (exd=='f' || exf=='f') {
					if (getchoice (1, " Symlink ", "File exists",
					    exf=='f' ? buf : name,
					    " Overwrite ", " Cancel ", NULL))
						continue;
				} else if (exf == 'd') {
					error ("%s is a directory", buf);
					continue;
				}
				runarg (p->name);
				p->tag = 0;
			}
		runarg ("-s");
		message (" Symlink ", "Linking %d file%s to %s ...", c, c>1 ? "s" : "", name);
		done = rundone ("/bin/ln", "ln");
		if (done) {
			endmesg ();
			message (" Symlink ", "Done");
		} else
			error ("Error while linking %d file%s to %s",
				c, c>1 ? "s" : "", name);
		endmesg ();
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* symlinking directory */
	} else if (c == S_IFREG) {
		/* symlink regular file */

		sprintf (buf, "Symlink \"%s\" to", p->name);
		if (! (name = getstring (60, (cur==left?right:left)->cwd, " Symlink ", buf)))
			return;
		exd = exist (name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Symlink ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("%s is a directory", buf);
			return;
		}
		if (runl(1, "/bin/ln", "ln", "-s", p->name, name, NULL)) {
			error ("Cannot symlink %s to %s", p->name, name);
			return;
		}
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}
Beispiel #11
0
/* main, menu */
void copy (void) {
	char buf [80];
	char *name;
	register struct file *p;
	register c;
	int done, all, ch;
	int exd, exf;

	if (c = tagged ()) {
		/* copy group of files */

		sprintf (buf, "Copy %d file%s to", c, c>1 ? "s" : "");
		if (! (name = getstring (60, (cur==left?right:left)->d.cwd,
		    " Copy ", buf)))
			return;
#if 0
		runset (name);
		exd = exist (name);
		all = 0;
		for (p = cur->d.cat; p < cur->d.cat + cur->d.num; ++p)
			if (p->tag) {
				sprintf (buf, "%s/%s", name, p->name);
				exf = exd=='d' ? exist (buf) : 0;
				if (exd=='f' || exf=='f') {
					if (! all) {
						ch = getchoice (1, " Copy ", "File exists",
							exf=='f' ? buf : name,
							" Overwrite ", " All ", " Cancel ");
						switch (ch) {
						case 2:         /* cancel */
							--c;
							continue;
						case 1:         /* all */
							all = 1;
						case 0:         /* all */
							break;
						default:
							runcancel ();
							return;
						}
					}
				} else if (exf == 'd') {
					error ("%s is a directory", buf);
					continue;
				}
				runarg (p->name);
				p->tag = 0;
			}
		if (c <= 0) {
			runcancel ();
			return;
		}
		message (" Copy ", "Copying %d file%s to %s ...", c, c>1 ? "s" : "", name);
		done = rundone ("/bin/cp", "cp");
		if (done) {
			endmesg ();
			message (" Copy ", "Done");
		} else
			error ("Error while copying %d file%s to %s",
				c, c>1 ? "s" : "", name);
		endmesg ();
#endif
	} else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) {
		/* copying directory */
	} else if (c == S_IFREG) {
		/* copy regular file */

		sprintf (buf, "Copy \"%s\" to", p->name);
		if (! (name = getstring (60, (cur==left?right:left)->d.cwd, " Copy ", buf)))
			return;
		exd = exist (cur==left?right:left, name);
		sprintf (buf, "%s/%s", name, p->name);
		exf = exd=='d' ? exist (cur==left?right:left, buf) : 0;
		if (exd=='f' || exf=='f') {
			if (getchoice (1, " Copy ", "File exists",
			    exf=='f' ? buf : name,
			    " Overwrite ", " Cancel ", NULL))
				return;
		} else if (exf == 'd') {
			error ("%s is a directory", buf);
			return;
		}
		/* copying */
		ReadWrite rf;
		strncpy(rf.from, cur->d.cwd, sizeof(rf.from));
		strncat(rf.from, "/", sizeof(rf.from));
		strncat(rf.from, p->name, sizeof(rf.from));
		strncpy(rf.to, buf, sizeof(rf.to));
		rfiles.AddReadFile(&rf);
	}
	setdir (cur == left ? right : left, NULL);
	setdir (cur, NULL);
}
Beispiel #12
0
rev_list *
rev_list_merge (rev_list *head)
{
    int		count = rev_list_count (head);
    rev_list	*rl;
    rev_list	*l;
    rev_ref	*lh, *h;
    Tag		*t;
    rev_ref	**refs;
    int		nref;

    ALLOC((rl = calloc (1, sizeof (rev_list))), "rev_list_merge");
    ALLOC((refs = calloc (count, sizeof (rev_ref *))), "rev_list_merge");
    /*
     * Find all of the heads across all of the incoming trees
     * Yes, this is currently very inefficient
     */
    for (l = head; l; l = l->next) {
	for (lh = l->heads; lh; lh = lh->next) {
	    h = rev_find_head (rl, lh->name);
	    if (!h)
		rev_list_add_head (rl, NULL, lh->name, lh->degree);
	    else if (lh->degree > h->degree)
		h->degree = lh->degree;
	}
    }
    /*
     * Sort by degree so that finding branch points always works
     */
//    rl->heads = rev_ref_sel_sort (rl->heads);
    rl->heads = rev_ref_tsort (rl->heads, head);
    if (!rl->heads)
	return NULL;
//    for (h = rl->heads; h; h = h->next)
//	fprintf (stderr, "head %s (%d)\n",
//		 h->name, h->degree);
    /*
     * Find branch parent relationships
     */
    for (h = rl->heads; h; h = h->next) {
	rev_ref_set_parent (rl, h, head);
//	dump_ref_name (stderr, h);
//	fprintf (stderr, "\n");
    }
    /*
     * Merge common branches
     */
    for (h = rl->heads; h; h = h->next) {
	/*
	 * Locate branch in every tree
	 */
	nref = 0;
	for (l = head; l; l = l->next) {
	    lh = rev_find_head (l, h->name);
	    if (lh)
		refs[nref++] = lh;
	}
	if (nref)
	    rev_branch_merge (refs, nref, h, rl);
    }
    /*
     * Compute 'tail' values
     */
    rev_list_set_tail (rl);

    free(refs);
    /*
     * Find tag locations
     */
    for (t = all_tags; t; t = t->next) {
	rev_commit **commits = tagged(t);
	if (commits)
	    rev_tag_search(t, commits, rl);
	else
	    fprintf (stderr, "lost tag %s\n", t->name);
	free(commits);
    }
    rev_list_validate (rl);
    return rl;
}