コード例 #1
0
    WeatherInfo(QWidget *parent = 0): QMainWindow(parent) {

        m_view = new QGraphicsView(this);
        setCentralWidget(m_view);

        setupScene();
        m_view->setScene(&m_scene);
        m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

        m_view->setFrameShape(QFrame::NoFrame);
        setWindowTitle("Weather Info");

        QStringList cities;
        cities << "Oslo";
        cities << "Berlin";
        cities << "Brisbane";
        cities << "Helsinki";
        cities << "San Diego";
        for (int i = 0; i < cities.count(); ++i) {
            QAction *action = new QAction(cities[i], this);
            connect(action, SIGNAL(triggered()), SLOT(chooseCity()));
            addAction(action);
#if defined(Q_OS_SYMBIAN)
            menuBar()->addAction(action);
#endif
        }
        setContextMenuPolicy(Qt::ActionsContextMenu);

        connect(&m_manager, SIGNAL(finished(QNetworkReply*)),
                this, SLOT(handleNetworkData(QNetworkReply*)));

        QTimer::singleShot(0, this, SLOT(delayedInit()));
    }
コード例 #2
0
ファイル: Ant.cpp プロジェクト: biaoyi/Ant-Clony-Algorithm
void Ant::move()
{
    int select = chooseCity();
    travel[num_city] = select;
    allowed[select] = 0;
    num_city++;
    cur_city = select;
}
コード例 #3
0
ファイル: geoloc.cpp プロジェクト: DimondTheCat/xray
BOOL LocationDialog::loadCityList(HWND hDlg)
// Update the list of cities.
{
    CityList::Entry* cl;
    UINT numCities = cityList.Count();    
    HWND h = GetDlgItem(hDlg, IDC_CITYLIST);
    int index;

    // Empty the list box and add only those cities in the current map.
    SendMessage(h, LB_RESETCONTENT, 0, 0);
    for (UINT i=0; i<numCities; i++) {
        cl = &cityList[i];
        if ((double)cl->latitude > minLatitude && 
            (double)cl->latitude < maxLatitude &&
            (double)cl->longitude < -minLongitude && /* signs are */
            (double)cl->longitude > -maxLongitude) { /* reversed  */

            if (cl->name[0] == '+') {
                isBig[i] = TRUE;
                index = SendMessage(h, LB_ADDSTRING, 0, (LPARAM)(cl->name+1));
            } else {
                isBig[i] = FALSE;                
                index = SendMessage(h, LB_ADDSTRING, 0, (LPARAM)(cl->name));
            }

            // Store city list index in item data.
            SendMessage(h, LB_SETITEMDATA, index, (LPARAM)i);
            
//            if (fabs(cl->latitude-updatedLatitude) < .01 &&
//                fabs(cl->longitude-updatedLongitude) < .01)
        }
    }

	if (lastCity < 0) {
		// Select first city.
		//SendMessage(h, LB_SETCURSEL, (WPARAM)0, 0);    
		//chooseCity(hDlg, 0);
	} else {
		// Select first city.
		SendMessage(h, LB_SETCURSEL, (WPARAM)lastCity, 0);    
		chooseCity(hDlg, lastCity);
	}

    return TRUE;
}