Пример #1
0
    int ServerListItem::compare(QListViewItem *i, int col, bool ascending) const
    {
        ServerListItem* item = static_cast<ServerListItem*>(i);

        if (col==0)
        {
            if (!item->server().host().isEmpty())
            {
                if (sortIndex() == item->sortIndex())
                    return 0;
                else if (sortIndex() < item->sortIndex())
                    return ascending ? -1 : 1;
                else
                    return ascending ? 1 : -1;
            }

            if (sortIndex() == item->sortIndex())
                return 0;
            else if (sortIndex() < item->sortIndex())
                return -1;
            else
                return 1;
        }

        return key( col, ascending ).localeAwareCompare( i->key( col, ascending ) );
    }
Пример #2
0
void test_common() {

	if (1) {
		//test angle macros in common.h
		Real a=181;
		Real b=-181;
		Real c=b-360;
		std::cout << "DIFFDEG(" << a << "," << b << ") = " << DIFFDEG(a,b) << std::endl;
		std::cout << "DIFFDEG(" << a << "," << c << ") = " << DIFFDEG(a,c) << std::endl;
		std::cout << "WRAPDEG(" << c << "," << 180 << ") = " << WRAPDEG(c,180) << std::endl;
		std::cout << std::endl;
	}

	if (1) {
		//test sortIndex()

		const int SIZE = 5;
		Real val[SIZE] = {-1.5, 0, 2.5, -2.5, 1.5};
		int idx[SIZE];
		Real val_sort[SIZE];

		sortIndex(SIZE, val, idx, val_sort);

		std::cout << "val=\n"; printMatReal(1,SIZE,val,-1,-1);
		std::cout << "idx=\n"; printMatInt(1,SIZE,idx,-1);
		std::cout << "val_sort=\n"; printMatReal(1,SIZE,val_sort,-1,-1);
	}

}