Exemplo n.º 1
0
void StopItemView::setDepartureTimes(ArrivalAndDepartureList departureList, Stop stop)
{
	this->departureList = departureList;
	this->stop = stop;
	ListView * departuresListView = view->findChild<ListView*>("departuresListView");
	ArrayDataModel * departuresListModel = view->findChild<ArrayDataModel*>("departuresListModel");
	departuresListModel->clear();

	foreach(ArrivalAndDeparture current, departureList)
	{
		QVariantMap departure = current.ToVariantMap();
		qDebug() << "Adding " << departure["routeShortName"].toString();
		departuresListModel->append(departure);
	}
Exemplo n.º 2
0
void StopsView::PopulateResults(StopList stopList)
{
	this->stopList = stopList;
	ListView * stopsListView = view->findChild<ListView*>("stopsListView");
	ArrayDataModel * stopsListModel = view->findChild<ArrayDataModel*>("stopsListModel");
	stopsListModel->clear();

	//TODO: implement a way to request results be cleared separately (possibly from the Search bar)

	foreach(Stop current, stopList)
	{
		QVariantMap stop = current.ToVariantMap();
		qDebug() << "Adding " << stop["name"].toString();
		stopsListModel->append(stop);
	}
Exemplo n.º 3
0
QVariantList Database::getLatestChatModel(QString type)
{
    QString q;
    ArrayDataModel *model = new ArrayDataModel();
    if(type.isEmpty())
    {
       q = "select * from contacts order by messagetime desc";
    }
    else
    {
        q = "select * from contacts where type = \"";
        q.append(type);
       q.append("\" order by messagetime desc");
    }
    QVariant list = sqlda->execute(q);

    model->clear();
    model->insert(0,list.value<QVariantList>());
    return list.value<QVariantList>();
}
Exemplo n.º 4
0
void controller::onFinished()
{

	m_succeeded = true;

	m_model->clear();
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
	ArrayDataModel *model = new ArrayDataModel();

	QString response;
	if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200)
	{
		    JsonDataAccess jda;
	        QVariantMap map = jda.loadFromBuffer(reply->readAll()).toMap();

	        QVariantList addresses = map["RegistrationResult"].toList();
	        qDebug() << "RegistrationResult is " << map["RegistrationResult"].toString();
	        m_temperature = map["RegistrationResult"].toString();
	        m_temperature=m_temperature.section(':', 0, 0);

	        qDebug() << " New RegistrationResult is " <<m_temperature;
	        qDebug() <<map["RegistrationResult"].toString();


	        emit temperatureChanged();

	        QString result;
	        QString empid;
	        QString empid_no;
	        QString companyname;
	        QString::SectionFlag flag = QString::SectionSkipEmpty;

	        empid=m_temperature.section(':', 1, 1);
	        qDebug()<<m_temperature.section(':', 1, 1)<<"  =  "<<m_temperature.section(':', 2, 2);

	        m_description=m_temperature.section(':', 4, 4);
	        emit descriptionChanged();

	        model->append(addresses);
	        ListView *listView = m_root->findChild<ListView*>("listView");
	       	        listView->setDataModel(model);

	        // list: ["12", "14", "99", "231", "7"]
/*	        foreach(QVariant var, addresses) {
	            QVariantMap addressMap = var.toMap();

	            //qDebug() << "RegistrationResult is " << addressMap["RegistrationResult"].toString();
	            qDebug() << "CategoryID is " << addressMap["CategoryID"].toString();
	            qDebug() << "CategoryID is " << addressMap["ThumnailImage"].toUrl();

	            //m_temperature = addressMap["CategoryName"].toString();
	            emit temperatureChanged();
	            m_description = addressMap["CategoryID"].toString();
	            emit descriptionChanged();

	            //m_model->insert(addressMap);

	            model->append(addressMap);

	           // m_model->insertList(addresses.value<QVariantList>());
	        }
	        ListView *listView = m_root->findChild<ListView*>("listView");
	        listView->setDataModel(model);												*/
	    }
	    else {
	        qDebug() << "Server returned code " << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
	    }

		emit statusChanged();

	    m_active = false;
	    	emit activeChanged();
	}