本文整理汇总了C++中QVector::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::empty方法的具体用法?C++ QVector::empty怎么用?C++ QVector::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
// HELPER
void process(Mesh& mesh,
QStringList& vList,
QVector<QVector3D>& verts,
QVector<QVector2D>& texCords,
QVector<QVector3D>& normals)
{
int vertPosition = vList[0].toInt() - 1; // obj file index starts at '1'
mesh.indices().append(vertPosition);
int texPosition = 0;
int normalPosition = 0;
if (!texCords.empty())
{
// obj texture starts (0,0)->left bottom corner
// opengl starts (0,0)->left top corner
texPosition = vList[1].toInt() - 1;
mesh.uvs()[vertPosition].setX(texCords[texPosition].x());
mesh.uvs()[vertPosition].setY(1.0 - texCords[texPosition].y());
}
if (!normals.empty())
{
normalPosition = vList[2].toInt() - 1;
mesh.normals()[vertPosition] = normals[normalPosition];
}
}
示例2: parse
QVector<DkPackage> DkXmlUpdateChecker::updatesAvailable(QXmlStreamReader& localXml, QXmlStreamReader& remoteXml) const {
QVector<DkPackage> localPackages = parse(localXml);
QVector<DkPackage> remotePackages = parse(remoteXml);
QVector<DkPackage> updatePackages;
for (const DkPackage& p : localPackages) {
int idx = remotePackages.indexOf(p);
if (idx != -1) {
bool isEqual = remotePackages[idx].version() == p.version();
qDebug() << "checking" << p.name() << "v" << p.version();
if (!isEqual) // we assume that the remote is _always_ newer than the local version
updatePackages.append(remotePackages[idx]);
else
qDebug() << "up-to-date";
}
else
qDebug() << "I could not find" << p.name() << "in the repository";
}
if (localPackages.empty() || remotePackages.empty())
qDebug() << "WARNING: I could not find any packages. local (" << localPackages.size() << ") remote (" << remotePackages.size() << ")";
return updatePackages;
}
示例3: replaceRareColors
dockListUpdate mutableSquareImageContainer::replaceRareColors() {
QHash<QRgb, int> countHash;
::colorCounts(image_, originalDimension_, &countHash);
rareColorsDialog countDialog(countHash);
const int dialogReturnCode = countDialog.exec();
QList<QRgbPair> pairs = countDialog.colorsToChange();
if (dialogReturnCode == QDialog::Accepted && pairs.size() > 0) {
QList<colorChange> changeHistories;
QSet<flossColor> oldFloss;
QVector<triC> oldColors;
for (int i = 0, size = pairs.size(); i < size; ++i) {
const QRgb oldColor = pairs[i].first;
const triC oldTriColor(oldColor);
oldColors.push_back(oldTriColor);
oldFloss.insert(getFlossColorFromColor(oldTriColor));
const QRgb newColor = pairs[i].second;
const QVector<pairOfInts> changedSquares =
::changeColor(&image_, oldColor, newColor, originalDimension_);
if (!changedSquares.empty()) {
removeColor(oldColor);
changeHistories.push_back(colorChange(oldColor, newColor,
changedSquares));
}
}
addToHistory(historyItemPtr(new rareColorsHistoryItem(changeHistories,
oldFloss)));
return dockListUpdate(oldColors, true);
}
else {
return dockListUpdate();
}
}
示例4: squareImageContainer
mutableSquareImageContainer::mutableSquareImageContainer(const QString& name,
const QVector<triC>& colors,
const QImage& image,
int dimension, flossType type)
: squareImageContainer(name, image.size(), type), image_(image),
toolFlossType_(flossVariable), originalDimension_(dimension),
widthSquareCount_(image.width()/dimension),
heightSquareCount_(image.height()/dimension),
colorListCheckNeeded_(false) {
if ((!colors.empty()) &&
colors.size() <= symbolChooser::maxNumberOfSymbols()) {
valid_ = true;
invalidColorCount_ = 0;
for (int i = 0, size = colors.size(); i < size; ++i) {
flossColors_.push_back(flossColor(colors[i], type));
}
}
else {
valid_ = false;
invalidColorCount_ = colors.size();
flossColors_ = QVector<flossColor>();
}
squareImageContainer::setScaledSize(QSize(0, 0));
}
示例5: boundingBoxFromPointList
bool QgsVectorLayerEditUtils::boundingBoxFromPointList( const QVector<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const
{
if ( list.empty() )
{
return false;
}
xmin = std::numeric_limits<double>::max();
xmax = -std::numeric_limits<double>::max();
ymin = std::numeric_limits<double>::max();
ymax = -std::numeric_limits<double>::max();
for ( QVector<QgsPointXY>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
{
if ( it->x() < xmin )
{
xmin = it->x();
}
if ( it->x() > xmax )
{
xmax = it->x();
}
if ( it->y() < ymin )
{
ymin = it->y();
}
if ( it->y() > ymax )
{
ymax = it->y();
}
}
return true;
}
示例6: tp
static void tp(int p, int s, BS &b) {
if (!b.isOut(s)) {
return;
}
int berry = b.poke(s).item();
QVector<int> stats;
for (int i = Attack; i <= Evasion; i++) {
if (fpoke(b,s).boosts[i] < 6) {
stats.push_back(i);
}
}
if (stats.empty())
return;
if (!testpinch(p, s, b, 4, false))
return;
int stat = stats[b.randint(stats.size())];
if (b.hasWorkingAbility(s, Ability::Contrary)) {
b.sendBerryMessage(9,s,1,s, berry, stat);
} else {
b.sendBerryMessage(9,s,0,s, berry, stat);
}
b.inflictStatMod(s, stat, 2, s, false);
}
示例7: performProcessing
triState numColorsBaseModes::performProcessing(QImage* image, int numColors,
int numImageColors) {
colorTransformerPtr transformer =
colorTransformer::createColorTransformer(flossMode());
QVector<triC> newColors = ::chooseColors(*image, numColors,
clickedColorList(),
numImageColors,
transformer);
if (!newColors.empty()) {
// remove the seed colors from newColors to create generatedColors
const QVector<triC>& seedColors = clickedColorList();
QVector<triC> generatedColors = newColors;
for (int i = 0, size = seedColors.size(); i < size; ++i) {
generatedColors.remove(generatedColors.indexOf(seedColors[i]));
}
setGeneratedColorList(generatedColors);
}
else {
return triNoop;
}
if (!::segment(image, newColors, numImageColors).empty()) {
//return triState(colorList().size() != savedColorsSize);
return triTrue;
}
else {
return triNoop;
}
}
示例8: onDeleteClicked
void ProfileForm::onDeleteClicked()
{
if (GUI::askQuestion(tr("Really delete profile?", "deletion confirmation title"),
tr("Are you sure you want to delete this profile?",
"deletion confirmation text"))) {
Nexus& nexus = Nexus::getInstance();
QVector<QString> manualDeleteFiles = nexus.getProfile()->remove();
if (!manualDeleteFiles.empty()) {
QString message =
tr("The following files could not be deleted:", "deletion failed text part 1") + "\n\n";
for (auto& file : manualDeleteFiles) {
message = message + file + "\n";
}
message =
message + "\n" + tr("Please manually remove them.", "deletion failed text part 2");
GUI::showError(tr("Files could not be deleted!", "deletion failed title"), message);
}
nexus.showLoginLater();
}
}
示例9: locker
bool
EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
{
QReadLocker locker(&m_lock);
QVector<float> sample;
QVector<int> n;
for (int i = 0; i < 10; ++i) {
size_t index = i * 10;
if (index < m_data.size()) {
const Column &c = m_data.at(index);
while (c.size() > sample.size()) {
sample.push_back(0.f);
n.push_back(0);
}
for (int j = 0; j < c.size(); ++j) {
sample[j] += c.at(j);
++n[j];
}
}
}
if (sample.empty()) return false;
for (int j = 0; j < sample.size(); ++j) {
if (n[j]) sample[j] /= n[j];
}
return LogRange::useLogScale(sample.toStdVector());
}
示例10: findFirstCorrectBeat
double BeatUtils::findFirstCorrectBeat(const QVector<double> rawbeats,
const int SampleRate, const double global_bpm) {
for (int i = N; i < rawbeats.size(); i++) {
// get start and end sample of the beats
double start_sample = rawbeats.at(i-N);
double end_sample = rawbeats.at(i);
// The time in seconds represented by this sample range.
double time = (end_sample - start_sample)/SampleRate;
// Average BPM within this sample range.
double avg_bpm = 60.0 * N / time;
//qDebug() << "Local BPM between beat " << (i-N) << " and " << i << " is " << avg_bpm;
// If the local BPM is within kCorrectBeatLocalBpmEpsilon of the global
// BPM then use this window as the first beat.
if (fabs(global_bpm - avg_bpm) <= kCorrectBeatLocalBpmEpsilon) {
//qDebug() << "Using beat " << (i-N) << " as first beat";
return start_sample;
}
}
// If we didn't find any beat that matched the window, return the first
// beat.
return !rawbeats.empty() ? rawbeats.first() : 0.0;
}
示例11: checkCategories
///-------------------------------------------------------------
bool CXMLAnalyser::checkCategories( const QVector< int > &categoriesToCheck )
///-------------------------------------------------------------
{
bool isOkay = true;
if ( false == categoriesToCheck.empty( ) )
{
QVector< int >::const_iterator current = categoriesToCheck.begin( );
QVector< int >::const_iterator end = categoriesToCheck.end( );
while( current != end )
{
if ( false == isInMetaDataCategories( *current ) )
{
isOkay = false;
mLastError = eWrongCategory;
break;
}
++current;
}
}
else
{
isOkay = false;
mLastError = eEmptyCategories;
}
return isOkay;
}
示例12: selectedIndexes
QList<int>* listview_t::get_selectedIndexes()
{//descending
QList<int>* result = new QList<int>;
QVector<int> temp;
QModelIndexList list = selectedIndexes();
QModelIndexList::const_iterator it;
for (it = list.constBegin(); it != list.constEnd(); it++)
temp.push_back(it->row());
if (!temp.empty())
{
for (int j = 0; j < temp.size() - 1; j++)
{
for (int i = 0; i < temp.size() - j - 1; i++)
if (temp[i] > temp[i+1])
{
int tmp = temp[i];
temp[i] = temp[i+1];
temp[i+1] = tmp;
}
result->push_back(temp[temp.size() - j - 1]);
}
result->push_back(temp[0]);
}
return result;
}
示例13: generateCache
// really generate the cache
void ImageView::generateCache() {
// disable the one-shot timer
cacheTimer_->deleteLater();
cacheTimer_ = nullptr;
if(!imageItem_ || image_.isNull()) return;
// generate a cache for "the visible part" of the scaled image
// rectangle of the whole image in viewport coordinate
QRect viewportImageRect = sceneToViewport(imageItem_->rect());
// rect of the image area that's visible in the viewport (in viewport coordinate)
cachedRect_ = viewportImageRect.intersected(viewport()->rect());
// convert to the coordinate of the original image
cachedSceneRect_ = viewportToScene(cachedRect_);
// create a sub image of the visible without real data copy
// Reference: http://stackoverflow.com/questions/12681554/dividing-qimage-to-smaller-pieces
QRect subRect = image_.rect().intersected(cachedSceneRect_);
const uchar* bits = image_.constBits();
unsigned int offset = subRect.x() * image_.depth() / 8 + subRect.y() * image_.bytesPerLine();
QImage subImage = QImage(bits + offset, subRect.width(), subRect.height(), image_.bytesPerLine(), image_.format());
// If the original image has a color table, also use it for the subImage
QVector<QRgb> colorTable = image_.colorTable();
if (!colorTable.empty())
subImage.setColorTable(colorTable);
// QImage scaled = subImage.scaled(subRect.width() * scaleFactor_, subRect.height() * scaleFactor_, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QImage scaled = subImage.scaled(cachedRect_.width(), cachedRect_.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
// convert the cached scaled image to pixmap
cachedPixmap_ = QPixmap::fromImage(scaled);
viewport()->update();
}
示例14: isEmpty
bool GroupExpression::isEmpty(Card* caster, const Event* e) const
{
QVector<Character*>* group = eval(caster, e);
bool empty = group->empty();
delete group;
return empty;
}
示例15: doRemoveSelectedArtworks
/*virtual*/
bool ArtworksViewModel::doRemoveSelectedArtworks() {
LOG_DEBUG << "#";
int count = (int)m_ArtworksList.size();
QVector<int> indicesToRemove;
indicesToRemove.reserve(count);
for (int i = 0; i < count; ++i) {
const MetadataElement &item = m_ArtworksList.at(i);
if (item.isSelected()) {
indicesToRemove.append(i);
}
}
bool anyItemToRemove = !indicesToRemove.empty();
if (anyItemToRemove) {
LOG_INFO << "Removing" << indicesToRemove.size() << "item(s)";
QVector<QPair<int, int> > rangesToRemove;
Helpers::indicesToRanges(indicesToRemove, rangesToRemove);
removeItemsAtIndices(rangesToRemove);
if (m_ArtworksList.empty()) {
emit requestCloseWindow();
}
emit artworksCountChanged();
}
return anyItemToRemove;
}