Exemple #1
0
/* control multiple files */
int
main(int argc, char *argv[])
{
	int ch;

#ifdef TIMING
	struct timeval t1, t2;

	(void)gettimeofday(&t1, NULL);
#endif

	prgname = argv[0];

	while ((ch = getopt(argc, argv, "OT:VW:X:Z:f:gkm:psvwx:")) != -1) {
		switch (ch) {
#if !defined(MULTIPASS) || defined(PASS1)
		case 'X':	/* pass1 debugging */
			while (*optarg)
				switch (*optarg++) {
				case 'b': ++bdebug; break; /* buildtree */
				case 'd': ++ddebug; break; /* declarations */
				case 'e': ++edebug; break; /* pass1 exit */
				case 'i': ++idebug; break; /* initializations */
				case 'n': ++ndebug; break; /* node allocation */
				case 'o': ++odebug; break; /* optim */
				case 'p': ++pdebug; break; /* prototype */
				case 's': ++sdebug; break; /* inline */
				case 't': ++tdebug; break; /* type match */
				case 'x': ++xdebug; break; /* MD code */
				default:
					fprintf(stderr, "unknown -X flag '%c'\n",
					    optarg[-1]);
					exit(1);
				}
			break;
#endif
#if !defined(MULTIPASS) || defined(PASS2)
		case 'Z':	/* pass2 debugging */
			while (*optarg)
				switch (*optarg++) {
				case 'b': /* basic block and SSA building */
					++b2debug;
					break;
				case 'c': /* code printout */
					++c2debug;
					break;
				case 'e': /* print tree upon pass2 enter */
					++e2debug;
					break;
				case 'f': /* instruction matching */
					++f2debug;
					break;
				case 'g': /* print flow graphs */
					++g2debug;
					break;
				case 'n': /* node allocation */
					++ndebug;
					break;
				case 'o': /* instruction generator */
					++o2debug;
					break;
				case 'r': /* register alloc/graph coloring */
					++r2debug;
					break;
				case 's': /* shape matching */
					++s2debug;
					break;
				case 't': /* type matching */
					++t2debug;
					break;
				case 'u': /* Sethi-Ullman debugging */
					++u2debug;
					break;
				case 'x': /* target specific */
					++x2debug;
					break;
				default:
					fprintf(stderr, "unknown -Z flag '%c'\n",
					    optarg[-1]);
					exit(1);
				}
			break;
#endif
		case 'f': /* Language */
			fflags(optarg);
			break;

		case 'g': /* Debugging */
			++gflag;
			break;

		case 'k': /* PIC code */
			++kflag;
			break;

		case 'm': /* Target-specific */
			mflags(optarg);
			break;

		case 'p': /* Profiling */
			++pflag;
			break;

		case 's': /* Statistics */
			++sflag;
			break;

		case 'W': /* Enable different warnings */
			Wflags(optarg);
			break;

		case 'x': /* Different settings */
			xopt(optarg);
			break;

		case 'v':
			printf("ccom: %s\n", VERSSTR);
			break;

		case '?':
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	if (argc > 0 && strcmp(argv[0], "-") != 0) {
		if (freopen(argv[0], "r", stdin) == NULL) {
			fprintf(stderr, "open input file '%s':",
			    argv[0]);
			perror(NULL);
			exit(1);
		}
	}
	if (argc > 1 && strcmp(argv[1], "-") != 0) {
		if (freopen(argv[1], "w", stdout) == NULL) {
			fprintf(stderr, "open output file '%s':",
			    argv[1]);
			perror(NULL);
			exit(1);
		}
	}

	mkdope();
	signal(SIGSEGV, segvcatch);
#ifdef SIGBUS
	signal(SIGBUS, segvcatch);
#endif
	fregs = FREGS;	/* number of free registers */
	lineno = 1;
#ifdef GCC_COMPAT
	gcc_init();
#endif

	/* starts past any of the above */
	reached = 1;

	bjobcode();
#ifndef TARGET_VALIST
	{
		NODE *p = block(NAME, NIL, NIL, PTR|CHAR, NULL, 0);
		struct symtab *sp = lookup(addname("__builtin_va_list"), 0);
		p->n_sp = sp;
		defid(p, TYPEDEF);
		nfree(p);
	}
#endif
	complinit();

#ifdef STABS
	if (gflag) {
		stabs_file(argc ? argv[0] : "");
		stabs_init();
	}
#endif

	if (sspflag)
		sspinit();

	(void) yyparse();
	yyaccpt();

	if (!nerrors)
		lcommprint();

#ifdef STABS
	if (gflag)
		stabs_efile(argc ? argv[0] : "");
#endif

	ejobcode( nerrors ? 1 : 0 );

#ifdef TIMING
	(void)gettimeofday(&t2, NULL);
	t2.tv_sec -= t1.tv_sec;
	t2.tv_usec -= t1.tv_usec;
	if (t2.tv_usec < 0) {
		t2.tv_usec += 1000000;
		t2.tv_sec -= 1;
	}
	fprintf(stderr, "ccom total time: %ld s %ld us\n",
	    t2.tv_sec, t2.tv_usec);
#endif

	if (sflag)
		prtstats();

	return(nerrors?1:0);
}
void HHeaderItemDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
    int row = index.row();
    int col = index.column();

    const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
    
    QRect smallRect;

    //判断是否有checkbox
    if (HHeaderView::m_Instance->isCheckedEnable(row, col))
    {
        smallRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,
                                        QSize(option.fontMetrics.width(index.data(Qt::DisplayRole).toString()) + 25, option.fontMetrics.height() + 3),
                                        option.rect);
    }
    else
    {
        smallRect = QStyle::alignedRect(option.direction, Qt::AlignCenter,
                                        QSize(option.fontMetrics.width(index.data(Qt::DisplayRole).toString()) + 8, option.fontMetrics.height() + 3),
                                        option.rect);
    }
    
    QStyleOptionHeader header_opt;
    header_opt.rect = option.rect;
    header_opt.position = QStyleOptionHeader::Middle;
    header_opt.textAlignment = Qt::AlignCenter;

    header_opt.state = option.state;
    //header_opt.state |= QStyle::State_HasFocus;//QStyle::State_Enabled | QStyle::State_Horizontal | QStyle::State_None | QStyle::State_Raised;

    //判断是否能够排序  
    if (HHeaderView::m_Instance->isSortedEnable(row, col))
    {//可以排序
        //获取它当前的排序顺序
        int ret = HHeaderView::m_Instance->sortedDirection(row, col);
        if (0 == ret)
        {
            header_opt.sortIndicator = QStyleOptionHeader::SortUp;
        }
        else if (1 == ret)
        {
            header_opt.sortIndicator = QStyleOptionHeader::SortDown;
        }
        else
        {
            header_opt.sortIndicator = QStyleOptionHeader::None;
        }    
    }
    
    if (HHeaderView::m_Instance->isItemPress(row, col))
    {
        header_opt.state |= QStyle::State_Sunken; //按钮按下效果
    }

   // if ((QApplication::mouseButtons() && (Qt::LeftButton || Qt::RightButton)))
   //             header_opt.state |= QStyle::State_Sunken;

    painter->save();
    QApplication::style()->drawControl(QStyle::CE_Header, &header_opt, painter);
    painter->restore();

    painter->setPen(QColor(255,0,0));

    QStyleOptionViewItemV4 xopt(option);

    xopt.state &= ~QStyle::State_MouseOver;

    if (HHeaderView::m_Instance->isCheckedEnable(row, col))
    {//判断是该单元格是否有checkbox
        xopt.features |= QStyleOptionViewItemV4::HasCheckIndicator;

        //判断checkbox的状态
        Qt::CheckState state = HHeaderView::m_Instance->checkedState(row, col);
        if (Qt::Unchecked == state)
        {
            xopt.state |= QStyle::State_Off;
        }
        else if (Qt::PartiallyChecked == state)
        {
            xopt.state |= QStyle::State_NoChange;
        }
        else if (Qt::Checked == state)
        {
            xopt.state |= QStyle::State_On;
        }
    }  

    xopt.rect = smallRect;
   // xopt.rect = option.rect;
    //xopt.rect.setLeft(xopt.rect.left() + 10);
    //xopt.rect.setRight(xopt.rect.right() - 10);

    if (!HHeaderView::m_Instance->isColHide(col))
    {
        QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &xopt, painter);

         //首先要判断是否处于hover状态
        if (header_opt.state & QStyle::State_MouseOver)
        {
            //判断是否能够排序,如果能排序,则显示图标
            if (HHeaderView::m_Instance->isCustomMenuEnable(row, col))
            {
                drawMenuBtn(row, col, option.rect, painter);      
            }    
        }

         //判断前面1列是否隐藏,如果隐藏了,需要在左边画上三角符号
        if (HHeaderView::m_Instance->isSectionHidden(col - 1))
        {
            drawPreBtn(option.rect, painter);
        }

        //判断后面1列是否隐藏,如果隐藏了,需要在右边画上三角符号
        if (HHeaderView::m_Instance->isSectionHidden(col + 1))
        {
            drawNextBtn(option.rect, painter);
        }
    }  
}