Ejemplo n.º 1
0
void HistoryEntry::deSerialize(const QJsonObject & json)
{
    *this = HistoryEntry();

    if (json.contains("expression"))
        m_expr = json["expression"].toString();

    if (json.contains("result"))
        m_result = Quantity(json["result"].toObject());
    return;
}
Ejemplo n.º 2
0
	/* set new scope */
	void push_elem(const char* msg) {
		const std::string s = msg;

		PerChunkCounter::const_iterator it = history.back().second.find(s);
		if(it != history.back().second.end()) {
			++history.back().second[s];
		}
		else history.back().second[s] = 1;

		history.push_back(HistoryEntry(s,PerChunkCounter()));

	}
Ejemplo n.º 3
0
    /* construct given two file handles to compare */
    comparer_context(FILE* actual,FILE* expect)
        : actual(actual)
        , expect(expect)
        , cnt_chunks(0)
    {
        ai_assert(actual);
        ai_assert(expect);

        fseek(actual,0,SEEK_END);
        lengths.push(std::make_pair(static_cast<uint32_t>(ftell(actual)),0));
        fseek(actual,0,SEEK_SET);

        history.push_back(HistoryEntry("---",PerChunkCounter()));
    }
Ejemplo n.º 4
0
HistoryEntry HistoryManager::getEntry(qint64 entry)
{
	QSqlQuery query(QSqlDatabase::database(QLatin1String("browsingHistory")));
	query.prepare(QLatin1String("SELECT \"visits\".\"id\", \"visits\".\"title\", \"locations\".\"scheme\", \"locations\".\"path\", \"hosts\".\"host\", \"icons\".\"icon\", \"visits\".\"time\", \"visits\".\"typed\" FROM \"visits\" LEFT JOIN \"locations\" ON \"visits\".\"location\" = \"locations\".\"id\" LEFT JOIN \"hosts\" ON \"locations\".\"host\" = \"hosts\".\"id\" LEFT JOIN \"icons\" ON \"visits\".\"icon\" = \"icons\".\"id\" WHERE \"visits\".\"id\" = ?;"));
	query.bindValue(0, entry);
	query.exec();

	if (query.first())
	{
		return getEntry(query.record());
	}

	return HistoryEntry();
}
Ejemplo n.º 5
0
void Bank::transferFrom(TransferInfo& info) {
    auto account = accounts[info.getFrom().second];
    account->money -= info.getMoney();
    account->_history
             .push_back(HistoryEntryTransfer(info.getMoney(),
                                             info.getCurrency(),
                                             OperationType::TRANSFER,
                                             info.getTitle(), info.getFrom(),
                                             info.getTo()));
    double charge = account->info.getTransferCharge();

    if (charge != 0) {
        account->money -= charge / exchangeTable()
                                   .getBuyRate(account->currency);
        account->_history.push_back(HistoryEntry(charge, Currency::ENC,
                                                 OperationType::CHARGE));
    }
}
Ejemplo n.º 6
0
HistoryEntry HistoryManager::getEntry(const QSqlRecord &record)
{
	if (record.isEmpty())
	{
		return HistoryEntry();
	}

	QPixmap pixmap;
	pixmap.loadFromData(record.field(QLatin1String("icon")).value().toByteArray());

	HistoryEntry historyEntry;
	historyEntry.url.setScheme(record.field(QLatin1String("scheme")).value().toString());
	historyEntry.url.setHost(record.field(QLatin1String("host")).value().toString());
	historyEntry.url.setPath(record.field(QLatin1String("path")).value().toString());
	historyEntry.title = record.field(QLatin1String("title")).value().toString();
	historyEntry.time = QDateTime::fromTime_t(record.field(QLatin1String("time")).value().toInt(), Qt::LocalTime);
	historyEntry.icon = QIcon(pixmap);
	historyEntry.identifier = record.field(QLatin1String("id")).value().toLongLong();
	historyEntry.visits = record.field(QLatin1String("visits")).value().toInt();
	historyEntry.typed = record.field(QLatin1String("typed")).value().toBool();

	return historyEntry;
}