本文整理汇总了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");
}
示例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;
}
示例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());
}
示例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++;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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)) );
}
示例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;
}
}
示例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;
}
示例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
}
示例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();
}
}
}