本文整理汇总了C++中QVariantList::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::isEmpty方法的具体用法?C++ QVariantList::isEmpty怎么用?C++ QVariantList::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromVariantMap
void NodeModel::fromVariantMap(const QVariantMap& map){
QVariantList pos = map["Position"].toList();
QVariantMap netDeviceMap = map["NetDevice"].toMap();
QVariantMap noiseSourceMap = map["NoiseSource"].toMap();
//Migration for older versions of the dgm files.
if(netDeviceMap.isEmpty()){
QVariantList netDevicesList = map["NetDevices"].toList();
if(!netDevicesList.isEmpty()){
netDeviceMap = netDevicesList.at(0).toMap();
}
}
if(noiseSourceMap.isEmpty()){
QVariantList noiseSourcesList = map["NoiseSources"].toList();
if(!noiseSourcesList.isEmpty()){
noiseSourceMap = noiseSourcesList.at(0).toMap();
}
}
name = map["Name"].toString();
position = QPointF(pos.at(0).toDouble(), pos.at(1).toDouble());
if (!netDeviceMap.isEmpty()){
netDevice = new NetDeviceModel(netDeviceMap);
}
if(!noiseSourceMap.isEmpty()){
noiseSource = new NoiseSourceModel(noiseSourceMap);
}
this->hasOutlet = map["HasOutlet"].toBool();
this->outletImpedance.setValue(map["OutletImpedance"].toString());
}
示例2: checkChanges
bool ChangeLog::checkChanges(const QString &previousVersion, const QString ¤tVersion)
{
QVersionNumber previous = QVersionNumber::fromString(previousVersion);
QVersionNumber current = QVersionNumber::fromString(currentVersion);
if (current <= previous) {
qCInfo(CHANGELOG_CATEGORY) << "Current version isn't newer, than previous"
<< previousVersion << currentVersion;
return false;
}
QFileSelector fileSelector;
fileSelector.setExtraSelectors(QStringList() << QLocale::system().uiLanguages().constFirst().split('-').constFirst());
const QString path = fileSelector.select(":/changelogs/changelog.json");
QFile file(path);
if (!file.open(QIODevice::ReadOnly)) {
qCCritical(CHANGELOG_CATEGORY) << "Fail to open changelog file" << path << file.errorString();
return false;
}
QByteArray data = file.readAll();
QJsonParseError parseError;
QJsonDocument document = QJsonDocument::fromJson(data, &parseError);
if (parseError.error != QJsonParseError::NoError) {
qCritical(CHANGELOG_CATEGORY) << "Fail to parse changelog data JSON:"
<< data << "error at offset"
<< parseError.offset
<< parseError.errorString() << parseError.error;
return false;
}
QVariantList content = document.array().toVariantList();
while (!content.isEmpty()) {
if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > current) {
content.takeFirst();
} else {
break;
}
}
QVariantList result;
while (!content.isEmpty()) {
if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > previous) {
result.append(content.takeFirst());
} else {
break;
}
}
if (result.isEmpty()) {
qCWarning(CHANGELOG_CATEGORY) << "Empty changelog" << previousVersion << currentVersion;
return false;
}
emit changesAvailable(result);
return true;
}
示例3: childCount
int RepDataModel::childCount(const QVariantList &indexPath)
{
#ifdef USE_FULL_FETCH
return indexPath.isEmpty() ? vcardList_.size() : 0;
#endif
#ifdef USE_SPARSE_FETCH
return indexPath.isEmpty() ? dataList_.size() : 0;
#endif
}
示例4: deleteRecord
void QuotesApp::deleteRecord()
{
QVariantList indexPath = mListView->selected();
if (!indexPath.isEmpty()) {
QVariantMap map = mDataModel->data(indexPath).toMap();
// Delete the item from the database based on unique ID. If successful, remove it
// from the data model (which will remove the data from the list).
if (mQuotesDbHelper->deleteById(map["id"])) {
// Delete is the only operation where the logics for updating which item
// is selected is handled in code.
// Before the item is removed, we store how many items there are in the
// category that the item is removed from, we need this to select a new item.
QVariantList categoryIndexPath;
categoryIndexPath.append(indexPath.first());
int childrenInCategory = mDataModel->childCount(categoryIndexPath);
mDataModel->remove(map);
// After removing the selected item, we want another quote to be shown.
// So we select the next quote relative to the removed one in the list.
if (childrenInCategory > 1) {
// If the Category still has items, select within the category.
int itemInCategory = indexPath.last().toInt();
if (itemInCategory < childrenInCategory - 1) {
mListView->select(indexPath);
} else {
// The last item in the category was removed, select the previous item relative to the removed item.
indexPath.replace(1, QVariant(itemInCategory - 1));
mListView->select(indexPath);
}
} else {
// If no items left in the category, move to the next category.
// If there are no more categories below(next), select the previous category.
// If no items left at all, navigate to the list.
QVariantList lastIndexPath = mDataModel->last();
if (!lastIndexPath.isEmpty()) {
if (indexPath.first().toInt() <= lastIndexPath.first().toInt()) {
mListView->select(indexPath);
} else {
mListView->select(mDataModel->last());
}
}
} // else statment
} //if statement
} // top if statement
} // deleteRecord()
示例5: fillCommonContainer
void ItemScanner::fillCommonContainer(qlonglong imageid, ImageCommonContainer* const container)
{
QVariantList imagesFields;
QVariantList imageInformationFields;
{
CoreDbAccess access;
imagesFields = access.db()->getImagesFields(imageid,
DatabaseFields::Name |
DatabaseFields::Category |
DatabaseFields::ModificationDate |
DatabaseFields::FileSize);
imageInformationFields = access.db()->getItemInformation(imageid,
DatabaseFields::Rating |
DatabaseFields::CreationDate |
DatabaseFields::DigitizationDate |
DatabaseFields::Orientation |
DatabaseFields::Width |
DatabaseFields::Height |
DatabaseFields::Format |
DatabaseFields::ColorDepth |
DatabaseFields::ColorModel);
}
if (!imagesFields.isEmpty())
{
container->fileName = imagesFields.at(0).toString();
container->fileModificationDate = imagesFields.at(2).toDateTime();
container->fileSize = imagesFields.at(3).toLongLong();
}
if (!imageInformationFields.isEmpty())
{
container->rating = imageInformationFields.at(0).toInt();
container->creationDate = imageInformationFields.at(1).toDateTime();
container->digitizationDate = imageInformationFields.at(2).toDateTime();
container->orientation = DMetadata::valueToString(imageInformationFields.at(3), MetadataInfo::Orientation);
container->width = imageInformationFields.at(4).toInt();
container->height = imageInformationFields.at(5).toInt();
container->format = formatToString(imageInformationFields.at(6).toString());
container->colorDepth = imageInformationFields.at(7).toInt();
container->colorModel = (imagesFields.at(1).toInt() == DatabaseItem::Video) ?
DMetadata::videoColorModelToString((DMetadata::VIDEOCOLORMODEL)imageInformationFields.at(8).toInt()) :
DImg::colorModelToString((DImg::COLORMODEL)imageInformationFields.at(8).toInt());
}
}
示例6: bindParameters
static void bindParameters(const QVariantList& bindValues, QSqlQuery *sqlQuery) {
if (!bindValues.isEmpty()) {
for (int i = bindValues.length() - 1; i >= 0; --i) {
sqlQuery->bindValue(i, bindValues.at(i));
}
}
}
示例7: handleRemote
void WampRouterRegistration::handleRemote(qulonglong requestId, WampRouterSession* /*caller*/, QVariantList params)
{
QVariantList invArr{(int)WampMsgCode::INVOCATION, requestId, registrationId(), QVariantMap()};
if(!params.isEmpty()) invArr.append(QVariant(params));
//if(arr.count()>5) invArr.append(arr[5]);
_session->sendWampMessage(invArr);
}
示例8: processItem
//![11]
void FtpDownloader::processItem(const QVariantList &indexPath)
{
if (!m_selectionPossible)
return;
m_currentIndexPath = indexPath;
enableDownloadButton();
if (!indexPath.isEmpty()) {
// If the user has selected an valid item in the directory listing ListView, check whether it's a directory
const FtpItem item = m_model.data(indexPath).value<FtpItem>();
if (item.isDirectory) {
// In this case clear the content of the model ...
m_model.clear();
// ... assemble the path for the selected subdirectory ...
m_currentPath += '/';
m_currentPath += item.fileName;
// ... and trigger a listing for this subdirectory
m_ftp->cd(item.fileName);
m_ftp->list();
// Update the status property
m_parentDirectoryAvailable = true;
emit parentDirectoryAvailableChanged();
return;
}
}
}
示例9: parseRipperDb
void RipperCC::parseRipperDb()
{
_timer->start();
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
// Occurs error
if(reply->error() != QNetworkReply::NoError) {
qDebug() << "RippperCC Plugin:" << reply->errorString();
reply->close();
return;
}
// No errors
QByteArray ba = reply->readAll();
QVariantMap ripperMap = QJsonWrapper::parseJson(ba).toMap();
if (!ripperMap.contains(QLatin1String("rippers")))
return;
QVariantList ripperList = ripperMap.value(QLatin1String("rippers")).toList();
if (ripperList.isEmpty())
return;
_rippers.clear();
foreach (const QVariant &item, ripperList) {
Ripper ripper;
ripper.jid = item.toMap().value(QLatin1String("jabber")).toString();
ripper.url = item.toMap().value(QLatin1String("link")).toString();
_rippers << ripper;
}
示例10: pushListUpdated
//If the data store changes this method updates the SceneCover with the latest push message
void CoverManager::pushListUpdated() {
QSettings settings;
QVariantList pushList = settings.value("pushList").toList();
if (!pushList.isEmpty()) {
//Read in the last message from the list
QVariant lastReceivedPushMessageVariant = pushList.last();
QString lastReceivedPushMessage;
QStringList messageParts;
lastReceivedPushMessage = lastReceivedPushMessageVariant.toString();
qDebug() << "Last push received: " << lastReceivedPushMessage;
messageParts = lastReceivedPushMessage.split('|');
if (messageParts.size() != 5) {
qDebug() << "Invalid list length. Expected 5, received: "
<< messageParts.size();
} else {
m_pushMessageCover->setProperty("priority", messageParts[0].toInt());
m_pushMessageCover->setProperty("title", messageParts[1]);
m_pushMessageCover->setProperty("body", messageParts[2]);
setDescription(messageParts[4]);
}
return;
} else { //If the list is empty let's display some data to let the user know
m_pushMessageCover->setProperty("priority", 13013);
m_pushMessageCover->setProperty("title", "");
m_pushMessageCover->setProperty("body", "");
setDescription("-");
}
}
示例11: GroupDataModel
ListView *QuotesApp::setUpQuotesList()
{
ListView *listView = 0;
// Load the quotes table from the database.
QVariantList sqlData = mQuotesDbHelper->loadDataBase("quotes.db", "quotes");
if (!sqlData.isEmpty()) {
// A GroupDataModel is used for creating a sorted list.
mDataModel = new GroupDataModel(QStringList() << "lastname" << "firstname");
mDataModel->setParent(this);
mDataModel->setGrouping(ItemGrouping::ByFirstChar);
mDataModel->insert(sqlData);
// The list view is set up in QML, here we retrieve it to connect it to
// a data model.
listView = mNav->findChild<ListView*>("quotesList");
listView->setDataModel(mDataModel);
// By connecting to the selectionChanged signal we can find out when selection has
// changed and update the content pane information based on the selected item.
QObject::connect(listView, SIGNAL(selectionChanged(const QVariantList, bool)), this,
SLOT(onListSelectionChanged(const QVariantList, bool)));
// Connect to the models item added and updated signals, since we want to
// select the item in the list if it has been manipulated.
QObject::connect(mDataModel, SIGNAL(itemAdded(QVariantList)), this,
SLOT(onModelUpdate(QVariantList)));
QObject::connect(mDataModel, SIGNAL(itemUpdated(QVariantList)), this,
SLOT(onModelUpdate(QVariantList)));
}
示例12: read_from
/* ========================================================================== */
QVariant LispPlugin::read_from(QVariantList& tokenz) {
if (tokenz.isEmpty())
throw runtime_error("unexpected EOF while reading");
QByteArray token = tokenz.takeFirst().toByteArray();
if (token == "(") {
//auto L = QVariant(QVariant::List);
QVariantList L;
while (tokenz[0] != ")")
L.append(read_from(tokenz));
tokenz.takeFirst(); // pop off )
return L;
} else if (token == ")") {
throw std::runtime_error("enexcepted )");
} else {
bool successCast;
auto i = token.toInt(&successCast);
if (successCast) return i;
auto d = token.toDouble(&successCast);
if (successCast) return d;
return QString(token);
}
}
示例13: deleteObject
bool App::deleteObject(const QString &customerID)
{
bool deleted = false;
bool saved = false;
if (!validateID(customerID))
return false;
// Create a person object with the required id.
// The name can be left out because find() will use the == operator
// defined in the Person class. See Person.cpp
Person *person = new Person(customerID, QString(), QString());
const QVariantList deleteIndexPath = m_dataModel->find(person);
if (deleteIndexPath.isEmpty()) {
alert(tr("Object ID not found."));
} else {
deleted = m_dataModel->removeAt(deleteIndexPath);
}
if (deleted) {
saved = m_storage->save(m_lastCustomerID, m_dataModel);
}
return (deleted && saved);
}
示例14: notesChanged
void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
{
const QmlProfilerNotesModel *notesModel = d->modelManager->notesModel();
if (typeIndex == -1) {
d->notes.clear();
for (int noteId = 0; noteId < notesModel->count(); ++noteId) {
int noteType = notesModel->typeId(noteId);
if (noteType != -1) {
QString ¬e = d->notes[noteType];
if (note.isEmpty()) {
note = notesModel->text(noteId);
} else {
note.append(QStringLiteral("\n")).append(notesModel->text(noteId));
}
}
}
} else {
d->notes.remove(typeIndex);
QVariantList changedNotes = notesModel->byTypeId(typeIndex);
if (!changedNotes.isEmpty()) {
QStringList newNotes;
for (QVariantList::ConstIterator it = changedNotes.begin(); it != changedNotes.end();
++it) {
newNotes << notesModel->text(it->toInt());
}
d->notes[typeIndex] = newNotes.join(QStringLiteral("\n"));
}
}
emit notesAvailable(typeIndex);
}
示例15: updateObject
//! [4]
// Change the first and last name of the person with the given id.
bool App::updateObject(const QString &id, const QString &firstName, const QString &lastName)
{
bool updated = false;
bool saved = false;
if (!validateID(id))
return false;
Person *person = new Person(id, firstName, lastName);
// Find person in the datamodel.
// Only the id is used by find(). This is because Person
// defines equality (==) as having the same id. (See the definition of "=="
// in the person class.)
const QVariantList updateIndexPath = m_dataModel->find(person);
// update the item if found
if (updateIndexPath.isEmpty()) {
alert(tr("Object ID not found."));
updated = false;
} else {
updated = m_dataModel->updateItem(updateIndexPath, person);
}
// Save the datamodel if we updated something.
if (updated) {
saved = m_storage->save(m_lastCustomerID, m_dataModel);
}
return (updated && saved);
}