本文整理汇总了C++中Entry::attributes方法的典型用法代码示例。如果您正苦于以下问题:C++ Entry::attributes方法的具体用法?C++ Entry::attributes怎么用?C++ Entry::attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry::attributes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
void TestKeePass2Reader::testProtectedStrings()
{
QString filename = QString(KEEPASSX_TEST_DATA_DIR).append("/ProtectedStrings.kdbx");
CompositeKey key;
key.addKey(PasswordKey("masterpw"));
KeePass2Reader reader;
Database* db = reader.readDatabase(filename, key);
QVERIFY(db);
QVERIFY(!reader.hasError());
QCOMPARE(db->metadata()->name(), QString("Protected Strings Test"));
Entry* entry = db->rootGroup()->entries().at(0);
QCOMPARE(entry->title(), QString("Sample Entry"));
QCOMPARE(entry->username(), QString("Protected User Name"));
QCOMPARE(entry->password(), QString("ProtectedPassword"));
QCOMPARE(entry->attributes()->value("TestProtected"), QString("ABC"));
QCOMPARE(entry->attributes()->value("TestUnprotected"), QString("DEF"));
QVERIFY(db->metadata()->protectPassword());
QVERIFY(entry->attributes()->isProtected("TestProtected"));
QVERIFY(!entry->attributes()->isProtected("TestUnprotected"));
delete db;
}
示例2: QCOMPARE
void TestKeePass2Writer::testProtectedAttributes()
{
QCOMPARE(m_dbTest->rootGroup()->entries().size(), 1);
Entry* entry = m_dbTest->rootGroup()->entries().at(0);
QCOMPARE(entry->attributes()->value("test"), QString("protectedTest"));
QCOMPARE(entry->attributes()->isProtected("test"), true);
}
示例3: QCOMPARE
void TestKeePass2Format::testKdbxProtectedAttributes()
{
QCOMPARE(m_kdbxTargetDb->rootGroup()->entries().size(), 1);
Entry* entry = m_kdbxTargetDb->rootGroup()->entries().at(0);
QCOMPARE(entry->attributes()->value("test"), QString("protectedTest"));
QCOMPARE(entry->attributes()->isProtected("test"), true);
}
示例4: copyAttribute
void DatabaseWidget::copyAttribute(QAction* action)
{
Entry* currentEntry = m_entryView->currentEntry();
if (!currentEntry) {
Q_ASSERT(false);
return;
}
clipboard()->setText(currentEntry->attributes()->value(action->text()));
}
示例5: Database
void TestKeePass2Writer::initTestCase()
{
Crypto::init();
CompositeKey key;
key.addKey(PasswordKey("test"));
m_dbOrg = new Database();
m_dbOrg->setKey(key);
m_dbOrg->metadata()->setName("TESTDB");
Group* group = m_dbOrg->rootGroup();
group->setUuid(Uuid::random());
group->setNotes("I'm a note!");
Entry* entry = new Entry();
entry->setPassword(QString::fromUtf8("\xc3\xa4\xa3\xb6\xc3\xbc\xe9\x9b\xbb\xe7\xb4\x85"));
entry->setUuid(Uuid::random());
entry->attributes()->set("test", "protectedTest", true);
QVERIFY(entry->attributes()->isProtected("test"));
entry->attachments()->set("myattach.txt", QByteArray("this is an attachment"));
entry->attachments()->set("aaa.txt", QByteArray("also an attachment"));
entry->setGroup(group);
Group* groupNew = new Group();
groupNew->setUuid(Uuid::random());
groupNew->setName("TESTGROUP");
groupNew->setNotes("I'm a sub group note!");
groupNew->setParent(group);
QBuffer buffer;
buffer.open(QBuffer::ReadWrite);
KeePass2Writer writer;
writer.writeDatabase(&buffer, m_dbOrg);
QVERIFY(!writer.error());
buffer.seek(0);
KeePass2Reader reader;
m_dbTest = reader.readDatabase(&buffer, key);
QVERIFY(!reader.hasError());
QVERIFY(m_dbTest);
}
示例6: testHistoryItem
void TestModified::testHistoryItem()
{
Entry* entry = new Entry();
QDateTime created = entry->timeInfo().creationTime();
entry->setUuid(Uuid::random());
entry->setTitle("a");
entry->setTags("a");
EntryAttributes* attributes = new EntryAttributes();
attributes->copyCustomKeysFrom(entry->attributes());
Entry* historyEntry;
int historyItemsSize = 0;
entry->beginUpdate();
entry->setTitle("a");
entry->setTags("a");
entry->setOverrideUrl("");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), historyItemsSize);
QDateTime modified = entry->timeInfo().lastModificationTime();
QTest::qSleep(10);
entry->beginUpdate();
entry->setTitle("b");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
historyEntry = entry->historyItems().at(historyItemsSize - 1);
QCOMPARE(historyEntry->title(), QString("a"));
QCOMPARE(historyEntry->uuid(), entry->uuid());
QCOMPARE(historyEntry->tags(), entry->tags());
QCOMPARE(historyEntry->overrideUrl(), entry->overrideUrl());
QCOMPARE(historyEntry->timeInfo().creationTime(), created);
QCOMPARE(historyEntry->timeInfo().lastModificationTime(), modified);
QCOMPARE(historyEntry->historyItems().size(), 0);
entry->beginUpdate();
entry->setTags("b");
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QCOMPARE(entry->historyItems().at(historyItemsSize - 1)->tags(), QString("a"));
entry->beginUpdate();
entry->attachments()->set("test", QByteArray("value"));
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QCOMPARE(entry->historyItems().at(historyItemsSize - 1)->attachments()->keys().size(), 0);
attributes->set("k", "myvalue");
entry->beginUpdate();
entry->attributes()->copyCustomKeysFrom(attributes);
entry->endUpdate();
QCOMPARE(entry->historyItems().size(), ++historyItemsSize);
QVERIFY(!entry->historyItems().at(historyItemsSize - 1)->attributes()->keys().contains("k"));
delete attributes;
delete entry;
Database* db = new Database();
Group* root = db->rootGroup();
db->metadata()->setHistoryMaxItems(3);
db->metadata()->setHistoryMaxSize(-1);
Entry* historyEntry2;
Entry* entry2 = new Entry();
entry2->setGroup(root);
entry2->beginUpdate();
entry2->setTitle("1");
entry2->endUpdate();
entry2->beginUpdate();
entry2->setTitle("2");
entry2->endUpdate();
entry2->beginUpdate();
entry2->setTitle("3");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 3);
entry2->beginUpdate();
entry2->setTitle("4");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 3);
db->metadata()->setHistoryMaxItems(1);
entry2->beginUpdate();
entry2->setTitle("5");
entry2->endUpdate();
QCOMPARE(entry2->historyItems().size(), 1);
historyEntry2 = entry2->historyItems().at(0);
QCOMPARE(historyEntry2->title(), QString("4"));
db->metadata()->setHistoryMaxItems(-1);
for (int i = 0; i < 20; i++) {
entry2->beginUpdate();
entry2->setTitle("6");
entry2->endUpdate();
entry2->beginUpdate();
//.........这里部分代码省略.........
示例7: testEntrySets
void TestModified::testEntrySets()
{
int spyCount = 0;
Database* db = new Database();
Group* root = db->rootGroup();
Group* g = new Group();
g->setParent(root);
Entry* entry = new Entry();
entry->setGroup(g);
QSignalSpy spyModified(db, SIGNAL(modifiedImmediate()));
entry->setUuid(Uuid::random());
QCOMPARE(spyModified.count(), ++spyCount);
entry->setUuid(entry->uuid());
QCOMPARE(spyModified.count(), spyCount);
entry->setTitle("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setTitle(entry->title());
QCOMPARE(spyModified.count(), spyCount);
entry->setUrl("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setUrl(entry->url());
QCOMPARE(spyModified.count(), spyCount);
entry->setUsername("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setUsername(entry->username());
QCOMPARE(spyModified.count(), spyCount);
entry->setPassword("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setPassword(entry->password());
QCOMPARE(spyModified.count(), spyCount);
entry->setNotes("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setNotes(entry->notes());
QCOMPARE(spyModified.count(), spyCount);
entry->setIcon(1);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setIcon(entry->iconNumber());
QCOMPARE(spyModified.count(), spyCount);
entry->setIcon(Uuid::random());
QCOMPARE(spyModified.count(), ++spyCount);
entry->setIcon(entry->iconUuid());
QCOMPARE(spyModified.count(), spyCount);
entry->setTags("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setTags(entry->tags());
QCOMPARE(spyModified.count(), spyCount);
entry->setExpires(true);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setExpires(entry->timeInfo().expires());
QCOMPARE(spyModified.count(), spyCount);
entry->setExpiryTime(Tools::currentDateTimeUtc().addYears(1));
QCOMPARE(spyModified.count(), ++spyCount);
entry->setExpiryTime(entry->timeInfo().expiryTime());
QCOMPARE(spyModified.count(), spyCount);
entry->setAutoTypeEnabled(false);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setAutoTypeEnabled(entry->autoTypeEnabled());
QCOMPARE(spyModified.count(), spyCount);
entry->setAutoTypeObfuscation(1);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setAutoTypeObfuscation(entry->autoTypeObfuscation());
QCOMPARE(spyModified.count(), spyCount);
entry->setDefaultAutoTypeSequence("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setDefaultAutoTypeSequence(entry->defaultAutoTypeSequence());
QCOMPARE(spyModified.count(), spyCount);
entry->setForegroundColor(Qt::red);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setForegroundColor(entry->foregroundColor());
QCOMPARE(spyModified.count(), spyCount);
entry->setBackgroundColor(Qt::red);
QCOMPARE(spyModified.count(), ++spyCount);
entry->setBackgroundColor(entry->backgroundColor());
QCOMPARE(spyModified.count(), spyCount);
entry->setOverrideUrl("test");
QCOMPARE(spyModified.count(), ++spyCount);
entry->setOverrideUrl(entry->overrideUrl());
QCOMPARE(spyModified.count(), spyCount);
entry->attributes()->set("test key", "test value", false);
QCOMPARE(spyModified.count(), ++spyCount);
//.........这里部分代码省略.........
示例8: dbWrite
void TestKeePass2Format::testXmlInvalidXmlChars()
{
QScopedPointer<Database> dbWrite(new Database());
QString strPlainInvalid =
QString().append(QChar(0x02)).append(QChar(0x19)).append(QChar(0xFFFE)).append(QChar(0xFFFF));
QString strPlainValid = QString()
.append(QChar(0x09))
.append(QChar(0x0A))
.append(QChar(0x20))
.append(QChar(0xD7FF))
.append(QChar(0xE000))
.append(QChar(0xFFFD));
// U+10437 in UTF-16: D801 DC37
// high low surrogate
QString strSingleHighSurrogate1 = QString().append(QChar(0xD801));
QString strSingleHighSurrogate2 = QString().append(QChar(0x31)).append(QChar(0xD801)).append(QChar(0x32));
QString strHighHighSurrogate = QString().append(QChar(0xD801)).append(QChar(0xD801));
QString strSingleLowSurrogate1 = QString().append(QChar(0xDC37));
QString strSingleLowSurrogate2 = QString().append(QChar((0x31))).append(QChar(0xDC37)).append(QChar(0x32));
QString strLowLowSurrogate = QString().append(QChar(0xDC37)).append(QChar(0xDC37));
QString strSurrogateValid1 = QString().append(QChar(0xD801)).append(QChar(0xDC37));
QString strSurrogateValid2 =
QString().append(QChar(0x31)).append(QChar(0xD801)).append(QChar(0xDC37)).append(QChar(0x32));
auto entry = new Entry();
entry->setUuid(QUuid::createUuid());
entry->setGroup(dbWrite->rootGroup());
entry->attributes()->set("PlainInvalid", strPlainInvalid);
entry->attributes()->set("PlainValid", strPlainValid);
entry->attributes()->set("SingleHighSurrogate1", strSingleHighSurrogate1);
entry->attributes()->set("SingleHighSurrogate2", strSingleHighSurrogate2);
entry->attributes()->set("HighHighSurrogate", strHighHighSurrogate);
entry->attributes()->set("SingleLowSurrogate1", strSingleLowSurrogate1);
entry->attributes()->set("SingleLowSurrogate2", strSingleLowSurrogate2);
entry->attributes()->set("LowLowSurrogate", strLowLowSurrogate);
entry->attributes()->set("SurrogateValid1", strSurrogateValid1);
entry->attributes()->set("SurrogateValid2", strSurrogateValid2);
QBuffer buffer;
buffer.open(QIODevice::ReadWrite);
bool hasError;
QString errorString;
writeXml(&buffer, dbWrite.data(), hasError, errorString);
QVERIFY(!hasError);
buffer.seek(0);
auto dbRead = readXml(&buffer, true, hasError, errorString);
if (hasError) {
qWarning("Database read error: %s", qPrintable(errorString));
}
QVERIFY(!hasError);
QVERIFY(dbRead.data());
QCOMPARE(dbRead->rootGroup()->entries().size(), 1);
Entry* entryRead = dbRead->rootGroup()->entries().at(0);
EntryAttributes* attrRead = entryRead->attributes();
QCOMPARE(attrRead->value("PlainInvalid"), QString());
QCOMPARE(attrRead->value("PlainValid"), strPlainValid);
QCOMPARE(attrRead->value("SingleHighSurrogate1"), QString());
QCOMPARE(attrRead->value("SingleHighSurrogate2"), QString("12"));
QCOMPARE(attrRead->value("HighHighSurrogate"), QString());
QCOMPARE(attrRead->value("SingleLowSurrogate1"), QString());
QCOMPARE(attrRead->value("SingleLowSurrogate2"), QString("12"));
QCOMPARE(attrRead->value("LowLowSurrogate"), QString());
QCOMPARE(attrRead->value("SurrogateValid1"), strSurrogateValid1);
QCOMPARE(attrRead->value("SurrogateValid2"), strSurrogateValid2);
}