本文整理汇总了C++中tinyxml2::XMLElement::text方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::text方法的具体用法?C++ XMLElement::text怎么用?C++ XMLElement::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinyxml2::XMLElement
的用法示例。
在下文中一共展示了XMLElement::text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destinationFile
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
canUpdate=false;
QSettings settings;
QString dir=QFileDialog::getExistingDirectory(NULL,"Folder containing region directory",settings.value("mapfolder").toString());
if(dir.isEmpty())
abort();
if(!QString(TMPDATA).endsWith("/"))
abort();
if(!dir.endsWith("/"))
dir+="/";
settings.setValue("mapfolder",dir);
QDir().mkpath(TMPDATA);
QDir dir2("/tmp/map-metadata/");
dir2.setFilter(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
QFileInfoList list = dir2.entryInfoList();
if(!QDir("/tmp/map-metadata/").exists() || list.size()==0)
{
process.setArguments(QStringList() << "/home/user/Desktop/CatchChallenger/datapack-pkmn/map/main/gen4/map/");
process.setProgram("/home/user/Desktop/CatchChallenger/tools/build-map2png-Desktop-Debug/map2png");
process.setWorkingDirectory("/tmp/map-metadata/");
process.start();
process.waitForFinished(999999999);
std::cerr << process.errorString().toStdString() << std::endl;
std::cout << process.readAll().toStdString() << std::endl;
if(process.exitCode()!=0)
std::cerr << "Process exit code: " << process.exitCode() << std::endl;
}
QString path=QCoreApplication::applicationDirPath()+"/changes.db";
QFile destinationFile(path);
if(!destinationFile.exists())
{
if(QFile::copy(":/changes.db",path))
{
if(!destinationFile.setPermissions(destinationFile.permissions() | QFileDevice::WriteOwner | QFileDevice::WriteUser))
std::cerr << "Unable to set db permissions" << std::endl;
}
else
std::cerr << "Unable to copy the :/changes.db" << std::endl;
}
m_db = QSqlDatabase::addDatabase("QSQLITE");
m_db.setDatabaseName(path);
if (!m_db.open())
{
qDebug() << "Error: connection with database fail";
abort();
}
QHash<QString,MapContent> db_finishedFile;
QHash<QString,MapContent> db_not_finishedFile;
QSqlQuery query;
if(!query.exec("SELECT file, region, zone, subzone, name, type, finished FROM maps"))
{
qDebug() << query.lastError().text();
abort();
}
while(query.next())
{
QString file = query.value(0).toString();
MapContent mapContent;
mapContent.region=query.value(1).toString();
mapContent.zone=query.value(2).toString();
mapContent.subzone=query.value(3).toString();
mapContent.name=query.value(4).toString();
mapContent.type=query.value(5).toString();
if(mapContent.region.isEmpty())
abort();
mapContent.officialzone=query.value(7).toInt()>0;
if(query.value(6).toInt()>0)
db_finishedFile[file]=mapContent;
else
db_not_finishedFile[file]=mapContent;
}
{
QDirIterator it(dir,QDirIterator::Subdirectories);
QRegularExpression regex("\\.tmx$");
QRegularExpression regexRemove("^/");
while (it.hasNext()) {
QString element=it.next();
if(element.contains(regex))
{
QString sortPath=element;
sortPath.remove(0,dir.size());
sortPath.remove(regexRemove);
QString pngDest=TMPDATA+sortPath;
pngDest.replace(".tmx",".png");
//std::cout << sortPath.toStdString() << " -> " << pngDest.toStdString() << std::endl;
const QStringList elementList=sortPath.split("/");
if(elementList.size()>=2 && elementList.size()<=3)
{
QString file = sortPath;
if(db_finishedFile.contains(file))
//.........这里部分代码省略.........