本文整理汇总了C++中QList::indexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::indexOf方法的具体用法?C++ QList::indexOf怎么用?C++ QList::indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLayoutsList
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);
}
示例2: displayConnectivity
/**
* 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);
}
}
}
示例3: parseMemberUrl
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;
}
示例4: max
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;
}
示例5: punish
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);
}
示例6: showMenu
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);
}
示例7: while
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();
}
}
示例8: escape
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;
}
示例9: engineChanged
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);
}
示例10: reindexList
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));
}
}
示例11: serialize
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);
}
}
示例12: lessThan
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;
}
示例13: property
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))();
}
示例14: dataChanged
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;
}
示例15: cycles
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]);
}