本文整理匯總了C++中Basket類的典型用法代碼示例。如果您正苦於以下問題:C++ Basket類的具體用法?C++ Basket怎麽用?C++ Basket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Basket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: while
void Archive::loadExtractedBaskets(const QString &extractionFolder, QDomNode &basketNode, QMap<QString, QString> &folderMap, Basket *parent)
{
bool basketSetAsCurrent = (parent != 0);
QDomNode n = basketNode;
while ( ! n.isNull() ) {
QDomElement element = n.toElement();
if ( (!element.isNull()) && element.tagName() == "basket" ) {
QString folderName = element.attribute("folderName");
if (!folderName.isEmpty()) {
// Move the basket folder to its destination, while renaming it uniquely:
QString newFolderName = folderMap[folderName];
FormatImporter copier;
// The folder has been "reserved" by creating it. Avoid asking the user to override:
QDir dir;
dir.rmdir(Global::basketsFolder() + newFolderName);
copier.moveFolder(extractionFolder + "baskets/" + folderName, Global::basketsFolder() + newFolderName);
// Append and load the basket in the tree:
Basket *basket = Global::bnpView->loadBasket(newFolderName);
BasketListViewItem *basketItem = Global::bnpView->appendBasket(basket, (basket && parent ? Global::bnpView->listViewItemForBasket(parent) : 0));
basketItem->setExpanded(!XMLWork::trueOrFalse(element.attribute("folded", "false"), false));
QDomElement properties = XMLWork::getElement(element, "properties");
importBasketIcon(properties, extractionFolder); // Rename the icon fileName if necessary
basket->loadProperties(properties);
// Open the first basket of the archive:
if (!basketSetAsCurrent) {
Global::bnpView->setCurrentBasket(basket);
basketSetAsCurrent = true;
}
QDomNode node = element.firstChild();
loadExtractedBaskets(extractionFolder, node, folderMap, basket);
}
}
n = n.nextSibling();
}
}
示例2: TEST
TEST(CxxCaseQuote, MockBulk)
{
using namespace case_quote;
// Bulk_quote sales which has discount: minimum 5 and 25% discount
// 35*6*(1-.25) = 157.5
shared_ptr<MockBulk> q1(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q2(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q3(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q4(new MockBulk("912", 35, 5, .25));
shared_ptr<MockBulk> q5(new MockBulk("912", 35, 5, .25));
EXPECT_CALL(*q1, net_price(_))
.WillOnce(Return(157.5));
Basket sale;
sale.add_item(q1);
sale.add_item(q2);
sale.add_item(q3);
sale.add_item(q4);
sale.add_item(q5);
EXPECT_EQ(sale.total_receipt(cout), 157.5);
}
示例3: main
int main()
{
Basket basket;
basket.add_item(Quote("0-201-82470-1", 50));
for (int i = 0; i < 15; ++i)
basket.add_item(Bulk_quote("0-201-54848-8", 50, 10, .25));
basket.total_receipt(cout);
return 0;
}
示例4: updateToolTipDelayed
void SystemTray::updateToolTipDelayed()
{
Basket *basket = Global::bnpView->currentBasket();
QString tip = "<p><nobr>" + ( basket->isLocked() ? KDialog::makeStandardCaption(i18n("%1 (Locked)"))
: KDialog::makeStandardCaption( "%1") )
.arg(Tools::textToHTMLWithoutP(basket->basketName()));
QToolTip::add(this, tip);
}
示例5: main
int main()
{
Basket bQuote;
for (int i = 0; i != 10; ++i)
{
bQuote.add_item(Bulk_quote("book", i * 10.1, 10, 0.3));
}
std::cout << std::endl << std::endl;
std::cout << bQuote.total() << std::endl;
return 0;
}
示例6: AddItemsToBasket
void AddItemsToBasket(const std::string& items, Basket& basket)
{
for (auto c : items) {
auto item = std::string(1, c);
basket.Add(item);
}
}
示例7: main
int main()
{
Basket basket;
Sales_item item1(Bulk_item("0-0001-0001-1", 99, 20, 0.5));
Sales_item item2(Bulk_item("0-0001-0001-2", 50));
Sales_item item3(Bulk_item("0-0001-0001-3", 59, 200, 0.3));
Sales_item item4(Bulk_item("0-0001-0001-1", 99, 20, 0.2));
basket.add_item(item1);
basket.add_item(item2);
basket.add_item(item3);
basket.add_item(item4);
cout << basket.total() << endl;
system("pause");
return 0;
}
示例8: main
int main()
{
RawString rawString;
ForThroughCollection forThrough;
LambdaMaxFunction lambdaMax;
Basket basket = {"jab³ko", "sliwka", "pomarañcza"};
basket.addItems({"banan", "marchew"});
cout << "Silnia z 10 to: " << TemplateFactorial<1, 10>::value << endl << endl;
LiteralOperatorExample apostropheOperator;
TupleExample tupleExample;
VariadicSizeofExample variadicSizeofExample;
VariadicVarargsExample varargsExample;
Bind bind;
//Regex regex;
TagDispatcher dispatcher;
return 0;
}
示例9: main
int main()
{
Basket basket;
for (unsigned i = 0; i != 10; ++i)
basket.add_item(Bulk_quote("Bible",20.6,20,0.3));
for (unsigned i = 0; i != 10; ++i)
basket.add_item(Bulk_quote("C++Primer",30.9,5,0.4));
for (unsigned i = 0; i != 10; ++i)
basket.add_item(Quote("CLRS",40.1));
std::ofstream log("log.txt",std::ios_base::app|std::ios_base::out);
basket.total_receipt(log);
return 0;
}
示例10: deserialize
// Deserializing the basket from the binary file in the already existing basket
// If there is an error, the existing basket is not changed
bool Basket::deserialize(const char* file)
{
Basket d;
cout << "Iniating deserialization." << endl;
std::ifstream myfile(file, std::ios::binary);
if (!myfile)
{
cout << "Error" << endl;
return false;
}
int amountOfE;
myfile.read((char*)&amountOfE, sizeof(amountOfE));
if (!myfile)
{
cout << "Error." << endl;
return false;
}
char buffer[1000];
int basketNameLen=0;
myfile.read((char*)&basketNameLen, sizeof(basketNameLen));
myfile.read((char*)buffer, basketNameLen);
name[basketNameLen] = '\0';
d.setName(buffer);
for (int i = 0; i < amountOfE; i++)
{
double eggSize = 0;
myfile.read((char*)&eggSize, sizeof(eggSize));
int nameSize = 0;
myfile.read((char*)&nameSize, sizeof(nameSize));
myfile.read((char*)buffer, nameSize);
buffer[nameSize] = '\0';
d.addÅgg(Egg(buffer, eggSize));
}
//if all is okay, existing basket = basket we just read from the binary file
*this = d;
myfile.close();
return true;
}
示例11: updateToolTip
void SystemTray::updateToolTip()
{
// return; /////////////////////////////////////////////////////
Basket *basket = Global::bnpView->currentBasket();
if (!basket)
return;
if (basket->icon().isEmpty() || basket->icon() == "basket" || ! Settings::showIconInSystray())
setPixmap(basket->isLocked() ? m_lockedIconPixmap : m_iconPixmap);
else {
// Code that comes from JuK:
QPixmap bgPix = loadIcon("basket");
QPixmap fgPix = SmallIcon(basket->icon());
QImage bgImage = bgPix.convertToImage(); // Probably 22x22
QImage fgImage = fgPix.convertToImage(); // Should be 16x16
QImage lockOverlayImage = loadIcon("lockoverlay").convertToImage();
KIconEffect::semiTransparent(bgImage);
copyImage(bgImage, fgImage, (bgImage.width() - fgImage.width()) / 2,
(bgImage.height() - fgImage.height()) / 2);
if (basket->isLocked())
KIconEffect::overlay(bgImage, lockOverlayImage);
bgPix.convertFromImage(bgImage);
setPixmap(bgPix);
}
//QTimer::singleShot( Container::c_delayTooltipTime, this, SLOT(updateToolTipDelayed()) );
// No need to delay: it's be called when notes are changed:
updateToolTipDelayed();
}
示例12: main
int main()
{
Basket car;
car.add_items(Quote("0001", 25));
car.add_items(Bulk_quote("0002", 12, 8, 0.3));
car.add_items(Quote("0003", 19));
car.add_items(Bulk_quote("0004", 32, 12, 0.5));
auto total = car.total_receipt(std::cout);
return 0;
}
示例13: updateDisplay
/** Updates the icon and tooltip in the system tray */
void SystemTray::updateDisplay()
{
Basket *basket = Global::bnpView->currentBasket();
if (!basket)
return;
// Update the icon
if (basket->icon().isEmpty()
|| basket->icon() == "basket"
|| !Settings::showIconInSystray())
setIcon(basket->isLocked() ? m_lockedIcon : m_icon);
else {
// Code that comes from JuK:
QPixmap bgPix = loadIcon("basket").pixmap(m_iconSize);
int smallIconSize = kapp->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap fgPix = loadIcon(basket->icon()).pixmap(smallIconSize);
QImage bgImage = bgPix.toImage(); // Probably 22x22
QImage fgImage = fgPix.toImage(); // Should be 16x16
KIconEffect::semiTransparent(bgImage);
copyImage(bgImage, fgImage, bgImage.width()-fgImage.width() / 2,
bgImage.height()-fgImage.height() / 2);
if (basket->isLocked()) {
QImage lockOverlay = loadIcon("lockoverlay").pixmap(m_iconSize).toImage();
KIconEffect::overlay(bgImage, lockOverlay);
}
setIcon(QPixmap::fromImage(bgImage));
}
// update the tooltip
QString tip = "<p><nobr>";
QString basketName = "%1";
if (basket->isLocked())
basketName += i18n(" (Locked)");
tip += KDialog::makeStandardCaption(basketName);
tip = tip.arg(Tools::textToHTMLWithoutP(basket->basketName()));
setToolTip(tip);
}
示例14: ThrowItemsToBasket
bool ThrowItemsToBasket(Basket& basket)
{
std::vector<Item> ret;
std::ifstream fin("./input/itemlist/input1.txt", std::ios::in);
while (!fin.eof())
{
std::string line;
std::getline(fin, line);
//if (!IsLegal(line)) continue;
std::string item_name;
unsigned int item_count;
unsigned int item_price;
bool is_imported = false;
if (GetItemProperties(line, item_name, item_count, item_price, is_imported))
{
Item item(item_name, item_price, is_imported);
basket.addItem(item, item_count);
}
}
return true;
}
示例15:
bool operator<(const Basket &a, const Basket &b)
{
int min;
if (a.getSize() < b.getSize())
min = a.getSize();
else
min = b.getSize();
for (int i = 0; i < min; i++)
{
if ((strcmp(a[i].getName(), b[i].getName()) > 0))
return false;
}
if(a.getSize() <= b.getSize())
{
return true;
}
else
{
return false;
}
}