本文整理汇总了C++中QVariantList::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::value方法的具体用法?C++ QVariantList::value怎么用?C++ QVariantList::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::value方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromHtmlList_helper
QString HtmlUtils::fromHtmlList_helper(const QVariant &item, const QString &indent, const HtmlUtils::FromHtmlListOptions &options)
{
QString ret;
Q_UNUSED(options)
if(item.type() == QVariant::List) {
QVariantList lst = item.toList();
QF_ASSERT(!lst.isEmpty(), "Bad item list!", return ret);
QString element_name = lst.first().toString();
//qfInfo() << element_name << item;
QF_ASSERT(!element_name.isEmpty(), "Bad element name!", return ret);
QString attrs_str;
int ix = 1;
QVariant attrs = lst.value(ix);
if(attrs.type() == QVariant::Map) {
QVariantMap m = attrs.toMap();
QMapIterator<QString, QVariant> it(m);
while(it.hasNext()) {
it.next();
attrs_str += ' ' + it.key() + '=' + '"' + it.value().toString() + '"';
}
ix++;
}
bool has_children = (ix < lst.count());
ret += '\n' + indent;
if(has_children) {
ret += '<' + element_name + attrs_str + '>';
QString indent2 = indent + '\t';
bool has_child_elemet = false;
for (; ix < lst.count(); ++ix) {
QVariant v = lst[ix];
if(!v.toList().isEmpty())
has_child_elemet = true;
ret += fromHtmlList_helper(v, indent2, options);
}
if(has_child_elemet)
ret += '\n' + indent;
ret += "</" + element_name + '>';
}
else {
ret += '<' + element_name + attrs_str + "/>";
}
}
示例2: removeExtensionsThatDoNotMustBeOpened
/*!
\param extsToDetect List of extensions to detect.
*/
void TNxSpooler::removeExtensionsThatDoNotMustBeOpened(QStringList &extsToDetect) const
{
QDEBUG_METHOD_NAME;
// List of "booleans" that indicate if the extension must be opened only if found inside a container file, a ".nxspooler-open" file
QVariantList onlyInsideContainer = m_settings.value("onlyInsideContainer").toList();
int quant_exts = extsToDetect.size();
for (int i = 0; i < quant_exts && quant_exts > 0; i++)
{
if (onlyInsideContainer.value(i).toBool() == true)
{
extsToDetect.removeAt(i);
onlyInsideContainer.removeAt(i);
// We change the loop variables to get the correct next item
i--;
quant_exts--;
}
}
}
示例3: invokeMethodEx
QVariant QAccessibleLineEdit::invokeMethodEx(QAccessible::Method method, int child,
const QVariantList ¶ms)
{
if (child)
return QVariant();
switch (method) {
case ListSupportedMethods: {
QSet<QAccessible::Method> set;
set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
return QVariant::fromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
}
case SetCursorPosition:
setCursorPosition(params.value(0).toInt());
return true;
case GetCursorPosition:
return cursorPosition();
default:
return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
}
}
示例4: addRequested
void EffectsManager::addRequested (const QString&, const QVariantList& datas)
{
const auto& id = datas.value (0).toByteArray ();
const auto effectPos = std::find_if (RegisteredEffects_.begin (), RegisteredEffects_.end (),
[&id] (const EffectInfo& info) { return info.ID_ == id; });
if (effectPos == RegisteredEffects_.end ())
{
qWarning () << Q_FUNC_INFO
<< "effect"
<< id
<< "not found";
return;
}
const auto elem = RestoreFilter (effectPos, {});
if (const auto conf = elem->GetConfigurator ())
conf->OpenDialog ();
UpdateHeaders ();
SaveFilters ();
ReemitEffectsList ();
}
示例5: doCall
static int doCall(QObject* object, const QMetaMethod *method,
QVariantList args, QByteArray* retval) {
QGenericReturnArgument ret(0);
int success;
QList<QByteArray> argTypes = method->parameterTypes();
QVariant returnValue(QVariant::nameToType(method->typeName()));
for (int i = 0; i < args.size(); ++i) {
if (!args[i].convert(QVariant::nameToType(argTypes[i]))) {
retval->append(
"Unable to convert parameter " + QByteArray::number(i) + " "
+ args.value(i).toString() + " to "
+ argTypes.value(i));
#ifdef DEBUG_QJnextMainLoop
qDebug() << "[QJnextMainLoop]\ttcalling" << method->signature() << *retval << args;
#endif
return -1;
}
}
#ifdef DEBUG_QJnextMainLoop
qDebug() << "[QJnextMainLoop]\t" << method->signature() << "called with" << args.size() << "args: " << args;
#endif
success = method->invoke(object, Qt::DirectConnection,
_Q_RETURN_ARG(method, returnValue), _Q_ARG(argTypes, args, 0),
_Q_ARG(argTypes, args, 1), _Q_ARG(argTypes, args, 2),
_Q_ARG(argTypes, args, 3), _Q_ARG(argTypes, args, 4),
_Q_ARG(argTypes, args, 5), _Q_ARG(argTypes, args, 6),
_Q_ARG(argTypes, args, 7), _Q_ARG(argTypes, args, 8),
_Q_ARG(argTypes, args, 9));
#ifdef DEBUG_QJnextMainLoop
qDebug() << "[QJnextMainLoop]\tcalled" << success << returnValue;
#endif
*retval = returnValue.toByteArray();
return success;
}
示例6: setModelData
void ItemCharacteristicDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
XSqlQuery ItemetModelData;
QComboBox *comboBox = static_cast<QComboBox*>(editor);
QModelIndex charidx = index.sibling(index.row(), CHAR);
QModelIndex priceidx = index.sibling(index.row(), PRICE);
QVariant charVars;
QVariantList listVars;
if (priceidx.model())
charVars.setValue(priceidx.model()->data(priceidx, Qt::UserRole).toList());
listVars=charVars.toList();
if (editor->inherits("QComboBox"))
{
if (listVars.value(CUST_ID).toInt())
{
ItemetModelData.prepare("SELECT itemcharprice(:item_id,:char_id,:value,:cust_id,:shipto_id,:qty,:curr_id,:effective)::numeric(16,4) AS price;");
ItemetModelData.bindValue(":item_id" , listVars.value(ITEM_ID).toInt());
ItemetModelData.bindValue(":char_id" , charidx.model()->data(charidx, Qt::UserRole));
ItemetModelData.bindValue(":value" , comboBox->currentText());
ItemetModelData.bindValue(":cust_id" , listVars.value(CUST_ID));
ItemetModelData.bindValue(":shipto_id", listVars.value(SHIPTO_ID));
ItemetModelData.bindValue(":qty" , listVars.value(QTY));
ItemetModelData.bindValue(":curr_id" , listVars.value(CURR_ID));
ItemetModelData.bindValue(":effective", listVars.value(EFFECTIVE));
ItemetModelData.exec();
if (ItemetModelData.first())
model->setData(priceidx, ItemetModelData.value("price").toString());
}
model->setData(index, comboBox->currentText());
}
else if (editor->inherits("DLineEdit"))
{
DLineEdit *dlineedit = static_cast<DLineEdit*>(editor);
model->setData(index, dlineedit->date());
}
}
示例7: setAspectRatioMode
StackFolder::StackFolder(QObject *parent, const QVariantList &args)
: Plasma::PopupApplet(parent, args),
m_graphicsWidget(0),
m_placesModel(0)
{
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setHasConfigurationInterface(false);
m_dirModel = new DirModel(this);
m_model = new ProxyModel(this);
m_model->setSourceModel(m_dirModel);
m_model->setSortLocaleAware(true);
m_model->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_selectionModel = new QItemSelectionModel(m_model, this);
if (args.count() > 0) {
m_url = KUrl(args.value(0).toString());
}
m_icon = KIcon("folder");
setPopupIcon(m_icon);
}
示例8: setHasConfigurationInterface
WebBrowser::WebBrowser(QObject *parent, const QVariantList &args)
: Plasma::PopupApplet(parent, args),
m_browser(0),
m_verticalScrollValue(0),
m_horizontalScrollValue(0),
m_completion(0),
m_bookmarkManager(0),
m_bookmarkModel(0),
m_autoRefreshTimer(0)
{
setHasConfigurationInterface(true);
setAspectRatioMode(Plasma::IgnoreAspectRatio);
m_historyCombo = 0;
m_graphicsWidget = 0;
m_webOverlay = 0;
m_layout = 0;
resize(500,500);
if (!args.isEmpty()) {
m_url = KUrl(args.value(0).toString());
}
setPopupIcon("konqueror");
}
示例9: defaultCodecParams
QVariantMap MediaSink::defaultCodecParams(const QString &codec)
{
AVCodec *avCodec = avcodec_find_encoder_by_name(codec.toStdString().c_str());
if (!avCodec)
return QVariantMap();
QVariantMap codecParams;
AVCodecContext *codecContext = avcodec_alloc_context3(avCodec);
if (avCodec->type == AVMEDIA_TYPE_AUDIO) {
QVariantList supportedSampleRates;
if (avCodec->supported_samplerates)
for (int i = 0; int sampleRate = avCodec->supported_samplerates[i]; i++)
supportedSampleRates << sampleRate;
QStringList supportedSampleFormats;
if (avCodec->sample_fmts)
for (int i = 0; ; i++) {
AVSampleFormat sampleFormat = avCodec->sample_fmts[i];
if (sampleFormat == AV_SAMPLE_FMT_NONE)
break;
supportedSampleFormats << QString(av_get_sample_fmt_name(sampleFormat));
}
QStringList supportedChannelLayouts;
char layout[1024];
if (avCodec->channel_layouts)
for (int i = 0; uint64_t channelLayout = avCodec->channel_layouts[i]; i++) {
int channels = av_get_channel_layout_nb_channels(channelLayout);
av_get_channel_layout_string(layout, 1024, channels, channelLayout);
supportedChannelLayouts << QString(layout);
}
codecParams["supportedSampleRates"] = supportedSampleRates;
codecParams["supportedSampleFormats"] = supportedSampleFormats;
codecParams["supportedChannelLayouts"] = supportedChannelLayouts;
codecParams["defaultSampleFormat"] = codecContext->sample_fmt != AV_SAMPLE_FMT_NONE?
QString(av_get_sample_fmt_name(codecContext->sample_fmt)):
supportedSampleFormats.value(0, "s16");
codecParams["defaultBitRate"] = codecContext->bit_rate?
codecContext->bit_rate: 128000;
codecParams["defaultSampleRate"] = codecContext->sample_rate?
codecContext->sample_rate:
supportedSampleRates.value(0, 44100);
int channels = av_get_channel_layout_nb_channels(codecContext->channel_layout);
av_get_channel_layout_string(layout, 1024, channels, codecContext->channel_layout);
QString channelLayout = codecContext->channel_layout?
QString(layout):
supportedChannelLayouts.value(0, "mono");
codecParams["defaultChannelLayout"] = channelLayout;
int channelsCount = av_get_channel_layout_nb_channels(av_get_channel_layout(channelLayout.toStdString().c_str()));
;
codecParams["defaultChannels"] = codecContext->channels?
codecContext->channels:
channelsCount;
} else if (avCodec->type == AVMEDIA_TYPE_VIDEO) {
QVariantList supportedFrameRates;
if (avCodec->supported_framerates)
for (int i = 0; ; i++) {
AVRational frameRate = avCodec->supported_framerates[i];
if (frameRate.num == 0 && frameRate.den == 0)
break;
supportedFrameRates << QVariant::fromValue(QbFrac(frameRate.num, frameRate.den));
}
codecParams["supportedFrameRates"] = supportedFrameRates;
QStringList supportedPixelFormats;
if (avCodec->pix_fmts)
for (int i = 0; ; i++) {
AVPixelFormat pixelFormat = avCodec->pix_fmts[i];
if (pixelFormat == AV_PIX_FMT_NONE)
break;
supportedPixelFormats << QString(av_get_pix_fmt_name(pixelFormat));
}
codecParams["supportedPixelFormats"] = supportedPixelFormats;
codecParams["defaultGOP"] = codecContext->gop_size > 0?
codecContext->gop_size: 12;
codecParams["defaultBitRate"] = codecContext->bit_rate?
codecContext->bit_rate: 200000;
codecParams["defaultPixelFormat"] = codecContext->pix_fmt != AV_PIX_FMT_NONE?
QString(av_get_pix_fmt_name(codecContext->pix_fmt)):
supportedPixelFormats.value(0, "yuv420p");
//.........这里部分代码省略.........
示例10: formatString
/*
Generate a string given a value, using formatting defined within this class.
*/
QString QEStringFormatting::formatString( const QVariant& value ) const
{
QEStringFormatting* self = (QEStringFormatting*) this; // this works as modified members are just used as temp. variables.
QString result;
if( value.type() != QVariant::List ){
// "Simple" scalar
result = self->formatElementString( value );
} else {
// Array variable
const QVariantList valueArray = value.toList();
const int number = valueArray.count ();
switch( arrayAction ) {
case APPEND:
// Interpret each element in the array as an unsigned integer and append
// string representations of each element from the array with a space in
// between each.
for( int j = 0; j < number; j++ ){
QVariant element = valueArray.value (j);
QString elementString;
elementString = self->formatElementString( element );
if( j > 0 )result.append ( " " );
result.append( elementString );
}
break;
case ASCII:
// Interpret each element from the array as a character in a string.
// Translate all non printing characters to '?' except for trailing
// zeros (ignore them)
for( int j = 0; j < number; j++ ){
QVariant element = valueArray.value( j );
bool okay;
int c = element.toInt( &okay );
if( !okay || (c == 0) ) break; // Not an int or got a zero - end of string.
// Ignore carriage returns.
// Note this will cause problems when implementing on Commodore 8-bit machines,
// Acorn BBC, ZX Spectrum, and TRS-80 as they don't use a line feed.
if( c == '\r' )
{
}
// Translate all non printing characters (except for space and line feed) to a '?'
else if( (c!= '\n') && (c < ' ' || c > '~') )
{
result.append( "?" );
}
// Use everything else as is.
else
{
result.append( element.toChar() );
}
}
break;
case INDEX:
// Interpret the element selected by setArrayIndex().
if( arrayIndex < (unsigned int)(number) )
{
QVariant element = valueArray.value ((int) arrayIndex);
result = self->formatElementString( element );
}
break;
default:
self->formatFailure( QString ( "Invalid arrayAction: %d" ).arg ( (int) arrayAction ));
result = "---";
break;
}
}
// Add units if required, if there are any present, and if the text is not an error message
int eguLen = dbEgu.length(); // ??? Why cant this be in the 'if' statement? If it is it never adds an egu
if( addUnits && eguLen && (format != FORMAT_TIME) )
{
result.append( " " ).append( dbEgu );
}
return result;
}
示例11: data
QVariant ResultsDataModel::data(const QVariantList &indexPath) {
//Model is just a list of maps, so return map at given indexPath
//(will be either a song or an album)
return QVariant(_internalDB.value(indexPath.value(0).toInt(NULL)).toMap());
}
示例12: _q_on_data_recieved
void LongPollPrivate::_q_on_data_recieved(const QVariant &response)
{
Q_Q(LongPoll);
auto data = response.toMap();
if (data.contains("failed")) {
q->requestServer();
return;
}
QVariantList updates = data.value("updates").toList();
for (int i = 0; i < updates.size(); i++) {
QVariantList update = updates.at(i).toList();
int updateType = update.value(0, -1).toInt();
switch (updateType) {
case LongPoll::MessageDeleted: {
emit q->messageDeleted(update.value(1).toInt());
break;
}
case LongPoll::MessageAdded: {
//qDebug() << update;
Message::Flags flags(update.value(2).toInt());
Message message(client);
int cid = update.value(3).toInt();
//qDebug() << (flags & Message::FlagChat);
//if (flags & Message::FlagChat)
// cid -= chatMessageOffset;
message.setId(update.value(1).toInt());
message.setFlags(flags);
if (flags & Message::FlagOutbox) {
message.setToId(cid);
message.setFrom(client->me());
} else {
message.setFromId(cid);
message.setTo(client->me());
}
message.setSubject(update.value(5).toString());
message.setBody(update.value(6).toString());
message.setDate(QDateTime::currentDateTime());
emit q->messageAdded(message);
break;
}
case LongPoll::MessageFlagsReplaced: {
int id = update.value(1).toInt();
int flags = update.value(2).toInt();
int userId = update.value(3).toInt();
emit q->messageFlagsReplaced(id, flags, userId);
break;
}
case LongPoll::MessageFlagsReseted: { //TODO remove copy/paste
int id = update.value(1).toInt();
int flags = update.value(2).toInt();
int userId = update.value(3).toInt();
emit q->messageFlagsReseted(id, flags, userId);
break;
}
case LongPoll::UserOnline:
case LongPoll::UserOffline: {
// WTF? Why VKontakte sends minus as first char of id?
auto id = qAbs(update.value(1).toInt());
Buddy::Status status;
if (updateType == LongPoll::UserOnline)
status = Buddy::Online;
else
status = update.value(2).toInt() == 1 ? Buddy::Away
: Buddy::Offline;
emit q->contactStatusChanged(id, status);
break;
}
case LongPoll::GroupChatUpdated: {
int chat_id = update.value(1).toInt();
bool self = update.value(1).toInt();
emit q->groupChatUpdated(chat_id, self);
break;
}
case LongPoll::ChatTyping: {
int user_id = qAbs(update.value(1).toInt());
//int flags = update.at(2).toInt();
emit q->contactTyping(user_id);
break;
}
case LongPoll::GroupChatTyping: {
int user_id = qAbs(update.value(1).toInt());
int chat_id = update.at(2).toInt();
emit q->contactTyping(user_id, chat_id);
break;
}
case LongPoll::UserCall: {
int user_id = qAbs(update.value(1).toInt());
int call_id = update.at(2).toInt();
emit q->contactCall(user_id, call_id);
break;
}
}
}
q->requestData(data.value("ts").toByteArray());
}
示例13: parseReply
bool GoogleTranslate::parseReply(const QByteArray &reply)
{
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
// JSON coming from Google is invalid due to sequences
// like ",,". Replacing all ",," with ",null," allows
// us to parse JSON with QJsonDocument.
QString json = QString::fromUtf8(reply);
if (json.isEmpty()) {
m_error = commonString(EmptyResultCommonString).arg(displayName());
return true;
}
int i = 1;
bool skip = json.at(0) == '"';
while (i < json.length()) {
const QStringRef mid = json.midRef(i - 1, 2);
if (mid.at(1) == '"' && mid.compare(QLatin1String("\\\"")) != 0) {
skip = !skip;
++i;
}
if (!skip && (mid.compare(QLatin1String(",,")) == 0
|| mid.compare(QLatin1String("[,")) == 0
|| mid.compare(QLatin1String(",]")) == 0)) {
json.insert(i, "null");
i += 4;
}
++i;
}
const QVariant data = parseJson(json.toUtf8());
#else
const QVariant data = parseJson(reply);
#endif
if (!data.isValid() || data.type() != QVariant::List)
return false;
const QVariantList dl = data.toList();
if (dl.isEmpty()) {
m_error = commonString(EmptyResultCommonString).arg(displayName());
return true;
}
const QString detected = dl.value(2).toString();
m_detectedLanguage = Language(detected, getLanguageName(detected));
m_translation.clear();
m_translit = StringPair();
foreach (const QVariant &ti, dl.value(0).toList()) {
const QVariantList tr = ti.toList();
if (!tr.value(0).isNull())
m_translation.append(tr.value(0).toString());
if (!tr.value(2).isNull())
m_translit.second.append(tr.value(2).toString());
if (!tr.value(3).isNull())
m_translit.first.append(tr.value(3).toString());
}
m_dict->clear();
if (dl.value(1).type() == QVariant::List) {
foreach (const QVariant &di, dl.value(1).toList()) {
const QVariantList dil = di.toList();
// Translations
const QStringList trans = dil.value(1).toStringList();
// Part of speech
DictionaryPos pos(dil.value(0).toString(), trans);
// Reverse translations
foreach (const QVariant &ei, dil.value(2).toList()) {
const QVariantList eil = ei.toList();
// Word from translations for which reverse translations are provided
QString word = eil.value(0).toString();
// Reverse translations for the aforementioned word
const QStringList rtrans = eil.value(1).toStringList();
// Article for the aforementioned word (if provided)
if (!eil.value(4).toString().isEmpty())
word.prepend(eil.value(4).toString() + " ");
pos.reverseTranslations()->append(word, QStringList(), rtrans);
}
m_dict->append(pos);
}
}
示例14: onDataReceived
void VLongPollClient::onDataReceived()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
reply->deleteLater();
QByteArray rawData = reply->readAll();
debug() << Q_FUNC_INFO << rawData;
QVariantMap data = Json::parse(rawData).toMap();
if (data.contains("failed")) {
requestServer();
return;
} else if (data.isEmpty() || reply->error() != QNetworkReply::NoError) {
if (m_connection->connectionState() == Connected)
QTimer::singleShot(1000, this, SLOT(requestServer()));
return;
}
QVariantList updates = data.value("updates").toList();
for (int i = 0; i < updates.size(); i++) {
QVariantList update = updates.at(i).toList();
int updateType = update.value(0, -1).toInt();
switch (updateType) {
case MessageAdded: {
MessageFlags flags(update.value(2).toInt());
if (flags & MessageOutbox)
continue;
QString id = update.value(3).toString();
QString messageId = update.value(1).toString();
QString subject = update.value(5).toString();
QString text = update.value(6).toString();
VContact *contact = m_connection->account()->getContact(id, true);
qutim_sdk_0_3::Message message;
message.setChatUnit(contact);
message.setProperty("subject", subject);
message.setText(unescape(text));
message.setProperty("mid",messageId);
//message.setProperty("html",text);
message.setTime(QDateTime::currentDateTime());
message.setIncoming(true);
ChatSession *s = ChatLayer::get(contact, true);
s->appendMessage(message);
connect(s,SIGNAL(unreadChanged(qutim_sdk_0_3::MessageList)),SLOT(onUnreadChanged(qutim_sdk_0_3::MessageList)));
m_unread_mess[s].append(message);
contact->setChatState(ChatStateActive);
break;
}
case UserOnline:
case UserOffline: {
// WTF? Why VKontakte sends minus as first char of id?
QString id = update.value(1).toString().mid(1);
VContact *contact = m_connection->account()->getContact(id, false);
if (contact)
contact->setOnline(updateType == UserOnline);
break;
}
}
}
if (m_connection->connectionState() == Connected)
requestData(data.value("ts").toString());
}