本文整理汇总了C++中QList::setAutoDelete方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::setAutoDelete方法的具体用法?C++ QList::setAutoDelete怎么用?C++ QList::setAutoDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::setAutoDelete方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setProperty
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
{
QList<CSSProperty> *props = parseProperties(propertyString.unicode(),
propertyString.unicode()+propertyString.length());
if(!props || !props->count())
{
kdDebug( 6080 ) << "no properties returned!" << endl;
return;
}
props->setAutoDelete(false);
unsigned int i = 0;
if(!m_lstValues) {
m_lstValues = new QList<CSSProperty>;
m_lstValues->setAutoDelete( true );
}
while(i < props->count())
{
//kdDebug( 6080 ) << "setting property" << endl;
CSSProperty *prop = props->at(i);
removeProperty(prop->m_id);
m_lstValues->append(prop);
i++;
}
delete props;
if (m_node)
m_node->setChanged(true);
}
示例2: ai
QPoint Reversi::ai(const int player)
{
const int choices[8][8] = {
{100, -100, 50, 30, 30, 50, -100, 100,},
{-100, -100, -50, -50, -50, -50, -100, -100,},
{50, -50, 10, 10, 10, 10, -50, 50,},
{30, -50, 10, 0, 0, 10, -50, 30,},
{30, -50, 10, 0, 0, 10, -50, 30,},
{50, -50, 10, 10, 10, 10, -50, 50,},
{-100, -100, -50, -50, -50, -50, -100, -100,},
{100, -100, 50, 30, 30, 50, -100, 100,},
};
QPointArray spaces = availableSpaces(player);
if (spaces.size() == 0)
return BoardGame::ai(player);
int values[spaces.size()];
for (unsigned int i = 0; i < spaces.size(); i++) {
QPoint p(spaces[i]);
values[i] = choices[p.y()][p.x()] + reversible(p, player) * 5;
}
int max = 0;
for (unsigned int i = 0; i < spaces.size(); i++)
if (values[i] > values[max])
max = i;
QList<int> equals;
equals.setAutoDelete(true);
for (unsigned int i = 0; i < spaces.size(); i++)
if (values[i] == values[max])
equals.append(new int(i));
return spaces[*equals.at(rand() % equals.count())];
}
示例3: config
BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl)
: BackupAndRestoreBase(parent, name, fl)
{
backupList->header()->hide();
restoreList->header()->hide();
locationList->header()->hide();
connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) );
connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) );
connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) );
connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) );
connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) );
connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) );
connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) );
//add directorys for backing up
applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/");
selectItem(applicationSettings);
applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/");
selectItem(applicationSettings);
documents= new QListViewItem(backupList, "Documents", "", "Documents/");
selectItem(documents);
scanForApplicationSettings();
refreshLocations();
refreshBackupLocations();
sourceDirChanged(restoreSource->currentItem());
// Read the list of items to ignore.
QList<QString> dontBackupList;
dontBackupList.setAutoDelete(true);
Config config("BackupAndRestore");
config.setGroup("DontBackup");
int total = config.readNumEntry("Total", 0);
for(int i = 0; i < total; i++)
{
dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), "")));
}
QList<QListViewItem> list;
getAllItems(backupList->firstChild(), list);
for(uint i = 0; i < list.count(); i++)
{
QString text = list.at(i)->text(HEADER_NAME);
for(uint i2 = 0; i2 < dontBackupList.count(); i2++)
{
if(*dontBackupList.at(i2) == text)
{
selectItem(list.at(i));
break;
}
}
}
QPEApplication::showWidget( this );
}
示例4: parseInput
void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf,Entry *root,
bool ,QStrList&)
{
g_thisParser=this;
bool inLine=false;
inputString=fileBuf;
// fprintf(stderr,"\n ============= %s\n ==========\n",fileBuf);
if (strlen(fileName)==0)
{
inLine=true;
}
yyFileName+=fileName;
bool xilinx_ucf=isConstraintFile(yyFileName,".ucf");
bool altera_qsf=isConstraintFile(yyFileName,".qsf");
// support XILINX(ucf) and ALTERA (qsf) file
if (xilinx_ucf)
{
VhdlDocGen::parseUCF(fileBuf,root,yyFileName,FALSE);
return;
}
if (altera_qsf)
{
VhdlDocGen::parseUCF(fileBuf,root,yyFileName,TRUE);
return;
}
libUse.setAutoDelete(true);
yyLineNr=1;
VhdlParser::current_root=root;
VhdlParser::lastCompound=0;
VhdlParser::lastEntity=0;
VhdlParser::currentCompound=0;
VhdlParser::lastEntity=0;
VhdlParser::current=new Entry();
VhdlParser::initEntry(VhdlParser::current);
groupEnterFile(fileName,yyLineNr);
lineParse=new int[200]; // Dimitri: dangerous constant: should be bigger than largest token id in VhdlParserConstants.h
VhdlParserIF::parseVhdlfile(fileBuf,inLine);
delete VhdlParser::current;
VhdlParser::current=0;
if (!inLine)
VhdlParser::mapLibPackage(root);
delete[] lineParse;
yyFileName.resize(0);
libUse.clear();
VhdlDocGen::resetCodeVhdlParserState();
}
示例5: dialogClosed
void Korn::dialogClosed(int ret )
{
QList<KornBox> *list = _optionsDialog->list();
if( _noConfig && !ret) {
ret = KMsgBox::yesNo(0, i18n("korn: no config set"),
i18n("Would you like to restart korn with\n"
"the automatically generated configuration?"),
KMsgBox::QUESTION,
i18n("Yes, Restart"), i18n("No, Exit"));
if( ret == 2 ) {
delete _optionsDialog;
_optionsDialog = 0;
qApp->quit();
return;
}
}
if ( ret ) {
// Here we should compare lists to see if any have
// been deleted. If they have, they should be deleted
// from the config as well.
// NOTE: No such KConfig feature exists as yet. 9/Jun/97
writeOut ( list );
list->setAutoDelete( TRUE );
list->clear();
delete list;
execvp( qApp->argv()[0], qApp->argv() );
}
list->setAutoDelete( TRUE );
list->clear();
delete list;
delete _optionsDialog;
_optionsDialog = 0;
}
示例6: unmarshalUInt
QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s)
{
uint i;
uint count = unmarshalUInt(s);
if (count==NULL_LIST) return 0; // null list
QList<ArgumentList> *result = new QList<ArgumentList>;
result->setAutoDelete(TRUE);
assert(count<1000000);
//printf("unmarshalArgumentLists: %d\n",count);
for (i=0;i<count;i++)
{
result->append(unmarshalArgumentList(s));
}
return result;
}
示例7: unmarshalUInt
QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
{
uint i;
uint count = unmarshalUInt(s);
if (count==NULL_LIST) return 0; // null list
QList<SectionInfo> *result = new QList<SectionInfo>;
result->setAutoDelete(TRUE);
assert(count<1000000);
for (i=0; i<count; i++)
{
QCString label = unmarshalQCString(s);
QCString title = unmarshalQCString(s);
QCString ref = unmarshalQCString(s);
SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
QCString fileName = unmarshalQCString(s);
result->append(new SectionInfo(fileName,label,title,type,ref));
}
return result;
}
示例8: itemList
void KFinder::itemList( QList<KFinderItem> &_list )
{
_list.clear();
QList<KFinderNode> nodeList;
nodeList.setAutoDelete( FALSE );
nodeList.append( finderWin->node );
KFinderNode *n;
KFinderItem *item;
QListIterator<KFinderNode> it(nodeList);
for ( ; it.current(); ++it )
{
n = it.current();
for ( item = n->first(); item != 0L; item = n->next() )
{
_list.append( item );
nodeList.append( item->node() );
}
}
}
示例9: generatePage
void CiteDict::generatePage() const
{
//printf("** CiteDict::generatePage() count=%d\n",m_ordering.count());
// do not generate an empty citations page
if (isEmpty()) return; // nothing to cite
// 1. generate file with markers and citations to OUTPUT_DIRECTORY
QFile f;
QCString outputDir = Config_getString("OUTPUT_DIRECTORY");
QCString citeListFile = outputDir+"/citelist.doc";
f.setName(citeListFile);
if (!f.open(IO_WriteOnly))
{
err("could not open file %s for writing\n",citeListFile.data());
}
FTextStream t(&f);
t << "<!-- BEGIN CITATIONS -->" << endl;
t << "<!--" << endl;
QDictIterator<CiteInfo> it(m_entries);
CiteInfo *ci;
for (it.toFirst();(ci=it.current());++it)
{
t << "\\citation{" << ci->label << "}" << endl;
}
t << "-->" << endl;
t << "<!-- END CITATIONS -->" << endl;
t << "<!-- BEGIN BIBLIOGRAPHY -->" << endl;
t << "<!-- END BIBLIOGRAPHY -->" << endl;
f.close();
// 2. generate bib2xhtml
QCString bib2xhtmlFile = outputDir+"/bib2xhtml.pl";
f.setName(bib2xhtmlFile);
QCString bib2xhtml = bib2xhtml_pl;
if (!f.open(IO_WriteOnly))
{
err("could not open file %s for writing\n",bib2xhtmlFile.data());
}
f.writeBlock(bib2xhtml, bib2xhtml.length());
f.close();
// 3. generate doxygen.bst
QCString doxygenBstFile = outputDir+"/doxygen.bst";
QCString bstData = doxygen_bst;
f.setName(doxygenBstFile);
if (!f.open(IO_WriteOnly))
{
err("could not open file %s for writing\n",doxygenBstFile.data());
}
f.writeBlock(bstData, bstData.length());
f.close();
// 4. for html we just copy the bib files to the output so that
// bibtex can find them without path (bibtex doesn't support path's
// with spaces!)
QList<QCString> tempFiles;
tempFiles.setAutoDelete(TRUE);
QDir thisDir;
if (Config_getBool("GENERATE_HTML"))
{
// copy bib files to the latex output dir
QStrList &citeDataList = Config_getList("CITE_BIB_FILES");
QCString bibOutputDir = outputDir+"/";
QFileInfo fo(bibOutputDir);
const char *bibdata = citeDataList.first();
while (bibdata)
{
QCString bibFile = bibdata;
if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib";
QFileInfo fi(bibFile);
if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath())
{
if (!bibFile.isEmpty())
{
QCString destFile=bibOutputDir+fi.fileName().data();
copyFile(bibFile,destFile);
tempFiles.append(new QCString(destFile));
}
}
else if (!fi.exists())
{
err("bib file %s not found!\n",bibFile.data());
}
bibdata = citeDataList.next();
}
}
QCString oldDir = QDir::currentDirPath().utf8();
QDir::setCurrent(outputDir);
// 5. run bib2xhtml perl script on the generated file which will insert the
// bibliography in citelist.doc
portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+
citeListFile+"\"");
QDir::setCurrent(oldDir);
// 6. read back the file
f.setName(citeListFile);
//.........这里部分代码省略.........
示例10: DoIt
int DoIt(const char* outFile, const char* regFile, const char* maskFile, const char* resultFile,
int mask_x, int mask_y, int mask_size_x, int mask_size_y)
{
// Read maskfile
FILE *mfp = fopen(maskFile, "r");
// FILE *mfp=fopen("/project/geoaida/tmp/mask.pbm","r");
if (!mfp) {
fprintf(stderr, "mask file %s not found\n", maskFile);
return 1;
}
GaMaskImage mask;
mask.read(mfp);
fclose(mfp);
// read regionfile
// QFile rfp("/project/geoaida/tmp/reglist.dest");
QFile rfp(regFile);
if (!rfp.open(IO_ReadOnly)) {
fprintf(stderr, "regionfile %s not founed\n", regFile);
return 1;
}
// Read and process regions
QList < ArgDict > regionList;
regionList.setAutoDelete(true);
MLParser parser(&rfp);
QString keywords[] = { "region", "" };
const MLTagTable nodeTagTable(keywords);
const int TOK_REGION = 1;
int tag;
do {
tag = parser.tag(nodeTagTable);
ArgDict *args;
switch (tag) {
case TOK_REGION:{
args = parser.args();
if (processRegion
(*args, mask, mask_x, mask_y, mask_size_x, mask_size_y))
regionList.append(args);
else
delete args;
break;
}
case -TOK_REGION:
break;
case MLParser::END_OF_FILE:
break;
default:{
args = parser.args();
delete args;
qDebug("Unknown keyword %s in line %d", parser.lasttagstr().latin1(),
parser.lineNumber());
break;
}
}
} while (tag != MLParser::END_OF_FILE);
rfp.close();
// Write labels
if (outFile) {
if (labelImageDict.count() > 1) {
fprintf(stderr, "regionmask: Cannot generate multiple labelfiles\n");
return 1;
}
else {
if (regionList.count()>0) {
ArgDict *dict = regionList.first();
QString *oldfile = (*dict)["file"];
QString *labelfile = new QString();
if (resultFile)
labelfile->sprintf("%s", resultFile);
else
labelfile->sprintf("%s.plm", outFile);
LabelImage *im = labelImageDict.take(*oldfile);
labelImageDict.replace(*labelfile, im);
QListIterator < ArgDict > it(regionList);
for (; it.current(); ++it) {
ArgDict *argDict = it.current();
assert(argDict);
argDict->replace("file", labelfile);
}
}
}
rfp.setName(outFile);
}
else {
printf("regionmask: overwriting %s\n",regFile);
outFile = regFile;
}
QDictIterator < LabelImage > git(labelImageDict);
if (regionList.count()>0) {
for (; git.current(); ++git) {
LabelImage *im = git.current();
qDebug("Writing %s", git.currentKey().latin1());
im->image.write(git.currentKey().latin1());
}
}
// Write regions
if (!rfp.open(IO_WriteOnly)) {
fprintf(stderr, "cannot open regionfile %s for writing\n", outFile);
return 1;
//.........这里部分代码省略.........
示例11: DoIt
int DoIt(const char* outFile, const char* regFile, const char* maskFile, const char* resultFile,
int mask_x, int mask_y, int mask_size_x, int mask_size_y)
{
// Read maskfile
FILE *mfp = fopen(maskFile, "r");
// FILE *mfp=fopen("/project/geoaida/tmp/mask.pbm","r");
if (!mfp) {
fprintf(stderr, "mask file %s not found\n", maskFile);
return 1;
}
GaMaskImage mask;
mask.read(mfp);
fclose(mfp);
QList<ArgDict> *regionSourceList=readRegionFile(regFile);
if (!regionSourceList) return 1;
QList<ArgDict> regionList;
// Process regions
for (ArgDict* arg = regionSourceList->first();
arg;
arg=regionSourceList->next()) {
ArgDict* args=new ArgDict(*arg);
if (processRegion
(*args, mask, mask_x, mask_y, mask_size_x, mask_size_y))
regionList.append(args);
else
delete args;
}
// Write labels
QFile rfp(outFile ? outFile : regFile);
if (outFile) {
if (labelImageDict.count() > 1) {
fprintf(stderr, "regionmask: Cannot generate multiple labelfiles\n");
return 1;
}
else {
if (regionList.count()>0) {
ArgDict *dict = regionList.first();
QString *oldfile = (*dict)["file"];
QString *labelfile = new QString();
if (resultFile)
labelfile->sprintf("%s", resultFile);
else
labelfile->sprintf("%s.plm", outFile);
LabelImage *im = labelImageDict.take(*oldfile);
labelImageDict.replace(*labelfile, im);
QListIterator < ArgDict > it(regionList);
for (; it.current(); ++it) {
ArgDict *argDict = it.current();
assert(argDict);
argDict->replace("file", labelfile);
}
}
}
}
else {
printf("regionmask: overwriting %s\n",regFile);
outFile = regFile;
}
QDictIterator < LabelImage > git(labelImageDict);
if (regionList.count()>0) {
for (; git.current(); ++git) {
LabelImage *im = git.current();
qDebug("Writing %s", git.currentKey().latin1());
im->image.write(git.currentKey().latin1());
}
}
// Write regions
if (!rfp.open(IO_WriteOnly)) {
fprintf(stderr, "cannot open regionfile %s for writing\n", outFile);
return 1;
}
if (regionList.count()>0) {
QListIterator < ArgDict > it(regionList);
QTextStream ts(&rfp);
for (; it.current(); ++it) {
ArgDict *argDict = it.current();
assert(argDict);
ts << "<region ";
ts << (*argDict);
ts << " />" << endl;
}
}
rfp.close();
labelImageDict.setAutoDelete(true);
labelImageDict.clear();
regionList.setAutoDelete(true);
return 0;
}
示例12: main
int main( int argc, char **argv )
{
if ( argc < 2 ) {
qWarning( "Usage:\n\t%s [--images] files", argv[0] );
return 1;
}
QFile output;
bool images = FALSE;
output.open( IO_WriteOnly, stdout );
QTextStream out( &output );
EmbedImageList list_image;
QList<Embed> list;
list.setAutoDelete( TRUE );
list_image.setAutoDelete( TRUE );
// Embed data for all input files
out << "/* Generated by qembed */\n";
srand( time(0) );
long l = rand();
out << "#ifndef _" << l << endl;
out << "#define _" << l << endl;
for ( int i=1; i<argc; i++ ) {
QString arg = argv[i];
if ( arg == "--images" ) {
if ( !images ) {
out << "#include <qimage.h>\n";
out << "#include <stdlib.h>\n";
images = TRUE;
}
} else {
QFile f( argv[i] );
if ( !f.open(IO_ReadOnly) ) {
qWarning( "Cannot open file %s, ignoring it", argv[i] );
continue;
}
QByteArray a( f.size() );
if ( f.readBlock(a.data(), f.size()) != (int)f.size() ) {
qWarning( "Cannot read file %s, ignoring it", argv[i] );
f.close();
continue;
}
if ( images ) {
QImage img;
if ( !img.loadFromData(a) ) {
qWarning( "Cannot read image from file %s, ignoring it", argv[i] );
f.close();
continue;
}
EmbedImage *e = new EmbedImage;
e->width = img.width();
e->height = img.height();
e->depth = img.depth();
e->numColors = img.numColors();
e->colorTable = new QRgb[e->numColors];
e->alpha = img.hasAlphaBuffer();
memcpy(e->colorTable, img.colorTable(), e->numColors*sizeof(QRgb));
QFileInfo fi(argv[i]);
e->name = fi.baseName();
e->cname = convertFileNameToCIdentifier( e->name.latin1() );
list_image.append( e );
QString s;
if ( e->depth == 32 ) {
out << s.sprintf( "static const QRgb %s_data[] = {",
(const char *)e->cname );
embedData( (QRgb*)img.bits(), e->width*e->height, &output );
} else {
if ( e->depth == 1 )
img = img.convertBitOrder(QImage::BigEndian);
out << s.sprintf( "static const unsigned char %s_data[] = {",
(const char *)e->cname );
embedData( img.bits(), img.numBytes(), &output );
}
out << "\n};\n\n";
if ( e->numColors ) {
out << s.sprintf( "static const QRgb %s_ctable[] = {",
(const char *)e->cname );
embedData( e->colorTable, e->numColors, &output );
out << "\n};\n\n";
}
} else {
Embed *e = new Embed;
e->size = f.size();
e->name = argv[i];
e->cname = convertFileNameToCIdentifier( argv[i] );
list.append( e );
QString s;
out << s.sprintf( "static const unsigned int %s_len = %d;\n",
(const char *)e->cname, e->size );
out << s.sprintf( "static const unsigned char %s_data[] = {",
(const char *)e->cname );
embedData( a, &output );
out << "\n};\n\n";
}
f.close();
}
//.........这里部分代码省略.........