Ejemplo n.º 1
0
static char *prepare_line(struct wdgt *w, struct process *p)
{
	char *tree, state = p->proc->state;
	int offset = 0;
	if (!p) return 0;
	tree = tree_string(tree_root, p->proc);
	if(state == 'S') state = ' ';
	if (show_linenr) 
		offset = snprintf(w->mwin->gbuf, w->mwin->gbsize, "\x6%4d ", p->line + 1);
	if (offset < 0) return "";
	if(show_owner) 
		snprintf(w->mwin->gbuf+offset, w->mwin->gbsize-offset ,"\x3%5d %c%c \x3%-8s \x2%s \x3%s", 
			p->proc->pid, get_state_color(state), 
			state, get_owner_name(proc_pid_uid(p->proc->pid)), tree, 
			get_cmdline(p->proc->pid));
	 else 
		snprintf(w->mwin->gbuf+offset, w->mwin->gbsize-offset,"\x3%5d %c%c \x2%s \x3%s",
			p->proc->pid, get_state_color(state), 
			state, tree, get_cmdline(p->proc->pid));
		
	return w->mwin->gbuf;
}
Ejemplo n.º 2
0
QStandardItem *FlagColumn::build_cell(Dwarf *d) {
    QStandardItem *item = init_cell(d);

    item->setData(CT_FLAGS, DwarfModel::DR_COL_TYPE);
    item->setData(0,DwarfModel::DR_STATE); //default

    QString info_msg = "";
    QString info_col_name = "";

    short rating = 0;
    if(d->get_flag_value(m_bit_pos))
        rating = 1;
    //check to fix butchering pets. currently this will cause the butchered parts to still be recognized as a pet
    //and they'll put them into a burial recepticle, but won't use them as a food source
    ViewColumn::CELL_STATE state  = STATE_TOGGLE;
    if(m_bit_pos == FLAG_BUTCHER){
        if(d->is_pet()){
            info_msg = tr("<b>Pets cannot be slaughtered!</b>");
            state = STATE_DISABLED;
        }else if(!d->get_caste() || !d->get_caste()->flags().has_flag(BUTCHERABLE)){
            info_msg = tr("<b>This caste cannot be slaughtered!</b>");
            state = STATE_DISABLED;
        }else if(rating == 1){
            info_msg = tr("<b>This creature has been marked for slaughter.</b>");
            state = STATE_PENDING;
        }else if(d->trained_level() >= Dwarf::unknown_trained){
            info_msg = tr("<b>Captured wild animals cannot be butchered!</b>");
            state = STATE_DISABLED;
        }else{
            state = STATE_TOGGLE;
        }
    }else if(m_bit_pos == FLAG_GELD){
        if(d->get_gender() != Dwarf::SEX_M){
            info_msg = tr("<b>Only males can be gelded!</b>");
            state = STATE_DISABLED;
        }else if(d->has_health_issue(eHealth::HI_GELDED,0)){
            info_msg = tr("<b>This creature has already been gelded!</b>");
            state = STATE_ACTIVE;
        }else if(rating == 1){
            info_msg = tr("<b>This creature has been marked for gelding.</b>");
            state = STATE_PENDING;
        }else if(!d->get_caste()->is_geldable()){ //check last as it's the most expensive
            info_msg = tr("<b>This caste is not geldable!</b>");
            state = STATE_DISABLED;
        }else{
            state = STATE_TOGGLE;
        }
    }

    item->setData(state,DwarfModel::DR_STATE);
    info_col_name = get_state_color(state).name();//item->data(Qt::BackgroundColorRole).value<QColor>().name();

    item->setData(rating, DwarfModel::DR_SORT_VALUE);
    item->setData(m_bit_pos, DwarfModel::DR_OTHER_ID);
    item->setData(m_set->name(), DwarfModel::DR_SET_NAME);

    QString tooltip = QString("<center><h3>%1</h3>%2</center>%3")
            .arg(m_title)
            .arg(QString("<font color=%1>%2</font>").arg(info_col_name).arg(info_msg))
            .arg(tooltip_name_footer(d));
    item->setToolTip(tooltip);

    return item;
}