bool QbsRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const { if (!canHandle(parent)) return false; QbsProject *project = static_cast<QbsProject *>(parent->project()); return findProduct(project->qbsProjectData(), productFromId(id)).isValid(); }
void CzMarket::setPurchased(const char* product_id, bool purchased) { CzMarketProduct* product = findProduct(product_id); if (product != NULL) { product->Purchased = purchased; product->Save(); } setCurrentProductID(product_id); }
QString QbsRunConfiguration::executable() const { QbsProject *pro = static_cast<QbsProject *>(target()->project()); const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_qbsProduct); if (!product.isValid() || !pro->qbsProject().isValid()) return QString(); return pro->qbsProject().targetExecutable(product, installOptions()); }
void market::buyProduct(std::string name) { product *temp = findProduct(name); //if product found if(temp != NULL) { //if there is more than 0 of the selected product if(temp->quantity != 0) { //if the user can afford it if(currentUser->wallet > temp->price) { //reduced the inventory by one (temp->quantity)--; //pay for the product currentUser->wallet = currentUser->wallet - temp->price; //for use in storage after the price is changes double salePrice = temp->price; std::cout << "You have " << currentUser->wallet << " dollars left in your wallet." << std::endl; //don't remember exactly why this is here but the idea seems important if(temp->base < temp->price * (pow(settingsStorage.decayRateBase,settingsStorage.decayRate * (time(&settingsStorage.startTime) - temp->lastSold)))) { temp->price = temp->price * (pow(settingsStorage.decayRateBase,settingsStorage.decayRate * (time(&settingsStorage.startTime) - temp->lastSold))); } temp->lastSold = time(&settingsStorage.startTime); //stroing the purchase information every where (very memory inefficient) purchase *newPurchase = new purchase(time(&settingsStorage.startTime),currentUser,temp,salePrice); temp->price = temp->price*(settingsStorage.postBuyMultiplier); std::cout << "The new price is " << temp->price << " and there are " << temp->quantity << " left" << std::endl ; purchaseBlockChain *newBlock = new purchaseBlockChain(newPurchase); personalPurchase *newPersonalPurchase = new personalPurchase(newPurchase); currentUser->purchases.push_back(newPersonalPurchase); blockChain.push_back(newBlock); } else { std::cout << "There is not enough money in your wallet" << std::endl; } } else { std::cout << "There are no " << name << "s left in stock" << std::endl; } } else { std::cout << "Product not found" << std::endl; } }
bool QbsRunConfiguration::isConsoleApplication() const { QbsProject *pro = static_cast<QbsProject *>(target()->project()); const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_qbsProduct); foreach (const qbs::TargetArtifact &ta, product.targetArtifacts()) { if (ta.isExecutable()) return !ta.properties().getProperty(QLatin1String("consoleApplication")).toBool(); } QTC_ASSERT(!pro->qbsProjectData().isValid(), qDebug("No executable target in product '%s'", qPrintable(product.name()))); return false; }