bool X11Helper::setLayout(const LayoutUnit& layout) { QList<LayoutUnit> currentLayouts = getLayoutsList(); int idx = currentLayouts.indexOf(layout); if( idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT ) { kWarning() << "Layout" << layout.toString() << "is not found in current layout list" << getLayoutsListAsString(currentLayouts); return false; } return X11Helper::setGroup((unsigned int)idx); }
/** * Displays the connectivity of Control Points * */ void MosaicControlNetTool::displayConnectivity() { if (m_controlNet) { ImageList images = getWidget()->images(); QList<QColor> colorsUsed; QList< QList<QString> > serialConns = m_controlNet->GetSerialConnections(); QList<QString> island; foreach(island, serialConns) { QColor color; QString cubeSn; foreach(cubeSn, island) { Image *image = takeImage(cubeSn, images); if (image) { while(!color.isValid()) { QColor displayColor = image->displayProperties()->getValue( ImageDisplayProperties::Color).value<QColor>(); if (colorsUsed.indexOf(displayColor) == -1) { colorsUsed.append(displayColor); color = displayColor; } else { QColor ranColor = ImageDisplayProperties::randomColor(); if (colorsUsed.indexOf(ranColor) == -1) { colorsUsed.append(ranColor); color = ranColor; } } } image->displayProperties()->setColor(color); } } }
RelationMember parseMemberUrl(const QString &string) { if (string.startsWith("urn:uuid:")) { RelationMember member; member.gid = string.mid(9); return member; } QUrl url(QUrl::fromEncoded(string.toLatin1())); QList<QByteArray> path; Q_FOREACH(const QByteArray &fragment, url.encodedPath().split('/')) { path.append(ownUrlDecode(fragment).toUtf8()); } // qDebug() << path; bool isShared = false; int start = path.indexOf("user"); if (start < 0) { start = path.indexOf("shared"); isShared = true; } if (start < 0) { Warning() << "Couldn't find \"user\" or \"shared\" in path: " << path; return RelationMember(); } path = path.mid(start + 1); if (path.size() < 2) { Warning() << "Incomplete path: " << path; return RelationMember(); } RelationMember member; if (!isShared) { member.user = path.takeFirst(); } member.uid = path.takeLast().toLong(); member.mailbox = path; member.messageId = ownUrlDecode(url.encodedQueryItemValue("message-id")); member.subject = ownUrlDecode(url.encodedQueryItemValue("subject")); member.date = ownUrlDecode(url.encodedQueryItemValue("date")); // qDebug() << member.uid << member.mailbox; return member; }
CubeCachingAlgorithm::CacheResult RegionalCachingAlgorithm::recommendChunksToFree( QList<RawCubeChunk *> allocated, QList<RawCubeChunk *> justUsed, const Buffer &justRequested) { CacheResult result; if(allocated.size() && allocated[0] != NULL) { double avgLargestDim = max( max(justRequested.SampleDimension(), justRequested.LineDimension()), justRequested.BandDimension()); // They'll all be roughly the same size, so the first one is good enough int largestChunkDim = max( max( allocated[0]->sampleCount(), allocated[0]->lineCount()), allocated[0]->bandCount()); // The average needed per request ought to be // avgLargestDim / largestChunkDim. Let's keep an extra few around // since it's cheap, and because we are uncertain of request patterns. // 40X with a maximum should keep a reasonable number of results // around. int numToKeep = (int)ceil(avgLargestDim / largestChunkDim) * 1; // Limit to ~10MB int approxBytesPerChunk = allocated[0]->getByteCount(); int tenMB = 10 * 1024 * 1024; // 10MB in bytes if(numToKeep * approxBytesPerChunk > tenMB) { numToKeep = tenMB / approxBytesPerChunk; } if(numToKeep < justUsed.size()) numToKeep = justUsed.size(); int numToToss = allocated.size() - numToKeep; QList<RawCubeChunk *> chunksToToss; QListIterator<RawCubeChunk *> allocatedIterator(allocated); while(numToToss > 0 && allocatedIterator.hasNext()) { RawCubeChunk *chunk = allocatedIterator.next(); if(justUsed.indexOf(chunk) == -1) { numToToss --; chunksToToss.append(chunk); } } result = CacheResult(chunksToToss); } return result; }
void ChannelUrlSelectorEntry::punish(const QString& url) { LOG_TRACE(logger, "punish ..."); QList<QString> urls = urlInformation.getUrls(); if(!urls.contains(url)) { LOG_DEBUG(logger, "Url not contained in cache entry ..."); return; } updateFitness(); int urlPosition = urls.indexOf(url); double urlFitness = fitness.at(urlPosition); urlFitness-= punishmentFactor; fitness.replace(urlPosition,urlFitness); }
int Cutegram::showMenu(const QStringList &actions, QPoint point) { if( point.isNull() ) point = QCursor::pos(); QMenu menu; QList<QAction*> pointers; for( int i=0; i<actions.count(); i++ ) pointers << menu.addAction(actions.value(i)); QAction *res = menu.exec(point); return pointers.indexOf(res); }
void Menu::moveVertically() { QList<QGraphicsItem *> items = this->items(); int sizeList = items.size(); QGraphicsItem * focusItem = this->focusItem(); QList<QGraphicsItem *>::const_iterator it = items.begin(); QList<QGraphicsItem *>::const_iterator tmpIt = it; int index = items.indexOf(focusItem); ++index; QRectF currentRectF = focusItem->boundingRect(); currentRectF.setHeight(this->getGeometry().height()); currentRectF.setWidth(currentRectF.width()); currentRectF.setX(currentRectF.x()); currentRectF.setY(0); int i = 0; bool haveRect = false; while (i < sizeList && haveRect == false) { index = ((index < sizeList) ? index : (index - sizeList)); tmpIt = it; tmpIt += index; haveRect = currentRectF.intersects((*tmpIt)->boundingRect()); ++index; ++i; } if (haveRect == true) { (*tmpIt)->setFocus(); } else { index = items.indexOf(focusItem) + 1; index = ((index < sizeList) ? index : (index - sizeList)); it += index; (*it)->setFocus(); } }
QString Jid::escape(const QString &AUserNode) { QString escNode; if (!AUserNode.isEmpty()) { escNode.reserve(AUserNode.length()*3); for (int i=0; i<AUserNode.length(); i++) { int index = EscChars.indexOf(AUserNode.at(i)); if (index==0 && EscStrings.indexOf(AUserNode.mid(i,3))>=0) escNode.append(EscStrings.at(index)); else if (index > 0) escNode.append(EscStrings.at(index)); else escNode.append(AUserNode.at(i)); } escNode.squeeze(); } return escNode; }
void EngineItemModel::engineChanged() { Engine *engine = qobject_cast<Engine *>(sender()); if(!engine) return; QList<Engine *> list = m_glwidget->engines(); int row = list.indexOf(engine); QModelIndex begin = createIndex(row, 0); QModelIndex end = createIndex(row, 0); emit dataChanged(begin, end); }
static QList<int> reindexList(const GlobalConfig *config, Phonon::Category category, QList<int>newOrder, bool output) { Q_ASSERT(config); #ifdef QT_NO_PHONON_AUDIOCAPTURE Q_ASSERT(output); #endif /*QString sb; sb = QString("(Size %1)").arg(currentList.size()); foreach (int i, currentList) sb += QString("%1, ").arg(i); fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData()); sb = QString("(Size %1)").arg(newOrder.size()); foreach (int i, newOrder) sb += QString("%1, ").arg(i); fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/ QList<int> currentList; if (output) currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); #ifndef QT_NO_PHONON_AUDIOCAPTURE else currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); #endif QList<int> newList; foreach (int i, newOrder) { int found = currentList.indexOf(i); if (found < 0) { // It's not in the list, so something is odd (e.g. client error). Ignore it. continue; } // Iterate through the list from this point onward. If there are hidden devices // immediately following, take them too. newList.append(currentList.takeAt(found)); while (found < currentList.size()) { bool hidden = true; if (output) hidden = isHiddenAudioOutputDevice(config, currentList.at(found)); #ifndef QT_NO_PHONON_AUDIOCAPTURE else hidden = isHiddenAudioCaptureDevice(config, currentList.at(found)); #endif if (!hidden) break; newList.append(currentList.takeAt(found)); } }
void MaterialEditorModel::serialize(QDataStream &str) const { QList<Node *> nodes = getNodes(); QList<NodeLink *> lnks = getLinks(); int version = 1; str<<version; str<<nodes.size(); str<<lnks.size(); for(Node *n : nodes) { n->serialize(str); } for(NodeLink *l : lnks) { NodeOut *start = l->getStart(); NodeIn *end = l->getEnd(); str<<nodes.indexOf(start->getParent()); str<<nodes.indexOf(end->getParent()); str<<start->getParent()->getOuts().indexOf(start); str<<end->getParent()->getIns().indexOf(end); } }
bool TreeWidget::lessThan(const TreeItem* one, const TreeItem* another) const { QStringList order; const TreeItem* parent = one->parentItem(); if (!parent) order = d.parentOrder; else if (!isSortingBlocked()) order = d.childrenOrders.value(parent->text(0)); const int oidx = order.indexOf(one->text(0)); const int aidx = order.indexOf(another->text(0)); if (oidx == -1 || aidx == -1) { if (!one->parentItem()) { QList<IrcConnection*> connections = one->treeWidget()->d.connections; return connections.indexOf(one->connection()) < connections.indexOf(another->connection()); } if (one->buffer()) { const FriendlyModel* model = static_cast<FriendlyModel*>(one->buffer()->model()); return model->lessThan(one->buffer(), another->buffer(), model->sortMethod()); } return one->QTreeWidgetItem::operator<(*another); } return oidx < aidx; }
QVariant DynamicPropertyData::property(const char *name, const QVariant &def, const QList<QByteArray> &gNames, const QList<Getter> &gGetters) const { QByteArray prop = QByteArray::fromRawData(name, strlen(name)); int id = gNames.indexOf(prop); if (id < 0) { id = names.indexOf(prop); if(id < 0) return def; return values.at(id); } return (this->*gGetters.at(id))(); }
bool QgsComposerAttributeTableColumnModelV2::moveColumnInSortRank( QgsComposerTableColumn * column, ShiftDirection direction ) { if ( !mComposerTable || !column ) { return false; } if (( direction == ShiftUp && column->sortByRank() <= 1 ) || ( direction == ShiftDown && column->sortByRank() <= 0 ) ) { //already at start/end of list or not being used for sort return false; } //find column before this one in sort order QList<QgsComposerTableColumn*> sortedColumns; QList<QgsComposerTableColumn*>::iterator columnIt = mComposerTable->columns()->begin(); for ( ; columnIt != mComposerTable->columns()->end(); ++columnIt ) { if (( *columnIt )->sortByRank() > 0 ) { sortedColumns.append( *columnIt ); } } qStableSort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank ); int columnPos = sortedColumns.indexOf( column ); if (( columnPos == 0 && direction == ShiftUp ) || (( columnPos == sortedColumns.length() - 1 ) && direction == ShiftDown ) ) { //column already at start/end return false; } QgsComposerTableColumn* swapColumn = direction == ShiftUp ? sortedColumns[ columnPos - 1] : sortedColumns[ columnPos + 1]; QModelIndex idx = indexFromColumn( column ); QModelIndex idxSwap = indexFromColumn( swapColumn ); //now swap sort ranks int oldSortRank = column->sortByRank(); column->setSortByRank( swapColumn->sortByRank() ); emit dataChanged( idx, idx ); swapColumn->setSortByRank( oldSortRank ); emit dataChanged( idxSwap, idxSwap ); return true; }
Grapher::CycleList Grapher::cycles() const { // vertex indices QList<Vertex> indices = m_vertices.keys(); QTime swatch; swatch.start(); int numEdges = 0; // construct the graph using vertex indices as vertex identifiers // math::Graph graph(m_vertices.size()); for (VertexMap::const_iterator it = m_vertices.begin(); it != m_vertices.end(); ++it) { Vertex const & v1 = it.key(); AdjacencyList const & adjs = it.value(); for (AdjacencyList::const_iterator jt = adjs.begin(); jt != adjs.end(); ++jt) { Vertex const & v2 = jt->v; // vertex identifiers // int gv1 = indices.indexOf(v1) + 1; int gv2 = indices.indexOf(v2) + 1; graph.connect(gv1,gv2); ++numEdges; } } numEdges /= 2; // undirected graph qDebug() << "graph contains" << m_vertices.size() << "vertices and" << numEdges << "edges"; // obtain the graph's MCB (this could take a while) QList<math::Graph::VertexList> mcb = graph.minimumCycleBasis(CompareCycles(indices)); // construct cycle list from the graph's MCB // CycleList result; foreach (math::Graph::VertexList gcycle, mcb) { Cycle cycle; foreach (math::Graph::Vertex gv, gcycle) { cycle.append(indices[gv-1]); }
void Layout::keyPressEvent(QKeyEvent * keyEvent ) { QList<QGraphicsItem *> items = this->items(); int sizeList = items.size(); switch (keyEvent->key()) { case Qt::Key_Left: case Qt::Key_Right : { QGraphicsItem * focusItem = this->focusItem(); int index = items.indexOf(focusItem) + 1; QList<QGraphicsItem *>::iterator it = items.begin(); if (index < sizeList) it += index; (*it)->setFocus(); } break; case Qt::Key_Up : case Qt::Key_Down: { QGraphicsItem * focusItem = this->focusItem(); int index = items.indexOf(focusItem) + 3; QList<QGraphicsItem *>::iterator it = items.begin(); it += ((index < sizeList) ? index : (index - sizeList)); (*it)->setFocus(); } break; case Qt::Key_Return : this->drawChild(this->focusItem()); break; case Qt::Key_Backspace : this->drawParent(this->focusItem()); break; } }
void TestShapeReorderCommand::testSendToBack() { MockShape shape1, shape2, shape3; shape1.setSize(QSizeF(100, 100)); shape1.setZIndex(1); shape2.setSize(QSizeF(100, 100)); shape2.setZIndex(2); shape3.setSize(QSizeF(100, 100)); shape3.setZIndex(3); QList<KShape*> shapes; shapes.append(&shape1); shapes.append(&shape2); shapes.append(&shape3); MockCanvas canvas; KShapeManager manager(&canvas, shapes); qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&shape1), 0); QCOMPARE(shapes.indexOf(&shape2), 1); QCOMPARE(shapes.indexOf(&shape3), 2); QList<KShape*> selectedShapes; selectedShapes.append(&shape3); QUndoCommand * cmd = KShapeReorderCommand::createCommand(selectedShapes, &manager, KShapeReorderCommand::SendToBack); cmd->redo(); qSort(shapes.begin(), shapes.end(), KShape::compareShapeZIndex); QCOMPARE(shapes.indexOf(&shape3), 0); QCOMPARE(shapes.indexOf(&shape1), 1); QCOMPARE(shapes.indexOf(&shape2), 2); delete cmd; }
/*! Updates model item with fresh data \param entry item to update */ void CaItemModelPrivate::updateItemData(const QSharedPointer<CaEntry> &entry) { CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::updateItemData"); int id = entry->id(); QList<int> ids = mService->getEntryIds(mQuery); if (mEntries.indexOf(id) >= 0 && ids.indexOf(id) == mEntries.indexOf(id)) { mEntries.updateEntry(entry); emit m_q->dataChanged( index(mEntries.indexOf(id)), index(mEntries.indexOf(id))); } else if (mParentEntry && id == mParentEntry->id()) { updateParentEntry(); m_q->reset(); } else if (ids.indexOf(id) < 0) { removeItem(id); } else if (mEntries.indexOf(id) < 0) { addItem(id); } else { updateModel(); } CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::updateItemData"); }
int CTUnit::fieldToValue(const QString& entry) const { QString lower = entry.toLower(); // check for days QList<QString> days; days << QLatin1String( "sun" ) << QLatin1String( "mon" ) << QLatin1String( "tue" ) << QLatin1String( "wed" ) << QLatin1String( "thu" ) << QLatin1String( "fri" ) << QLatin1String( "sat" ); int day = days.indexOf(lower); if (day != -1) { return day; } // check for months QList<QString> months; months << QLatin1String( "" ) << QLatin1String( "jan" ) << QLatin1String( "feb" ) << QLatin1String( "mar" ) << QLatin1String( "apr" ) << QLatin1String( "may" ) << QLatin1String( "jun" ) << QLatin1String( "jul" ) << QLatin1String( "aug" ) << QLatin1String( "sep" ) << QLatin1String( "oct" ) << QLatin1String( "nov" ) << QLatin1String( "dec" ); int month = months.indexOf(lower); if (month != -1) { return month; } //If the string does not match a day ora month, then it's a simple number (minute, hour or day of month) return entry.toInt(); }
/** * @brief Database::SELECT * @param params */ void Database::SELECT(QStringList params) { QString selection = params.at(1).toUpper(); QString database; QString column; QString value; QList<QString> headers; int columnIndex; QList<QString> words; QTextStream output(stdout); if(params.at(2).toUpper() == "FROM") { database = params.at(3).toLower(); if(params.at(4).toUpper() == "WHERE") { QList<QString> whereparams = params.at(5).split("="); column = whereparams.at(0).trimmed().toUpper(); value = whereparams.at(1).trimmed(); } else { output << "Error!" << endl; } } else { output << "Error!" << endl; } // Open File and get the data QFile file("../Datenbank/" + database + ".csv"); if (!file.open(QIODevice::ReadWrite)) { qDebug() << file.errorString(); } else { while (!file.atEnd()) { QString line = file.readLine(); if(headers.length() == 0) { headers = line.split(";"); data.append(headers); columnIndex = headers.indexOf(column); if(columnIndex < 0) { output << "Error!" << endl; } } words = line.split(";"); if(words.at(columnIndex).trimmed().toLower() == value) data.append(words); } } outputData(); }
void DemoApplet::showConfigurationDialog() { QDialog dialog; QStringList colors = QColor::colorNames(); QList <QColor> colorList; for (int i = 0; i < colors.size(); i++) colorList << QColor(colors.at(i)); m_settingsUi->setupUi(&dialog); m_settingsUi->color->addItems(colors); m_settingsUi->color->setCurrentIndex(colorList.indexOf(m_color)); if(dialog.exec() == QDialog::Accepted) { m_color = QColor(m_settingsUi->color->currentText()); m_rectItem->setBrush(QBrush(m_color)); m_configChanged = true; } }
void Server_Game::nextTurn() { QMutexLocker locker(&gameMutex); const QList<int> keys = players.keys(); int listPos = -1; if (activePlayer != -1) listPos = keys.indexOf(activePlayer); do { ++listPos; if (listPos == keys.size()) listPos = 0; } while (players.value(keys[listPos])->getSpectator() || players.value(keys[listPos])->getConceded()); setActivePlayer(keys[listPos]); }
void Library::updateTrackMetadata(Track track) { Track ntrack = track; if (track.id() > 0) { ntrack = _library_storage->updateTrack(track); } // update all playlists QList<QString> playlists = getPlaylistsNames(); foreach (QString name, playlists) { Playlist pl = getPlaylist(name); QList<Track> tracks = pl.tracks(); int pos = tracks.indexOf(ntrack); // comparing using source tracks.removeOne(ntrack); // comparing using source tracks.insert(pos, ntrack); pl.setTracks(tracks); savePlaylist(pl); }
void QPropertyModel::addItem(QObject *propertyObject) { // first create property <-> class hierarchy QList<PropertyPair> propertyMap; QList<const QMetaObject*> classList; const QMetaObject* metaObject = propertyObject->metaObject(); do { int count = metaObject->propertyCount(); for (int i=0; i<count; ++i) { QMetaProperty property = metaObject->property(i); if( property.isUser() ) // Hide Qt specific properties { PropertyPair pair(metaObject, property); int index = propertyMap.indexOf(pair); if (index != -1) { propertyMap[index] = pair; } else { propertyMap.push_back(pair); } } } classList.push_front(metaObject); }while ((metaObject = metaObject->superClass())!=0); QList<const QMetaObject*> finalClassList; // remove empty classes from hierarchy list foreach(const QMetaObject* obj, classList) { bool keep = false; foreach(PropertyPair pair, propertyMap) { if (pair.Object == obj) { keep = true; break; } } if (keep) { finalClassList.push_back(obj); } }
/** * @brief Database::DELETE * @param params */ void Database::DELETE(QStringList params) { QString database; QString column; QString value; QTextStream output(stdout); if(params.at(1).toUpper() == "FROM") { database = params.at(2).toLower(); if(params.at(3).toUpper() == "WHERE") { QList<QString> whereparams = params.at(4).split("="); column = whereparams.at(0).trimmed().toUpper(); value = whereparams.at(1).trimmed(); } else { output << "Error!" << endl; } } else { output << "Error!" << endl; } QFile file("../Datenbank/" + database + ".csv"); if (!file.open(QIODevice::ReadWrite)) { qDebug() << file.errorString(); } else { QList<QString> headers; int columnIndex; while (!file.atEnd()) { QString line = file.readLine(); if(headers.length() == 0) { headers = line.split(";"); columnIndex = headers.indexOf(column); if(columnIndex < 0) { output << "Error!" << endl; } } QList<QString> words = line.split(";"); if(words.at(columnIndex).trimmed().toLower() != value) data.append(words); } } // update the file; file.resize(0); QTextStream stream(&file); stream << "Test"; }
static void getSlots( const QMetaObject *meta, QList<Property> &result, bool super, bool withArgs, bool sigs ) { while (meta) { int nmethods = meta->methodCount(); for (int i=0; i<nmethods; ++i) { const QMetaMethod m = meta->method(i); if (m.access() == QMetaMethod::Private) continue ; if ((m.methodType() == QMetaMethod::Slot && !sigs) || (m.methodType() == QMetaMethod::Signal && sigs)) { Property prop; QString s = QLatin1String( m.methodSignature() ); s = s.left(s.indexOf('(')); QList<QByteArray> parameterTypes = m.parameterTypes(); QList<QByteArray> parameterNames = m.parameterNames(); prop.type = m.typeName(); QuickInterpreter::cleanType(prop.type); if ( withArgs ) { s += QLatin1String("("); for ( int j = 0; j < parameterTypes.count(); ++j ) { s += parameterTypes.at(j); s += QLatin1String(" "); s += QString::fromLatin1(parameterNames.at(j)); if ( j < parameterTypes.count() - 1 ) s += QString::fromLatin1(","); } s += QString::fromLatin1(")"); } prop.name = s; if (result.indexOf(prop) == -1) result << prop; } } if (super) meta = meta->superClass(); else meta = 0; } }
/*! Called internally when the legend has been checked Emits a checked() signal. */ void QwtLegend::itemChecked( bool on ) { QWidget *w = qobject_cast<QWidget *>( sender() ); if ( w ) { const QVariant itemInfo = d_data->itemMap.itemInfo( w ); if ( itemInfo.isValid() ) { const QList<QWidget *> widgetList = d_data->itemMap.legendWidgets( itemInfo ); const int index = widgetList.indexOf( w ); if ( index >= 0 ) Q_EMIT checked( itemInfo, on, index ); } } }
/*! \internal */ bool QImageReaderPrivate::initHandler() { // check some preconditions if (!device || (!deleteDevice && !device->isOpen() && !device->open(QIODevice::ReadOnly))) { imageReaderError = QImageReader::DeviceError; errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Invalid device")); return false; } // probe the file extension if (deleteDevice && !device->isOpen() && !device->open(QIODevice::ReadOnly) && autoDetectImageFormat) { QList<QByteArray> extensions = QImageReader::supportedImageFormats(); if (!format.isEmpty()) { // Try the most probable extension first int currentFormatIndex = extensions.indexOf(format.toLower()); if (currentFormatIndex > 0) extensions.swap(0, currentFormatIndex); } int currentExtension = 0; QFile *file = static_cast<QFile *>(device); QString fileName = file->fileName(); do { file->setFileName(fileName + QLatin1Char('.') + QString::fromLatin1(extensions.at(currentExtension++).constData())); file->open(QIODevice::ReadOnly); } while (!file->isOpen() && currentExtension < extensions.size()); if (!device->isOpen()) { imageReaderError = QImageReader::FileNotFoundError; errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "File not found")); file->setFileName(fileName); // restore the old file name return false; } } // assign a handler if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) { imageReaderError = QImageReader::UnsupportedFormatError; errorString = QLatin1String(QT_TRANSLATE_NOOP(QImageReader, "Unsupported image format")); return false; } return true; }
QString Json::stringify(const QVariant &variant, int indent) { QString res; if((variant.type() == QVariant::List) || (variant.type() == QVariant::StringList)) { res = QString(" ").repeated(indent) + "[\n"; QList<QVariant> list = variant.toList(); foreach(QVariant var, list) { res += stringify(var, indent + 2); if(list.indexOf(var) < list.size() - 1) { res += ","; } res += "\n"; }
static ControlPoint getControlPoint(const QList<ControlPoint> &selectedPoints, const ControlPoint &controlPoint, int indexOffset, bool isClosedPath) { int controlPointIndex = selectedPoints.indexOf(controlPoint); if (controlPointIndex >= 0) { int offsetIndex = controlPointIndex + indexOffset; if (offsetIndex >= 0 && offsetIndex < selectedPoints.count()) return selectedPoints.at(offsetIndex); else if (isClosedPath) { if (offsetIndex == -1) return selectedPoints.constLast(); else if (offsetIndex < selectedPoints.count()) return selectedPoints.at(1); } } return ControlPoint(); }