当前位置: 首页>>代码示例>>C++>>正文


C++ QList::last方法代码示例

本文整理汇总了C++中QList::last方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::last方法的具体用法?C++ QList::last怎么用?C++ QList::last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QList的用法示例。


在下文中一共展示了QList::last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _writeByteArrayToFd

static void _writeByteArrayToFd(const QByteArray& data, const QByteArray& prefix, FILE *fh)
{
    QList<QByteArray> lines = data.split('\n');
    if (lines.isEmpty())
        return;

    // If the last item was a separator, there will be an extra blank item at the end
    if (lines.last().isEmpty())
        lines.removeLast();

    if (!lines.isEmpty()) {
        QFile f;
        f.open(fh, QIODevice::WriteOnly);
        foreach (const QByteArray& line, lines) {
            f.write(prefix);
            f.write(line);
            f.write("\n");
        }
开发者ID:qtproject,项目名称:playground-qtprocessmanager,代码行数:18,代码来源:qprocessbackend.cpp

示例2: while

QList<QStringList> QHelpDBReader::filterAttributeSets() const
{
    QList<QStringList> result;
    if (m_query) {
        m_query->exec(QLatin1String("SELECT a.Id, b.Name FROM FileAttributeSetTable a, "
            "FilterAttributeTable b WHERE a.FilterAttributeId=b.Id ORDER BY a.Id"));
        int oldId = -1;
        while (m_query->next()) {
            int id = m_query->value(0).toInt();
            if (id != oldId) {
                result.append(QStringList());
                oldId = id;
            }
            result.last().append(m_query->value(1).toString());
        }
    }
    return result;
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:18,代码来源:qhelpdbreader.cpp

示例3: saveSettings

void PropertiesWidget::saveSettings() {
  Preferences* const pref = Preferences::instance();
  pref->setPropVisible(state==VISIBLE);
  // Splitter sizes
  QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
  QList<int> sizes;
  if (state == VISIBLE)
    sizes = hSplitter->sizes();
  else
    sizes = slideSizes;
  qDebug("Sizes: %d", sizes.size());
  if (sizes.size() == 2) {
    pref->setPropSplitterSizes(QString::number(sizes.first())+','+QString::number(sizes.last()));
  }
  pref->setPropFileListState(filesList->header()->saveState());
  // Remember current tab
  pref->setPropCurTab(m_tabBar->currentIndex());
}
开发者ID:seapoint,项目名称:qBittorrent,代码行数:18,代码来源:propertieswidget.cpp

示例4: setupModelData

void QalfTreeModel::setupModelData(const QStringList &lines, TreeItem *parent) {
	QList<TreeItem*> parents;
	QList<int> indentations;
	parents << parent;
	indentations << 0;

	int number = 0;

	while (number < lines.count()) {
		int position = 0;
		while (position < lines[number].length()) {
			if (lines[number].mid(position, 1) != " ")
				break;
			position++;
		}

		QString lineData = lines[number].mid(position).trimmed();

		if (!lineData.isEmpty()) {
			// Read the column data from the rest of the line.
			QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
			QList<QVariant> columnData;
			for (int column = 0; column < columnStrings.count(); ++column)
				columnData << columnStrings[column];

			if (position > indentations.last()) {
				// The last child of the current parent is now the new parent
				// unless the current parent has no children.

				if (parents.last()->childCount() > 0) {
					parents << parents.last()->child(parents.last()->childCount()-1);
					indentations << position;
				}
			} else {
				while (position < indentations.last() && parents.count() > 0) {
					parents.pop_back();
					indentations.pop_back();
				}
			}

			// Append a new item to the current parent's list of children.
			parents.last()->appendChild(new TreeItem(columnData, parents.last()));
		}

		number++;
	}
}
开发者ID:BackupTheBerlios,项目名称:torrentlibre-svn,代码行数:47,代码来源:qalftreemodel.cpp

示例5: newSampleBuffer

QList<SharedSampleBuffer> SampleUtils::splitSampleBuffer( const SharedSampleBuffer sampleBuffer,
                                                          QList<int> slicePointFrameNums )
{
    Q_ASSERT( ! slicePointFrameNums.isEmpty() );

    QList<SharedSampleBuffer> sampleBufferList;

    qSort( slicePointFrameNums );

    const int totalNumFrames = sampleBuffer->getNumFrames();

    if ( slicePointFrameNums.last() != totalNumFrames )
    {
        slicePointFrameNums << totalNumFrames;
    }

    const int numChans = sampleBuffer->getNumChannels();

    int startFrame = 0;

    foreach ( int frameNum, slicePointFrameNums )
    {
        if( frameNum <= totalNumFrames )
        {
            const int numFrames = frameNum - startFrame;

            if ( numFrames > 0 )
            {
                SharedSampleBuffer newSampleBuffer( new SampleBuffer( numChans, numFrames ) );

                for ( int chanNum = 0; chanNum < numChans; chanNum++ )
                {
                    newSampleBuffer->copyFrom( chanNum, 0, *sampleBuffer.data(), chanNum, startFrame, numFrames );
                }

                sampleBufferList << newSampleBuffer;

                startFrame += numFrames;
            }
        }
    }

    return sampleBufferList;
}
开发者ID:conradjones,项目名称:shuriken,代码行数:44,代码来源:sampleutils.cpp

示例6: setModules

/** Sets the modules used by the search. */
void BtSearchOptionsArea::setModules( QList<CSwordModuleInfo*> modules ) {
    qDebug() << "BtSearchOptionsArea::setModules";
    qDebug() << modules;
    QString t;

    m_modules.clear(); //remove old modules
    QList<CSwordModuleInfo*>::iterator end_it = modules.end();

    for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
        /// \todo Check for containsRef compat
        if (*it == 0) { //don't operate on null modules.
            continue;
        }
        qDebug() << "new module:" << (*it)->name();
        if ( !m_modules.contains(*it) ) {
            m_modules.append( *it );
            t.append( (*it)->name() );
            if (*it != modules.last()) {
                t += QString::fromLatin1(", "); // so that it will become a readable list (WLC, LXX, GerLut...)
            }
        }
    };
    //m_modulesLabel->setText(t);
    int existingIndex = m_modulesCombo->findText(t);
    qDebug() << "index of the module list string which already exists in combobox:" << existingIndex;
    if (existingIndex >= 0) {
        m_modulesCombo->removeItem(existingIndex);
    }
    if (m_modulesCombo->count() > 10) {
        m_modulesCombo->removeItem(m_modulesCombo->count() - 1);
    }
    m_modulesCombo->insertItem(0, t);
    m_modulesCombo->setItemData(0, t, Qt::ToolTipRole);
    m_modulesCombo->setCurrentIndex(0);
    m_modulesCombo->setToolTip(t);
    //Save the list in config here, not when deleting, because the history may be used
    // elsewhere while the dialog is still open
    QStringList historyList;
    for (int i = 0; i < m_modulesCombo->count(); ++i) {
        historyList.append(m_modulesCombo->itemText(i));
    }
    CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
    emit sigSetSearchButtonStatus(modules.count() != 0);
}
开发者ID:bibletime,项目名称:historic-bibletime-svn,代码行数:45,代码来源:btsearchoptionsarea.cpp

示例7: operator

Expression RangeCommand::operator()(const QList< Analitza::Expression >& args)
{
    Expression ret;
    
    const int nargs = args.size();
    
    double a = 1;
    double b = 0;
    double h = 1;
    
    switch(nargs) {
        case 0: {
            ret.addError(QCoreApplication::tr("Invalid parameter count for '%1'").arg(RangeCommand::id));
            
            return ret;
        }    break;
        case 1: {
            b = static_cast<const Analitza::Cn*>(args.first().tree())->value();
        }    break;
        case 2: {
            a = static_cast<const Analitza::Cn*>(args.first().tree())->value();
            b = static_cast<const Analitza::Cn*>(args.last().tree())->value();
        }    break;
        case 3: {
            a = static_cast<const Analitza::Cn*>(args.at(0).tree())->value();
            b = static_cast<const Analitza::Cn*>(args.at(1).tree())->value();
            h = static_cast<const Analitza::Cn*>(args.at(2).tree())->value();
        }    break;
        default:
            ret.addError(QCoreApplication::tr("Invalid parameter count for '%1'").arg(RangeCommand::id));
            
            return ret;
            break;
    }
    
    Analitza::List *seq = new Analitza::List;
        
    for (double x = a; x <= b; x += h)
        seq->appendBranch(new Analitza::Cn(x));
    
    ret.setTree(seq);
    
    return ret;
}
开发者ID:KDE,项目名称:analitza,代码行数:44,代码来源:listcommands.cpp

示例8: buffer

	Private(const QByteArray *ba)
	{
		init();

		QBuffer buffer((QByteArray *)ba);
		buffer.open(QBuffer::ReadOnly);
		QImageReader reader(&buffer);

		while ( reader.canRead() ) {
			QImage image = reader.read();
			if ( !image.isNull() ) {
				Frame newFrame;
				frames.append( newFrame );
				frames.last().impix  = Impix(image);
				frames.last().period = reader.nextImageDelay();
			}
			else {
				break;
			}
		}

		looping = reader.loopCount();

		if ( !reader.supportsAnimation() && (frames.count() == 1) ) {
			QImage frame = frames[0].impix.image();

			// we're gonna slice the single image we've got if we're absolutely sure
			// that it's can be cut into multiple frames
			if ((frame.width() / frame.height() > 0) && !(frame.width() % frame.height())) {
				int h = frame.height();
				QList<Frame> newFrames;

				for (int i = 0; i < frame.width() / frame.height(); i++) {
					Frame newFrame;
					newFrames.append( newFrame );
					newFrames.last().impix  = Impix(frame.copy(i * h, 0, h, h));
					newFrames.last().period = 120;
				}

				frames  = newFrames;
				looping = 0;
			}
		}
	}
开发者ID:Vitozz,项目名称:psi,代码行数:44,代码来源:anim.cpp

示例9: updateScreenTwits

	void TwitterPage::updateScreenTwits (QList<Tweet_ptr> twits)
	{
		if (twits.isEmpty ())	// if we have no tweets to parse
			return;

		Tweet_ptr firstNewTwit = twits.first ();

		if (ScreenTwits_.length () && (twits.last ()->GetId () == ScreenTwits_.first ()->GetId ())) // if we should prepend
			for (auto i = twits.end () - 2; i >= twits.begin (); i--)
				ScreenTwits_.insert (0, *i);
		else
		{
			int i;
			// Now we'd find firstNewTwit in twitList
			for (i = 0; i < ScreenTwits_.length (); i++)
				if ((ScreenTwits_.at (i)->GetId ()) == firstNewTwit->GetId ())
					break;

			int insertionShift = ScreenTwits_.length () - i;    // We've already got insertionShift twits to our list

			for (i = 0; i < insertionShift && !twits.isEmpty (); i++)
				twits.removeFirst ();

			if (XmlSettingsManager::Instance ()->property ("notify").toBool ())
			{
				if (twits.length () == 1)			// We can notify the only twit
				{
					const auto& notification = Util::MakeNotification (twits.first ()->GetAuthor ()->GetUsername (),
							twits.first ()->GetText (),
							PInfo_);
					EntityManager_->HandleEntity (notification);
				}
				else if (!twits.isEmpty ()) {
					const auto& notification = Util::MakeNotification (tr ("Woodpecker"),
							tr ( "%1 new twit (s)" ).arg (twits.length ()),
							PInfo_);
					EntityManager_->HandleEntity (notification);
				}
			}
			ScreenTwits_.append (twits);
		}

		UpdateReady_ = true;
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:44,代码来源:twitterpage.cpp

示例10: touch_event

bool Viewport::touch_event(QTouchEvent *event)
{
	QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints();

	if (touchPoints.count() != 2) {
		pinch_zoom_active_ = false;
		return false;
	}

	const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
	const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();

	if (!pinch_zoom_active_ ||
	    (event->touchPointStates() & Qt::TouchPointPressed)) {
		pinch_offset0_ = (view_.offset() + view_.scale() * touchPoint0.pos().x()).convert_to<double>();
		pinch_offset1_ = (view_.offset() + view_.scale() * touchPoint1.pos().x()).convert_to<double>();
		pinch_zoom_active_ = true;
	}

	double w = touchPoint1.pos().x() - touchPoint0.pos().x();
	if (abs(w) >= 1.0) {
		const double scale =
			fabs((pinch_offset1_ - pinch_offset0_) / w);
		double offset = pinch_offset0_ - touchPoint0.pos().x() * scale;
		if (scale > 0)
			view_.set_scale_offset(scale, offset);
	}

	if (event->touchPointStates() & Qt::TouchPointReleased) {
		pinch_zoom_active_ = false;

		if (touchPoint0.state() & Qt::TouchPointReleased) {
			// Primary touch released
			drag_release();
		} else {
			// Update the mouse down fields so that continued
			// dragging with the primary touch will work correctly
			mouse_down_point_ = touchPoint0.pos().toPoint();
			drag();
		}
	}

	return true;
}
开发者ID:jhol,项目名称:pulseview,代码行数:44,代码来源:viewport.cpp

示例11: font

KnobSpin::KnobSpin(const QString &title, double min, double max, double step, QWidget *parent):
    QWidget(parent)
{
  QFont font("Helvetica", 10);

  knob_ = new QwtKnob(this);
  knob_->setFont(font);
  knob_->setRange(min, max);
  QwtScaleDiv scaleDiv =
      knob_->scaleEngine()->divideScale(min, max, 5, 3);
  QList<double> ticks = scaleDiv.ticks(QwtScaleDiv::MajorTick);
  if ( ticks.size() > 0 && ticks[0] > min )
  {
      if ( ticks.first() > min )
          ticks.prepend(min);
      if ( ticks.last() < max )
          ticks.append(max);
  }
  scaleDiv.setTicks(QwtScaleDiv::MajorTick, ticks);
  knob_->setScale(scaleDiv);

  knob_->setKnobWidth(150);
  knob_->setStep(step);

  spin_ = new QDoubleSpinBox(this);
  spin_->setRange(min, max);
  spin_->setSingleStep(step);

  font.setBold(true);
  label_ = new QLabel(title, this);
  label_->setFont(font);
  label_->setAlignment(Qt::AlignTop | Qt::AlignHCenter);

  setSizePolicy(QSizePolicy::MinimumExpanding,
      QSizePolicy::MinimumExpanding);

  connect(spin_, SIGNAL(valueChanged(double)),
          this, SIGNAL(valueChanged(double)));

  connect(knob_, SIGNAL(valueChanged(double)),
          spin_, SLOT(setValue(double)) );
  connect(spin_, SIGNAL(valueChanged(double)),
          knob_, SLOT(setValue(double)) );
}
开发者ID:hribarjernej89,项目名称:iris_modules,代码行数:44,代码来源:KnobSpin.cpp

示例12: setupModelData

void TreeModel::setupModelData(const QStringList &lines, TreeItem *parent)
{
    QList<TreeItem*> parents;
    QList<int> indentations;
    parents << parent;
    indentations << 0;

    int number = 0;

    while (number < lines.count()) {
        int position = 0;
        while (position < lines[number].length()) {
            if (lines[number].at(position) != ' ')
                break;
            ++position;
        }

        QString lineData = lines[number].mid(position).trimmed();

        if (!lineData.isEmpty()) {
            // Read the column data from the rest of the line.
            QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
            QVector<QVariant> columnData;
            for (int column = 0; column < columnStrings.count(); ++column)
                columnData << columnStrings[column];

            if (position > indentations.last()) {
                // The last child of the current parent is now the new parent
                // unless the current parent has no children.

                if (parents.last()->childCount() > 0) {
                    parents << parents.last()->child(parents.last()->childCount()-1);
                    indentations << position;
                }
            } else {
                while (position < indentations.last() && parents.count() > 0) {
                    parents.pop_back();
                    indentations.pop_back();
                }
            }

            // Append a new item to the current parent's list of children.
            TreeItem *parent = parents.last();
            parent->insertChildren(parent->childCount(), 1, rootItem->columnCount());
            for (int column = 0; column < columnData.size(); ++column)
                parent->child(parent->childCount() - 1)->setData(column, columnData[column]);
        }

        ++number;
    }
}
开发者ID:jiwaharlal,项目名称:cpp_experience,代码行数:51,代码来源:TreeModel.cpp

示例13: getFeatureAttributes

bool QgsComposerTextTable::getFeatureAttributes( QList<QgsAttributeMap>& attributeMaps )
{
  attributeMaps.clear();

  QList< QStringList >::const_iterator rowIt = mRowText.constBegin();
  QStringList currentStringList;
  for ( ; rowIt != mRowText.constEnd(); ++rowIt )
  {
    currentStringList = *rowIt;

    attributeMaps.push_back( QgsAttributeMap() );
    for ( int i = 0; i < currentStringList.size(); ++i )
    {
      attributeMaps.last().insert( i, QVariant( currentStringList.at( i ) ) );
    }
  }

  return true;
}
开发者ID:AaronGaim,项目名称:QGIS,代码行数:19,代码来源:qgscomposertexttable.cpp

示例14:

// first use RideFile::startTime, then Measure then fallback to Global Setting
static double
getWeight(const MainWindow *main, const RideFile *ride)
{
    // ride
    double weight;
    if ((weight = ride->getTag("Weight", "0.0").toDouble()) > 0) {
        return weight;
    }
#if 0
    // withings?
    QList<SummaryMetrics> measures = main->metricDB->getAllMeasuresFor(QDateTime::fromString("Jan 1 00:00:00 1900"), ride->startTime());
    if (measures.count()) {
        return measures.last().getText("Weight", "0.0").toDouble();
    }
#endif

    // global options
    return appsettings->cvalue(main->cyclist, GC_WEIGHT, "75.0").toString().toDouble(); // default to 75kg
}
开发者ID:g3rg,项目名称:GoldenCheetah,代码行数:20,代码来源:WattsPerKilogram.cpp

示例15: readFiles

void QHelpProjectDataPrivate::readFiles()
{
	while (!atEnd()) {
		readNext();
		if (isStartElement()) {
			if (name() == QLatin1String("file"))
                filterSectionList.last().addFile(readElementText());
			else
				raiseUnknownTokenError();
		} else if (isEndElement()) {
			if (name() == QLatin1String("file"))
				continue;
			else if (name() == QLatin1String("files"))
				break;
			else
				raiseUnknownTokenError();
		}
	}
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:19,代码来源:qhelpprojectdata.cpp


注:本文中的QList::last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。