本文整理汇总了C++中QStack::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ QStack::push_back方法的具体用法?C++ QStack::push_back怎么用?C++ QStack::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStack
的用法示例。
在下文中一共展示了QStack::push_back方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort
void PGE_Menu::sort()
{
if(_items.size()<=1) {
autoOffset(); //Nothing to sort!
return;
}
QStack<int> beg;
QStack<int> end;
PGE_Menuitem * piv;
int i=0, L, R, swapv;
beg.push_back(0);
end.push_back(_items.size());
while (i>=0)
{
L=beg[i];
R=end[i]-1;
if (L<R)
{
piv=_items[L];
while (L<R)
{
while ((namefileMoreThan(_items[R], piv)) && (L<R)) R--;
if (L<R) _items[L++]=_items[R];
while ((namefileLessThan(_items[L], piv)) && (L<R)) L++;
if (L<R) _items[R--]=_items[L];
}
_items[L]=piv;
beg.push_back(L+1);
end.push_back(end[i]);
end[i++]=(L);
if((end[i]-beg[i]) > (end[i-1]-beg[i-1]))
{
swapv=beg[i];
beg[i]=beg[i-1];
beg[i-1]=swapv;
swapv=end[i];
end[i]=end[i-1];
end[i-1]=swapv;
}
}
else
{
i--;
beg.pop_back();
end.pop_back();
}
}
autoOffset();
}
示例2: cur
void KoTextWriter::Private::writeBlocks(QTextDocument *document, int from, int to, QHash<QTextList *, QString> &listStyles, QTextTable *currentTable, QTextList *currentList)
{
pairedInlineObjectsStackStack.push(currentPairedInlineObjectsStack);
currentPairedInlineObjectsStack = new QStack<KoInlineObject*>();
QTextBlock block = document->findBlock(from);
// Here we are going to detect all sections that
// are positioned entirely inside selection.
// They will stay untouched, and others will be omitted.
// So we are using stack to detect them, by going through
// the selection and finding open/close pairs.
QSet<QString> entireWithinSectionNames;
QStack<QString> sectionNamesStack;
QTextCursor cur(document);
cur.setPosition(from);
while (to == -1 || cur.position() <= to) {
if (cur.block().position() >= from) { // Begin of the block is inside selection.
foreach (const KoSection *sec, KoSectionUtils::sectionStartings(cur.blockFormat())) {
sectionNamesStack.push_back(sec->name());
}
}
if (to == -1 || cur.block().position() + cur.block().length() - 1 <= to) { // End of the block is inside selection.
foreach (const KoSectionEnd *sec, KoSectionUtils::sectionEndings(cur.blockFormat())) {
if (!sectionNamesStack.empty() && sectionNamesStack.top() == sec->name()) {
sectionNamesStack.pop();
entireWithinSectionNames.insert(sec->name());
}
}
}
示例3: sortElements
void PGE_LevelCamera::sortElements()
{
if(objects_to_render.size()<=1) return; //Nothing to sort!
QStack<int> beg;
QStack<int> end;
PGE_Phys_Object* piv;
int i=0, L, R, swapv;
beg.push_back(0);
end.push_back(objects_to_render.size());
while (i>=0)
{
L=beg[i]; R=end[i]-1;
if (L<R)
{
piv=objects_to_render[L];
while (L<R)
{
while ((objects_to_render[R]->zIndex()>=piv->zIndex()) && (L<R)) R--;
if (L<R) objects_to_render[L++]=objects_to_render[R];
while ((objects_to_render[L]->zIndex()<=piv->zIndex()) && (L<R)) L++;
if (L<R) objects_to_render[R--]=objects_to_render[L];
}
objects_to_render[L]=piv; beg.push_back(L+1); end.push_back(end[i]); end[i++]=(L);
if((end[i]-beg[i]) > (end[i-1]-beg[i-1]))
{
swapv=beg[i]; beg[i]=beg[i-1]; beg[i-1]=swapv;
swapv=end[i]; end[i]=end[i-1]; end[i-1]=swapv;
}
}
else
{
i--;
beg.pop_back();
end.pop_back();
}
}
}
示例4: pushContext
void XLIFFHandler::pushContext(XliffContext ctx)
{
m_contextStack.push_back(ctx);
}
示例5: run
void FileIndexThread::run()
{
struct PathToIndex
{
QString path;
bool recursive;
QStringList filter;
};
#ifdef Q_OS_UNIX
static const QList<PathToIndex> pathsToIndex = {
{ "/usr/share/applications", true, { "*.desktop" } },
{ QDir(QDir::homePath()).relativeFilePath(".local/share/applications"), true, { "*.desktop" } },
{ QDir(QDir::homePath()).relativeFilePath("Desktop"), true, { "*.desktop" } },
};
#elif defined(Q_OS_WIN)
QList<PathToIndex> pathsToIndex = {
{ QSettings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", QSettings::NativeFormat).value("Common Desktop").toString(), true, { "*.lnk" } },
{ QSettings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", QSettings::NativeFormat).value("Common Start Menu").toString(), true, { "*.lnk" } },
};
{
// There are newer API functions for this; but they are only for Vista and newer
WCHAR szPath[MAX_PATH];
HRESULT hr = SHGetFolderPathW(0, CSIDL_STARTMENU, 0, 0, szPath);
if (SUCCEEDED(hr))
pathsToIndex.push_back({ QString::fromWCharArray(szPath), true, { "*.lnk" } });
hr = SHGetFolderPathW(0, CSIDL_DESKTOPDIRECTORY, 0, 0, szPath);
if (SUCCEEDED(hr))
pathsToIndex.push_back({ QString::fromWCharArray(szPath), true, { "*.lnk" } });
}
#else
#error "Not implemented for this operating system"
#endif
for (const PathToIndex& pathInfo : pathsToIndex)
{
const QString pathString = expandEnvironmentPath(pathInfo.path);
QStack<QString> dirstack;
dirstack.push_back(expandEnvironmentPath(pathString));
while (dirstack.empty() == false)
{
QDir path(dirstack.pop());
path.setNameFilters(pathInfo.filter);
for (const QString& filename : path.entryList())
{
int dot = filename.lastIndexOf('.');
const QString basename = dot > 0 ? filename.left(dot) : filename;
dbLock.lockForWrite();
this->db.add(basename, basename, path.absoluteFilePath(filename), QStringList());
dbLock.unlock();
}
// For now, no symlink traversal to avoid loops
for (const QString& dirname : path.entryList(QStringList(), QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot))
{
dirstack.push_back(path.absoluteFilePath(dirname));
}
}
}
#ifdef Q_OS_WIN
const QString systemPath = getWindowsSystemPath();
for (const QString& filename : QDir(systemPath).entryList({ "*.cpl" }))
{
readCpl(filename, this->db, this->dbLock);
}
#endif
emit indexDone();
}
示例6: parse
bool SimpleJsonParser::parse(const QByteArray& json)
{
resetState();
m_source = json;
m_ptr = m_source.data();
m_end = m_ptr + m_source.length();
QStack<QString> stack;
QVariantMap result;
QVector<Token> expectedTokens;
expectedTokens.push_back(Token_Begin);
Token prevToken = Token_ERROR;
QString lastStr;
QString prefix;
QString lastKey;
for (;;) {
Token token = nextToken();
if (expectedTokens.indexOf(token) < 0) {
DBGLOG(LOG_ERROR, 2, QString::fromUtf8("unexpected token %1").arg(token));
return false;
}
switch (token) {
case Token_ERROR:
return false;
case Token_EOF:
if (!stack.empty()) {
DBGLOG(LOG_ERROR, 2, QString::fromUtf8("unblanced { }, bad json!"));
return false;
}
m_result = result;
return true;
case Token_Begin:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token BEGIN"));
if (stack.empty()) {
stack.push_back(QString::fromUtf8(""));
} else {
stack.push_back(prefix);
prefix.append(lastKey);
prefix.append(QChar::fromAscii('.'));
}
expectedTokens.clear();
expectedTokens.push_back(Token_End);
expectedTokens.push_back(Token_String);
break;
case Token_End:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token END"));
prefix = stack.pop();
if (!stack.empty()) {
expectedTokens.clear();
expectedTokens.push_back(Token_Comma);
expectedTokens.push_back(Token_End);
} else {
expectedTokens.push_back(Token_EOF);
}
break;
case Token_Comma:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token COMMA"));
expectedTokens.clear();
expectedTokens.push_back(Token_End);
expectedTokens.push_back(Token_String);
break;
case Token_Colon:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token COLON"));
expectedTokens.clear();
expectedTokens.push_back(Token_Begin);
expectedTokens.push_back(Token_String);
expectedTokens.push_back(Token_Number);
break;
case Token_String:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token STRING [%1]").arg(QString::fromUtf8(m_str)));
if (prevToken == Token_Colon) {
DBGLOG(LOG_DEBUG, 12, QString::fromUtf8("submit '%3%1'='%2'").arg(lastKey).arg(QString::fromUtf8(m_str)).arg(prefix));
result.insert(prefix + lastKey, QString::fromUtf8(m_str));
} else {
lastKey = QString::fromUtf8(m_str);
}
// TODO:
expectedTokens.clear();
expectedTokens.push_back(Token_End);
expectedTokens.push_back(Token_Comma);
expectedTokens.push_back(Token_Colon);
break;
case Token_Number:
DBGLOG(LOG_DEBUG, 8, QString::fromUtf8("token NUMBER [%1]").arg(m_num));
DBGLOG(LOG_DEBUG, 12, QString::fromUtf8("submit '%3%1'=%2").arg(lastKey).arg(m_num).arg(prefix));
result.insert(prefix + lastKey, m_num);
expectedTokens.clear();
expectedTokens.push_back(Token_End);
expectedTokens.push_back(Token_Comma);
break;
}
prevToken = token;
}
//.........这里部分代码省略.........