本文整理汇总了C++中QValueStack类的典型用法代码示例。如果您正苦于以下问题:C++ QValueStack类的具体用法?C++ QValueStack怎么用?C++ QValueStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QValueStack类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isLast
bool QExp::isLast(QValueStack<char> opr){
int ins=0;
bool b=true;
while(b && !opr.empty()){
if(opr.top()==tLpr){
if(ins == 0)
b= true;
else
ins--;
} else if(opr.top()==tLpr)
ins++;
else if(opr.top()==tComa)
b= false;
else if(opr.top()==tEof)
b= false;
opr.pop();
}
return b;
}
示例3: 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() );
//.........这里部分代码省略.........
示例4: metrics
// 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())
{
//.........这里部分代码省略.........
示例5: ourClipRect
//.........这里部分代码省略.........
// is there anything at all at this value
/* see above for meaning of 16 */
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.
示例6: startTokenizer
static void startTokenizer( const char *fileName, int (*getCharFunc)() )
{
yyInPos = 0;
getChar = getCharFunc;
yyFileName = fileName;
yyCh = getChar();
yySavedBraceDepth.clear();
yySavedParenDepth.clear();
yyBraceDepth = 0;
yyParenDepth = 0;
yyCurLineNo = 1;
yyBraceLineNo = 1;
yyParenLineNo = 1;
}
示例7: getToken
static int getToken()
{
const char tab[] = "abfnrtv";
const char backTab[] = "\a\b\f\n\r\t\v";
uint n;
yyIdentLen = 0;
yyCommentLen = 0;
yyStringLen = 0;
while ( yyCh != EOF ) {
yyLineNo = yyCurLineNo;
if ( isalpha(yyCh) || yyCh == '_' ) {
do {
if ( yyIdentLen < sizeof(yyIdent) - 1 )
yyIdent[yyIdentLen++] = (char) yyCh;
yyCh = getChar();
} while ( isalnum(yyCh) || yyCh == '_' );
yyIdent[yyIdentLen] = '\0';
switch ( yyIdent[0] ) {
case 'Q':
if ( strcmp(yyIdent + 1, "_OBJECT") == 0 ) {
return Tok_Q_OBJECT;
} else if ( strcmp(yyIdent + 1, "T_TR_NOOP") == 0 ) {
return Tok_tr;
} else if ( strcmp(yyIdent + 1, "T_TRANSLATE_NOOP") == 0 ) {
return Tok_translate;
}
break;
case 'T':
// TR() for when all else fails
if ( qstricmp(yyIdent + 1, "R") == 0 )
return Tok_tr;
break;
case 'c':
if ( strcmp(yyIdent + 1, "lass") == 0 )
return Tok_class;
break;
case 'f':
/*
QTranslator::findMessage() has the same parameters as
QApplication::translate().
*/
if ( strcmp(yyIdent + 1, "indMessage") == 0 )
return Tok_translate;
break;
case 'i':
/* FOR KDE APPS */
if ( strcmp( yyIdent + 1, "8n") == 0 )
return Tok_translate;
break;
case 'n':
if ( strcmp(yyIdent + 1, "amespace") == 0 )
return Tok_namespace;
break;
case 'r':
if ( strcmp(yyIdent + 1, "eturn") == 0 )
return Tok_return;
break;
case 's':
if ( strcmp(yyIdent + 1, "truct") == 0 )
return Tok_class;
break;
case 't':
if ( strcmp(yyIdent + 1, "r") == 0 ) {
return Tok_tr;
} else if ( qstrcmp(yyIdent + 1, "rUtf8") == 0 ) {
return Tok_trUtf8;
} else if ( qstrcmp(yyIdent + 1, "ranslate") == 0 ) {
return Tok_translate;
}
}
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();
//.........这里部分代码省略.........