本文整理汇总了C++中QValueStack::push方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueStack::push方法的具体用法?C++ QValueStack::push怎么用?C++ QValueStack::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueStack
的用法示例。
在下文中一共展示了QValueStack::push方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populateProject
void AntProjectPart::populateProject()
{
QApplication::setOverrideCursor(Qt::waitCursor);
QValueStack<QString> s;
int prefixlen = m_projectDirectory.length()+1;
s.push(m_projectDirectory);
QDir dir;
do
{
dir.setPath(s.pop());
kdDebug() << "Examining: " << dir.path() << endl;
const QFileInfoList *dirEntries = dir.entryInfoList();
QPtrListIterator<QFileInfo> it(*dirEntries);
for (; it.current(); ++it)
{
QString fileName = it.current()->fileName();
if (fileName == "." || fileName == "..")
continue;
QString path = it.current()->absFilePath();
if (it.current()->isDir())
{
kdDebug() << "Pushing: " << path << endl;
s.push(path);
}
else
{
kdDebug() << "Adding: " << path << endl;
m_sourceFiles.append(path.mid(prefixlen));
}
}
}
while (!s.isEmpty());
QApplication::restoreOverrideCursor();
}
示例2: parse
/**
\internal
*/
bool GetOpt::parse( bool untilFirstSwitchOnly )
{
// qDebug( "parse(%s)", args.join( QString( "," ) ).ascii() );
// push all arguments as we got them on a stack
// more pushes might following when parsing condensed arguments
// like --key=value.
QValueStack<QString> stack;
{
QStringList::const_iterator it = args.fromLast();
const QStringList::const_iterator end = args.end();
while ( it != end ) {
stack.push( *it );
--it;
}
}
const OptionConstIterator obegin = options.begin();
const OptionConstIterator oend = options.end();
enum { StartState, ExpectingState, OptionalState } state = StartState;
Option currOpt;
enum TokenType { LongOpt, ShortOpt, Arg, End } t, currType = End;
bool extraLoop = true; // we'll do an extra round. fake an End argument
while ( !stack.isEmpty() || extraLoop ) {
QString a;
QString origA;
// identify argument type
if ( !stack.isEmpty() ) {
a = stack.pop();
currArg++;
origA = a;
// qDebug( "popped %s", a.ascii() );
if ( a.startsWith( QString::fromLatin1( "--" ) ) ) {
// recognized long option
a = a.mid( 2 );
if ( a.isEmpty() ) {
qWarning( "'--' feature not supported, yet" );
exit( 2 );
}
t = LongOpt;
// split key=value style arguments
int equal = a.find( '=' );
if ( equal >= 0 ) {
stack.push( a.mid( equal + 1 ) );
currArg--;
a = a.left( equal );
}
} else if ( a.length() == 1 ) {
t = Arg;
} else if ( a[0] == '-' ) {
#if 0 // compat mode for -long style options
if ( a.length() == 2 ) {
t = ShortOpt;
a = a[1];
} else {
a = a.mid( 1 );
t = LongOpt;
// split key=value style arguments
int equal = a.find( '=' );
if ( equal >= 0 ) {
stack.push( a.mid( equal + 1 ) );
currArg--;
a = a.left( equal );
}
}
#else
// short option
t = ShortOpt;
// followed by an argument ? push it for later processing.
if ( a.length() > 2 ) {
stack.push( a.mid( 2 ) );
currArg--;
}
a = a[1];
#endif
} else {
t = Arg;
}
} else {
// faked closing argument
t = End;
}
// look up among known list of options
Option opt;
if ( t != End ) {
OptionConstIterator oit = obegin;
while ( oit != oend ) {
const Option &o = *oit;
if ( ( t == LongOpt && a == o.lname ) || // ### check state
( t == ShortOpt && a[0].unicode() == o.sname ) ) {
opt = o;
break;
}
++oit;
}
if ( t == LongOpt && opt.type == OUnknown ) {
if ( currOpt.type != OVarLen ) {
qWarning( "Unknown option --%s", a.ascii() );
//.........这里部分代码省略.........
示例3: printRange
// Print a range of lines to a printer.
int QsciPrinter::printRange(QsciScintillaBase *qsb, int from, int to)
{
// Sanity check.
if (!qsb)
return false;
// Setup the printing area.
QRect def_area;
def_area.setX(0);
def_area.setY(0);
QPaintDeviceMetrics metrics(this);
def_area.setWidth(metrics.width());
def_area.setHeight(metrics.height());
// Get the page range.
int pgFrom, pgTo;
pgFrom = fromPage();
pgTo = toPage();
// Find the position range.
long startPos, endPos;
endPos = qsb->SendScintilla(QsciScintillaBase::SCI_GETLENGTH);
startPos = (from > 0 ? qsb -> SendScintilla(QsciScintillaBase::SCI_POSITIONFROMLINE,from) : 0);
if (to >= 0)
{
long toPos = qsb -> SendScintilla(QsciScintillaBase::SCI_POSITIONFROMLINE,to + 1);
if (endPos > toPos)
endPos = toPos;
}
if (startPos >= endPos)
return false;
QPainter painter(this);
bool reverse = (pageOrder() == LastPageFirst);
bool needNewPage = false;
qsb -> SendScintilla(QsciScintillaBase::SCI_SETPRINTMAGNIFICATION,mag);
qsb -> SendScintilla(QsciScintillaBase::SCI_SETPRINTWRAPMODE,wrap);
for (int i = 1; i <= numCopies(); ++i)
{
// If we are printing in reverse page order then remember the start
// position of each page.
QValueStack<long> pageStarts;
int currPage = 1;
long pos = startPos;
while (pos < endPos)
{
// See if we have finished the requested page range.
if (pgTo > 0 && pgTo < currPage)
break;
// See if we are going to render this page, or just see how much
// would fit onto it.
bool render = false;
if (pgFrom == 0 || pgFrom <= currPage)
{
if (reverse)
pageStarts.push(pos);
else
{
render = true;
if (needNewPage)
{
if (!newPage())
return false;
}
else
needNewPage = true;
}
}
QRect area = def_area;
formatPage(painter,render,area,currPage);
pos = qsb -> SendScintilla(QsciScintillaBase::SCI_FORMATRANGE,render,&painter,area,pos,endPos);
++currPage;
}
// All done if we are printing in normal page order.
if (!reverse)
continue;
// Now go through each page on the stack and really print it.
while (!pageStarts.isEmpty())
{
//.........这里部分代码省略.........
示例4: getToken
//.........这里部分代码省略.........
return Tok_Ident;
} else {
switch ( yyCh ) {
case '#':
/*
Early versions of lupdate complained about
unbalanced braces in the following code:
#ifdef ALPHA
while ( beta ) {
#else
while ( gamma ) {
#endif
delta;
}
The code contains, indeed, two opening braces for
one closing brace; yet there's no reason to panic.
The solution is to remember yyBraceDepth as it was
when #if, #ifdef or #ifndef was met, and to set
yyBraceDepth to that value when meeting #elif or
#else.
*/
do {
yyCh = getChar();
} while ( isspace(yyCh) && yyCh != '\n' );
switch ( yyCh ) {
case 'i':
yyCh = getChar();
if ( yyCh == 'f' ) {
// if, ifdef, ifndef
yySavedBraceDepth.push( yyBraceDepth );
yySavedParenDepth.push( yyParenDepth );
}
break;
case 'e':
yyCh = getChar();
if ( yyCh == 'l' ) {
// elif, else
if ( !yySavedBraceDepth.isEmpty() ) {
yyBraceDepth = yySavedBraceDepth.top();
yyParenDepth = yySavedParenDepth.top();
}
} else if ( yyCh == 'n' ) {
// endif
if ( !yySavedBraceDepth.isEmpty() ) {
yySavedBraceDepth.pop();
yySavedParenDepth.pop();
}
}
}
while ( isalnum(yyCh) || yyCh == '_' )
yyCh = getChar();
break;
case '/':
yyCh = getChar();
if ( yyCh == '/' ) {
do {
yyCh = getChar();
} while ( yyCh != EOF && yyCh != '\n' );
} else if ( yyCh == '*' ) {
bool metAster = FALSE;
bool metAsterSlash = FALSE;
示例5: paintData
//.........这里部分代码省略.........
if( data->cellCoord( dataset, value, vValY, 1 ) &&
QVariant::Double == vValY.type() ){
_startAngles[ value ] = currentValue;
const double cellValue = fabs( vValY.toDouble() );
_angleLens[ value ] = ( int ) floor( cellValue * sectorsPerValue + 0.5 );
atLeastOneValue = true;
} else { // mark as non-existent
_angleLens[ value ] = 0;
if ( value > 0 )
_startAngles[ value ] = _startAngles[ value - 1 ];
else
_startAngles[ value ] = currentValue;
}
currentValue = _startAngles[ value ] + _angleLens[ value ];
}
// If there was no value at all, bail out, to avoid endless loops
// later on (e.g. in findPieAt()).
if( !atLeastOneValue )
return;
// Find the backmost pie which is at +90° and needs to be drawn
// first
int backmostpie = findPieAt( 90 * 16 );
// Find the frontmost pie (at -90°/+270°) that should be drawn last
int frontmostpie = findPieAt( 270 * 16 );
// and put the backmost pie on the TODO stack to initialize it,
// but only if it is not the frontmostpie
QValueStack < int > todostack;
if ( backmostpie != frontmostpie )
todostack.push( backmostpie );
else {
// Otherwise, try to find something else
int leftOfCurrent = findLeftPie( backmostpie );
if ( leftOfCurrent != frontmostpie ) {
todostack.push( leftOfCurrent );
} else {
int rightOfCurrent = findRightPie( backmostpie );
if ( rightOfCurrent != frontmostpie ) {
todostack.push( rightOfCurrent );
}
}
// If we get here, there was nothing else, and we will bail
// out of the while loop below.
}
// The list with pies that have already been drawn
QValueList < int > donelist;
// Draw pies until the todostack is empty or only the frontmost
// pie is there
while ( !todostack.isEmpty() &&
!( ( todostack.count() == 1 ) &&
( ( todostack.top() == frontmostpie ) ) ) ) {
// The while loop cannot be cancelled if frontmostpie is on
// top of the stack, but this is also backmostpie (can happen
// when one of the pies covers more than 1/2 of the circle. In
// this case, we need to find something else to put on the
// stack to get things going.
// take one pie from the stack
int currentpie = todostack.pop();