本文整理汇总了C++中QVariantList::prepend方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::prepend方法的具体用法?C++ QVariantList::prepend怎么用?C++ QVariantList::prepend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::prepend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
/// Load configuration from database.
bool WebData::load(QVariantList& conf)
{
QSqlQuery query(*database_);
query.prepare( "select value from conf_data");
if (!query.exec())
{
return false;
}
while (query.next())
{
QVariant var;
QByteArray data = query.value(0).toByteArray();
QBuffer buffer(&data);
buffer.open(QIODevice::ReadOnly);
QDataStream stream(&buffer);
stream >> var;
conf.prepend(var);
}
return true;
}
示例2: post
FeedReply NodeInfoFeed::post(const QString &path, const QVariantMap &json, Channel *channel, const QByteArray &blob)
{
Q_UNUSED(blob)
const bool owner = can(channel, Acl::Edit);
const bool moderator = can(channel, Acl::SpecialWrite);
if (!owner && !moderator)
return Notice::Forbidden;
if (!channel || path.isEmpty() || path.contains(FEED_WILDCARD_ASTERISK) || !json.contains(FEED_KEY_VALUE))
return Notice::BadRequest;
const QVariant& value = json[FEED_KEY_VALUE];
const qint64 date = DateTime::utc();
if (path == INFO_FEED_MOTD_KEY) {
ChatId id(value.toString());
if (id.type() != ChatId::MessageId)
return Notice::BadRequest;
QVariantList list = m_data.value(path).toList();
list.removeAll(value.toString());
list.prepend(value.toString());
m_data.insert(path, list);
return FeedReply(Notice::OK, date);
}
if (!owner)
return Notice::Forbidden;
// Установка текстового заголовка канала.
if (path == INFO_FEED_TITLE_KEY) {
QVariantMap data;
data[INFO_FEED_TEXT_KEY] = value.toString().left(200);
data[INFO_FEED_AUTHOR_KEY] = SimpleID::encode(channel->id());
data[INFO_FEED_DATE_KEY] = date;
m_data[path] = data;
return FeedReply(Notice::OK, date);
}
if (path == INFO_FEED_VISIBILITY_KEY) {
visibility(value.toInt());
return FeedReply(Notice::OK, date);
}
if (path == INFO_FEED_PINNED_KEY) {
if (!Ch::server()->feed(FEED_NAME_ACL)->can(channel, Acl::Edit))
return Notice::Forbidden;
m_data[path] = value.toBool();
return FeedReply(Notice::OK, date);
}
if (!m_data.contains(path) || m_data.value(path) != value) {
m_data[path] = value;
return FeedReply(Notice::OK, date);
}
return Notice::NotModified;
}