本文整理汇总了C++中GroupDataModel类的典型用法代码示例。如果您正苦于以下问题:C++ GroupDataModel类的具体用法?C++ GroupDataModel怎么用?C++ GroupDataModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupDataModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QObject
ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
app->setScene(root);
{
// load JSON data from file to QVariant
bb::data::JsonDataAccess jda;
QVariantList lst = jda.load("app/native/assets/mydata.json").toList();
if (jda.hasError()) {
bb::data::DataAccessError error = jda.error();
qDebug() << "JSON loading error: " << error.errorType() << ": " << error.errorMessage();
}
else {
qDebug() << "JSON data loaded OK!";
GroupDataModel *m = new GroupDataModel();
// insert the JSON data to model
m->insertList(lst);
// make the model flat
m->setGrouping(ItemGrouping::None);
// find cascades component of type ListView with an objectName property set to the value 'listView'
// usable if one do not want to expose GroupDataModel to QML (qmlRegisterType<GroupDataModel>("com.example", 1, 0, "MyListModel");)
ListView *list_view = root->findChild<ListView*>("listView");
// assign data model object (m) to its GUI representation object (list_view)
if(list_view) list_view->setDataModel(m);
}
}
}
示例2: GroupDataModel
GroupDataModel * Database::getQueryModel(QString query)
{
GroupDataModel *model = new GroupDataModel(QStringList());
QVariant data = sqlda->execute(query);
model->insertList(data.value<QVariantList>());
return model;
}
示例3: sendMessage
void MainScreen::sendMessage(Peer* peer, const QString& message)
{
QByteArray bytes = message.toUtf8();
if (peer->type() == TGL_BROADCAST_CHAT)
{
BroadcastChat* chat = (BroadcastChat*)peer;
GroupDataModel* members = (GroupDataModel*)chat->members();
tgl_peer_id_t* peers = new tgl_peer_id_t[members->size()];
int idx = 0;
for (QVariantList indexPath = members->first(); !indexPath.isEmpty(); indexPath = members->after(indexPath))
{
User* user = (User*)members->data(indexPath).value<QObject*>();
peers[idx].type = user->type();
peers[idx].id = user->id();
idx++;
}
tgl_do_send_broadcast(gTLS, members->size(), peers, bytes.data(), bytes.length(), Storage::_broadcastSended, chat);
delete[] peers;
}
else
tgl_do_send_message(gTLS, {peer->type(), peer->id()}, (const char*)bytes.data(), bytes.length(), 0, 0);
}
示例4: qDebug
void Auction::requestFinished(QNetworkReply* reply)
{
qDebug() << "\n Got Auctions";
// Check the network reply for errors
if (reply->error() == QNetworkReply::NoError) {
mListView = root->findChild<ListView*>("auctionView");
QString xmldata = QString(reply->readAll());
qDebug() << "\n "+xmldata;
GroupDataModel *model = new GroupDataModel(QStringList() << "albumid");
// Specify the type of grouping to use for the headers in the list
model->setGrouping(ItemGrouping::None);
XmlDataAccess xda;
QVariant list = xda.loadFromBuffer(xmldata, "/cardcategories/album");
QVariantMap tempMap = list.value<QVariantMap>();
QVariantList tempList;
if (tempMap.isEmpty()) {
tempList = list.value<QVariantList>();
}
else {
tempList.append(tempMap);
}
model->insertList(tempList);
mListView->setDataModel(model);
}
else
{
qDebug() << "\n Problem with the network";
qDebug() << "\n" << reply->errorString();
}
mActivityIndicator->stop();
}
示例5: qWarning
void SmileyPickerController::pushToView(Emoticon *e) {
if(e == NULL)
return;
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (!dataModel) {
qDebug() << "create new model";
dataModel = new GroupDataModel(
QStringList() << "tag"
<< "localUrl"
);
m_ListView->setDataModel(dataModel);
}
// ----------------------------------------------------------------------------------------------
// push data to the view
dataModel->insert(e);
}
示例6: qWarning
void BalanceController::getWeightsList() {
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (dataModel) {
dataModel->clear();
} else {
qWarning() << "no group data model!";
return;
}
QList<QObject*> datas;
QList< BodyWeight* > bodyweights = Database::get()->getBodyWeights();
for(int i = 0 ; i < bodyweights.size() ; ++i) {
datas.push_back(bodyweights[i]);
}
dataModel->insertList(datas);
emit completed();
}
示例7: addChatMessageToListModel
static void addChatMessageToListModel(void *item, void *user_data)
{
GroupDataModel *model = (GroupDataModel *)user_data;
LinphoneChatMessage *message = (LinphoneChatMessage *)item;
QVariantMap entry;
entry = fillEntryWithMessageValues(entry, message);
model->insert(entry);
}
示例8: GroupDataModel
void RocknRoll::parseJSON() {
GroupDataModel *model = new GroupDataModel(QStringList() << "artist" << "song" << "genre" << "year");
JsonDataAccess jda;
QVariant list = jda.load("dummy.json");
model->insertList(list.value<QVariantList>());
ListView *listView = new ListView();
listView->setDataModel(model);
}
示例9: qWarning
void DriveController::onImageReady(const QString &url, const QString &diskPath) {
if(diskPath == "loading")
return;
if(url[0] == '/')
return;
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (!dataModel) {
qDebug() << "create new model";
dataModel = new GroupDataModel(
QStringList() << "id"
<< "iconLink"
<< "title"
<< "type"
<< "timestamp"
);
m_ListView->setDataModel(dataModel);
}
QSettings settings("Amonchakai", "Hg10");
QStringList keys = dataModel->sortingKeys();
if(!keys.isEmpty() && keys.last() != settings.value("DriveSortKey", "type").toString()) {
keys.clear();
keys.push_back(settings.value("DriveSortKey", "type").toString());
dataModel->setSortingKeys(keys);
}
m_Mutex.lockForWrite();
for(int i = 0 ; i < m_DriveItems.length() ; ++i) {
if(m_DriveItems.at(i)->getIconLink() == url) {
m_DriveItems.at(i)->setIconLink(diskPath);
dataModel->insert(m_DriveItems.at(i));
break;
}
}
m_Mutex.unlock();
emit complete();
}
示例10: result
void HeatScores::requestFinished(QNetworkReply* reply)
{
// Check the network reply for errors
if (reply->error() == QNetworkReply::NoError) {
QString colours [] = {"asset:///images/scoring/red.png", "asset:///images/scoring/black.png",
"asset:///images/scoring/blue.png", "asset:///images/scoring/green.png", "asset:///images/scoring/white.png"};
QString result(reply->readAll());
qDebug() << "\n Scoring result: " << result;
GroupDataModel *model = new GroupDataModel();
model->setGrouping(ItemGrouping::None);
XmlDataAccess xda;
QVariant scoreData = xda.loadFromBuffer(result);
QVariantMap scoreMap = scoreData.value<QVariantMap>();
QVariantMap scoresMap = scoreMap["scores"].value<QVariantMap>();
QVariantList scoreList = scoresMap["score"].value<QVariantList>();
QMap<QString, QVariant> scoreEntry;
for (int i = 0; i < scoreList.size(); i++) {
QVariantMap score = scoreList[i].value<QVariantMap>();
QVariantMap wavesMap = score["waves"].value<QVariantMap>();
QVariantList waveList = wavesMap["wave"].value<QVariantList>();
scoreEntry["surfer_name"] = score["surfer_name"].value<QString>();
scoreEntry["surfer_points"] = score["surfer_points"].value<QString>();
scoreEntry["surfer_points_needed"] = score["surfer_points_needed"].value<QString>();
scoreEntry["surfer_colour"] = colours[i%5];
scoreEntry["waves"] = waveList;
model->insert(scoreEntry);
}
(root->findChild<ListView*>("heatListView"))->setDataModel(model);
(root->findChild<ListView*>("heatListView"))->setListItemProvider(mScoreFactory);
}
else {
qDebug() << "\n Scoring Problem with the network";
qDebug() << "\n Scoring " << reply->errorString();
}
(root->findChild<Label*>("scoresRefreshingLabel"))->setText("");
mActivityIndicator->stop();
mLoading = false;
}
示例11: feedback
void ProfileController::parseFeedback(const QString& page) {
QRegExp feedback("<a href=\"[^\"]+\" target=\"_blank\">(.*)</a></td><td class=\"col2\">(.*)</td><td class=\"col3 .*\">(.*)</td><td>([0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])</td><td class=\"col4\">(.*)</a></td>");
feedback.setMinimal(true);
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (dataModel) {
dataModel->clear();
}
// ----------------------------------------------------------------------------------------------
// push data to the view
int pos = 0;
while((pos = feedback.indexIn(page, pos)) != -1) {
ReviewListItem *item = new ReviewListItem;
item->setFrom(feedback.cap(1));
item->setRole(feedback.cap(2));
item->setDate(feedback.cap(4));
item->setAdvice(feedback.cap(3));
item->setReview(feedback.cap(5));
item->setTimestamp(QDateTime::fromString(feedback.cap(3), "dd/MM/yyyy").toMSecsSinceEpoch());
QRegExp cleanup("<a href=\"[^\"]+\" target=\"_blank\">(.*)");
if(cleanup.indexIn(feedback.cap(5)) != -1) {
item->setReview(cleanup.cap(1));
}
dataModel->insert(item);
pos += feedback.matchedLength();
}
}
示例12: qWarning
void ListFavoriteController::updateView() {
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (dataModel) {
dataModel->clear();
} else {
qDebug() << "create new model";
dataModel = new GroupDataModel(
QStringList() << "title"
<< "timestamp"
<< "lastAuthor"
<< "urlFirstPage"
<< "urlLastPage"
<< "urlLastPostRead"
<< "pages"
<< "flagType"
<< "read"
<< "color"
<< "groupKey"
);
m_ListView->setDataModel(dataModel);
}
dataModel->setGrouping(ItemGrouping::ByFullValue);
// ----------------------------------------------------------------------------------------------
// push data to the view
QList<QObject*> datas;
for(int i = m_Datas->length()-1 ; i >= 0 ; --i) {
datas.push_back(m_Datas->at(i));
}
dataModel->clear();
dataModel->insertList(datas);
}
示例13: qWarning
void ExploreCategoryController::updateView() {
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
if(m_ListView == NULL) {
qWarning() << "the list view is either not provided or not a listview...";
return;
}
using namespace bb::cascades;
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (dataModel) {
dataModel->clear();
} else {
dataModel = new GroupDataModel(
QStringList() << "title"
<< "timestamp"
<< "lastAuthor"
<< "urlFirstPage"
<< "urlLastPage"
<< "urlLastPostRead"
<< "pages"
<< "flagType"
<< "read"
);
m_ListView->setDataModel(dataModel);
}
dataModel->setGrouping(ItemGrouping::ByFullValue);
// ----------------------------------------------------------------------------------------------
// push data to the view
QList<QObject*> datas;
for(int i = m_Datas->length()-1 ; i >= 0 ; --i) {
datas.push_back(m_Datas->at(i));
}
dataModel->clear();
dataModel->insertList(datas);
}
示例14: url
void SmileyPickerController::getSmiley(const QString &keyword) {
if(keyword.isEmpty())
return;
// list green + yellow flags
const QUrl url(DefineConsts::FORUM_URL + "/message-smi-mp-aj.php?config=hfr.inc&findsmilies=" + keyword);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QSslConfiguration sslConfig = request.sslConfiguration();
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
sslConfig.setPeerVerifyDepth(1);
sslConfig.setProtocol(QSsl::TlsV1);
sslConfig.setSslOption(QSsl::SslOptionDisableSessionTickets, true);
request.setSslConfiguration(sslConfig);
QNetworkReply* reply = HFRNetworkAccessManager::get()->get(request);
bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReply()));
Q_ASSERT(ok);
Q_UNUSED(ok);
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
dataModel->clear();
}
示例15: qWarning
void BugReportController::updateView() {
// ----------------------------------------------------------------------------------------------
// get the dataModel of the listview if not already available
using namespace bb::cascades;
if(m_ListView == NULL) {
qWarning() << "did not received the listview. quit.";
return;
}
GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel());
if (dataModel) {
dataModel->clear();
} else {
qDebug() << "create new model";
dataModel = new GroupDataModel(
QStringList() << "title"
<< "author"
<< "number"
<< "locked"
<< "avatar"
<< "comments"
);
m_ListView->setDataModel(dataModel);
}
// ----------------------------------------------------------------------------------------------
// push data to the view
QList<QObject*> datas;
for(int i = m_Issues.length()-1 ; i >= 0 ; --i) {
datas.push_back(m_Issues.at(i));
}
dataModel->clear();
dataModel->insertList(datas);
}