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(); }
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); }
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); }
void SmileyPickerController::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() << "tag" << "localUrl" ); m_ListView->setDataModel(dataModel); } // ---------------------------------------------------------------------------------------------- // push data to the view QList<QObject*> datas; for(int i = 0 ; i < m_Emoticons.size() ; ++i) { Emoticon *e = new Emoticon; e->setLocalUrl(m_Emoticons.at(i)->getLocalUrl()); e->setTag(m_Emoticons.at(i)->getTag()); datas.push_back(e); } dataModel->clear(); dataModel->insertList(datas); }
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); }
void DriveController::openForSharing(const QString &id, const QString &type) { // ---------------------------------------------------------------------------------------------- // 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(type == "application/vnd.google-apps.folder") { if(dataModel != NULL) dataModel->clear(); m_Google->getFileList(id); } else { using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle("Share"); dialog->setBody("Do you want to share this document?"); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedShareFile(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI. m_SelectedItemForSharing = id; dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } } }
void DriveController::search(const QString &key) { 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 != NULL) { m_DriveItems.clear(); dataModel->clear(); } m_Google->search(key); }
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(); } }
GroupDataModel* Database::getLive(int uid,int offset,QString type) { GroupDataModel *model = new GroupDataModel(QStringList()); QString query = "select * from messagesTab where (fromId = \""; query.append(QString::number(uid)); query.append("\" or toId = \""); query.append(QString::number(uid)); query.append("\" ) and type = \""); query.append(type); query.append("\" and id > \""); query.append(QString::number(offset)); query.append("\" order by date desc"); QVariant list = sqlda->execute(query); model->clear(); model->insertList(list.value<QVariantList>()); qDebug()<< "userid in database " << uid << offset << type; qDebug() << query << model->size(); return model; }
void DriveController::open(const QString &id, const QString &type) { // ---------------------------------------------------------------------------------------------- // 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(type == "application/vnd.google-apps.folder") { if(dataModel != NULL) dataModel->clear(); m_Google->getFileList(id); } else { QString link; m_Mutex.lockForRead(); for(int i = 0 ; i < m_DriveItems.length() ; ++i) { if(m_DriveItems.at(i)->getID() == id) { link = m_DriveItems.at(i)->getOpenLink(); break; } } m_Mutex.unlock(); if(!link.isEmpty()) emit pushOpenLink(link); else { bb::system::SystemToast *toast = new bb::system::SystemToast(this); toast->setBody(tr("Cannot open this file...")); toast->setPosition(bb::system::SystemUiPosition::MiddleCenter); toast->show(); } } }
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(); }
void SmileyPickerController::getPrevPage() { if(m_IndexSubpagesInFile.length() == 0) return; if(m_Page.isEmpty()) 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()); dataModel->clear(); m_lastId = std::max(m_lastId-1, 0); parse(m_Page, m_IndexSubpagesInFile[m_lastId]); }
void HistoryBrowserController::updateThreadsView(const QByteArray& buffer) { using namespace bb::data; JsonDataAccess jda; QVariant qtData = jda.loadFromBuffer(buffer); if(jda.hasError()) { qDebug() << jda.error().errorMessage(); } if(m_HistoryList == NULL) { qWarning() << "did not received the list. quit."; return; } using namespace bb::cascades; GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_HistoryList->dataModel()); dataModel->clear(); dataModel->insertList(qtData.toMap()["threads"].toList()); emit completed(); }