本文整理汇总了C++中ItemLocation::set_tab_id方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemLocation::set_tab_id方法的具体用法?C++ ItemLocation::set_tab_id怎么用?C++ ItemLocation::set_tab_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemLocation
的用法示例。
在下文中一共展示了ItemLocation::set_tab_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFirstTabReceived
void ItemsManagerWorker::OnFirstTabReceived() {
QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
QByteArray bytes = reply->readAll();
rapidjson::Document doc;
doc.Parse(bytes.constData());
int index = 0;
if (!doc.IsObject()) {
QLOG_ERROR() << "Can't even fetch first tab. Failed to update items.";
updating_ = false;
return;
}
if (!doc.HasMember("tabs") || doc["tabs"].Size() == 0) {
QLOG_WARN() << "There are no tabs, this should not happen, bailing out.";
updating_ = false;
return;
}
tabs_as_string_ = Util::RapidjsonSerialize(doc["tabs"]);
QLOG_DEBUG() << "Received tabs list, there are" << doc["tabs"].Size() << "tabs";
tabs_.clear();
for (auto &tab : doc["tabs"]) {
std::string label = tab["n"].GetString();
tabs_.push_back(label);
if (index > 0) {
ItemLocation location;
location.set_type(ItemLocationType::STASH);
location.set_tab_id(index);
location.set_tab_label(label);
if (!tab.HasMember("hidden") || !tab["hidden"].GetBool())
QueueRequest(MakeTabRequest(index), location);
}
++index;
}
ItemLocation first_tab_location;
first_tab_location.set_type(ItemLocationType::STASH);
first_tab_location.set_tab_id(0);
first_tab_location.set_tab_label(tabs_[0]);
if (!doc["tabs"][0].HasMember("hidden") || !doc["tabs"][0]["hidden"].GetBool())
ParseItems(&doc["items"], first_tab_location, doc.GetAllocator());
total_needed_ = queue_.size() + 1;
total_completed_ = 1;
FetchItems(kThrottleRequests - 1);
connect(signal_mapper_, SIGNAL(mapped(int)), this, SLOT(OnTabReceived(int)));
reply->deleteLater();
}
示例2: OnFirstTabReceived
void ItemsManagerWorker::OnFirstTabReceived() {
QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
QByteArray bytes = reply->readAll();
rapidjson::Document doc;
doc.Parse(bytes.constData());
int index = 0;
if (!doc.IsObject()) {
QLOG_ERROR() << "Can't even fetch first tab. Failed to update items.";
updating_ = false;
StatusFinished();
return;
}
if (!doc.HasMember("tabs") || doc["tabs"].Size() == 0) {
QLOG_WARN() << "There are no tabs, this should not happen, bailing out.";
updating_ = false;
StatusFinished();
return;
}
tabs_as_string_ = Util::RapidjsonSerialize(doc["tabs"]);
QLOG_INFO() << "Received tabs list, there are" << doc["tabs"].Size() << "tabs";
// Setup tab exclusions
std::string exclusions = data_manager_.Get("tab_exclusions");
QList<QRegularExpression> expressions;
rapidjson::Document exclusionDoc;
exclusionDoc.Parse(exclusions.c_str());
if (exclusionDoc.IsArray()) {
for (auto &excl : exclusionDoc) {
QRegularExpression expr(excl.GetString());
if (!expr.pattern().isEmpty() && expr.isValid()) expressions.append(expr);
}
}
int tabsParsed = 0;
tabs_.clear();
for (auto &tab : doc["tabs"]) {
std::string label = tab["n"].GetString();
bool skip = false;
for (QRegularExpression expr : expressions) {
QRegularExpressionMatch match = expr.match(QString::fromStdString(label));
if (match.isValid() && match.hasMatch()) {
skip = true;
break;
}
}
if (!skip) {
tabs_.push_back(label);
ItemLocation location;
location.set_type(ItemLocationType::STASH);
location.set_tab_id(index);
location.set_tab_label(label);
if (index == 0) {
// We already have this tab (it's the first one we get).
// Parse the items now that we have them
if (!doc["tabs"][0].HasMember("hidden") || !doc["tabs"][0]["hidden"].GetBool()) {
ParseItems(&doc["items"], location, doc.GetAllocator());
++tabsParsed;
}
}
else if (!tab.HasMember("hidden") || !tab["hidden"].GetBool()) {
// If it's not hidden, then we need to download
QueueRequest(MakeTabRequest(index), location);
}
}
++index;
}
if (tabs_.size() == 0) {
QLOG_WARN() << "There are no tabs to be downloaded. Try clearing your tab exclusions list.";
updating_ = false;
StatusFinished();
return;
}
// tabsParsed will be 1 if the first tab was included in the initial download
total_needed_ = queue_.size() + tabsParsed;
total_completed_ = tabsParsed;
FetchItems(kThrottleRequests - tabsParsed);
connect(signal_mapper_, SIGNAL(mapped(int)), this, SLOT(OnTabReceived(int)));
reply->deleteLater();
}
示例3: OnFirstTabReceived
void ItemsManagerWorker::OnFirstTabReceived() {
QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
QByteArray bytes = reply->readAll();
rapidjson::Document doc;
doc.Parse(bytes.constData());
int index = 0;
if (!doc.IsObject()) {
QLOG_ERROR() << "Can't even fetch first tab. Failed to update items.";
updating_ = false;
return;
}
if (!doc.HasMember("tabs") || doc["tabs"].Size() == 0) {
QLOG_WARN() << "There are no tabs, this should not happen, bailing out.";
updating_ = false;
return;
}
tabs_as_string_ = Util::RapidjsonSerialize(doc["tabs"]);
QLOG_INFO() << "Received tabs list, there are" << doc["tabs"].Size() << "tabs";
// Setup tab exclusions
std::string exclusions = data_manager_.Get("tab_exclusions");
QList<QRegularExpression> expressions;
rapidjson::Document exclusionDoc;
exclusionDoc.Parse(exclusions.c_str());
if (exclusionDoc.IsArray()) {
for (auto &excl : exclusionDoc) {
expressions.append(QRegularExpression(excl.GetString()));
}
}
tabs_.clear();
for (auto &tab : doc["tabs"]) {
std::string label = tab["n"].GetString();
bool skip = false;
for (QRegularExpression expr : expressions) {
QRegularExpressionMatch match = expr.match(QString::fromStdString(label));
if (match.isValid() && match.hasMatch()) {
skip = true;
break;
}
}
tabs_.push_back(label);
if (index > 0 || skip) {
ItemLocation location;
location.set_type(ItemLocationType::STASH);
location.set_tab_id(index);
location.set_tab_label(label);
if (!tab.HasMember("hidden") || !tab["hidden"].GetBool())
QueueRequest(MakeTabRequest(skip ? 0 : index), location);
}
++index;
}
ItemLocation first_tab_location;
first_tab_location.set_type(ItemLocationType::STASH);
first_tab_location.set_tab_id(0);
first_tab_location.set_tab_label(tabs_[0]);
if (!doc["tabs"][0].HasMember("hidden") || !doc["tabs"][0]["hidden"].GetBool())
ParseItems(&doc["items"], first_tab_location, doc.GetAllocator());
total_needed_ = queue_.size() + 1;
total_completed_ = 1;
FetchItems(kThrottleRequests - 1);
connect(signal_mapper_, SIGNAL(mapped(int)), this, SLOT(OnTabReceived(int)));
reply->deleteLater();
}