本文整理汇总了C++中QDir::mkdir方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::mkdir方法的具体用法?C++ QDir::mkdir怎么用?C++ QDir::mkdir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: done
//.........这里部分代码省略.........
Settings.setValue( "Emulator_Monitor_Type", ui.RB_Monitor_TCP->isChecked() ? "tcp" : "stdio" );
#endif
Settings.setValue( "Emulator_Monitor_Hostname", ui.CB_Monitor_Hostname->currentText() );
Settings.setValue( "Emulator_Monitor_Port", ui.SB_Monitor_Port->value() );
// USB
if( ui.RB_USB_Style_device->isChecked() )
Settings.setValue( "USB_Style", "device" );
else
Settings.setValue( "USB_Style", "usbdevice" );
if( ui.RB_USB_ID_BusAddr->isChecked() )
Settings.setValue( "USB_ID_Style", "BusAddr" );
else if( ui.RB_USB_ID_BusPath->isChecked() )
Settings.setValue( "USB_ID_Style", "BusPath" );
else if( ui.RB_USB_ID_VendorProduct->isChecked() )
Settings.setValue( "USB_ID_Style", "VendorProduct" );
// All OK?
if( Settings.status() != QSettings::NoError )
AQError( "void Advanced_Settings_Window::done(int)", "QSettings Error!" );
QDir dir; // For Check on valid
Settings.setValue( "Default_VM_Template", ui.CB_Default_VM_Template->currentText() );
ui.Edit_VM_Folder->setText( QDir::toNativeSeparators(ui.Edit_VM_Folder->text()) );
// VM Folder
if( ! (ui.Edit_VM_Folder->text().endsWith("/") || ui.Edit_VM_Folder->text().endsWith("\\")) )
ui.Edit_VM_Folder->setText( ui.Edit_VM_Folder->text() + QDir::toNativeSeparators("/") );
if( dir.exists(ui.Edit_VM_Folder->text()) )
{
if( ! dir.exists(ui.Edit_VM_Folder->text() + QDir::toNativeSeparators("/os_templates/")) )
dir.mkdir( ui.Edit_VM_Folder->text() + QDir::toNativeSeparators("/os_templates/") );
Settings.setValue( "VM_Directory", ui.Edit_VM_Folder->text() );
}
else
{
int mes_res = QMessageBox::question( this, tr("Invalid Value!"),
tr("AQEMU VM folder doesn't exist! Do you want to create it?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if( mes_res == QMessageBox::Yes )
{
if( ! (dir.mkdir(ui.Edit_VM_Folder->text()) &&
dir.mkdir(ui.Edit_VM_Folder->text() + QDir::toNativeSeparators("/os_templates/"))) )
{
AQGraphic_Warning( tr("Error!"), tr("Cannot Create New Folder!") );
return;
}
else Settings.setValue( "VM_Directory", ui.Edit_VM_Folder->text() );
}
else return;
}
// Use New Emulator Control Removable Device Menu
if( ui.CH_Use_New_Device_Changer->isChecked() ) Settings.setValue( "Use_New_Device_Changer", "yes" );
else Settings.setValue( "Use_New_Device_Changer", "no" );
// Interface Language
if( ui.CB_Language->currentIndex() == 0 ) Settings.setValue( "Language", "en" );
else Settings.setValue( "Language", ui.CB_Language->itemText(ui.CB_Language->currentIndex()) );
// VM Icons Size
switch( ui.CB_VM_Icons_Size->currentIndex() )
示例2: main
//.........这里部分代码省略.........
//Set Geographic Location
dat->setLocationFromOptions();
//Set color scheme
dat->colorScheme()->loadFromConfig();
//set clock now that we have a location:
//Check to see if user provided a date/time string. If not, use current CPU time
QString datestring = parser.value( "date" );
KStarsDateTime kdt;
if ( ! datestring.isEmpty() ) {
if ( datestring.contains( "-" ) ) { //assume ISODate format
if ( datestring.contains( ":" ) ) { //also includes time
//kdt = QDateTime::fromString( datestring, QDateTime::ISODate );
kdt = QDateTime::fromString( datestring, Qt::ISODate );
} else { //string probably contains date only
//kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) );
kdt.setDate( QDate::fromString( datestring, Qt::ISODate ) );
kdt.setTime( QTime( 0, 0, 0 ) );
}
} else { //assume Text format for date string
kdt = dat->geo()->LTtoUT( QDateTime::fromString( datestring, Qt::TextDate ) );
}
if ( ! kdt.isValid() ) {
qWarning() << i18n( "Using CPU date/time instead." ) ;
kdt = KStarsDateTime::currentDateTimeUtc();
}
} else {
kdt = KStarsDateTime::currentDateTimeUtc();
}
dat->clock()->setUTC( kdt );
SkyMap *map = SkyMap::Create();
map->resize( w, h );
QPixmap sky( w, h );
dat->setFullTimeUpdate();
dat->updateTime(dat->geo(), map );
SkyPoint dest( Options::focusRA(), Options::focusDec() );
map->setDestination( dest );
map->destination()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );
map->setFocus( map->destination() );
map->focus()->EquatorialToHorizontal( dat->lst(), dat->geo()->lat() );
//Execute the specified script
QString scriptfile = parser.value( "script" );
if ( ! scriptfile.isEmpty() ) {
if ( dat->executeScript( scriptfile, map ) ) {
std::cout << i18n( "Script executed." ).toUtf8().data() << std::endl;
} else {
qWarning() << i18n( "Could not execute script." ) ;
}
}
qApp->processEvents();
map->setupProjector();
map->exportSkyImage( &sky );
qApp->processEvents();
if ( ! sky.save( fname, format ) )
qWarning() << "Unable to save image: " << fname;
else
qDebug() << "Saved to file: %1" << fname;
delete map;
delete dat;
return 0;
}
//Try to parse the given date string
QString datestring = parser.value( "date" );
if ( ! datestring.isEmpty() && ! KStarsDateTime::fromString( datestring ).isValid() )
{
qWarning() << i18n( "Using CPU date/time instead." ) ;
datestring.clear();
}
#endif
// Create writable data dir if it does not exist
QDir writableDir;
writableDir.mkdir(KSPaths::writableLocation(QStandardPaths::GenericDataLocation));
#ifndef KSTARS_LITE
KStars::createInstance( true, ! parser.isSet( "paused" ), datestring );
// no session.. just start up normally
const QStringList urls = parser.positionalArguments();
// take arguments
if( ! urls.isEmpty() )
{
foreach (const QString &url, urls) {
const QUrl u = QUrl::fromUserInput(url, QDir::currentPath());
KStars::Instance()->openFITS(u);
}
}
示例3: QWidget
Options::Options(QWidget *parent) : QWidget(parent)
{
ui.setupUi(this);
SetupPluginList();
channelsChanged(0);
ui.sbPaTxDelayValue->setVisible(false);
ui.sbVoiceRepeatTime->setVisible(false);
ui.tbSDR->setCurrentIndex(0);
ui.SwMain->setCurrentIndex(0);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QString DocumentsLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#else
QString DocumentsLocation = QDesktopServices::storageLocation(QDesktopServices:: HomeLocation);
#endif
QDir dir;
if(dir.exists(DocumentsLocation))
{
if(!dir.exists(DocumentsLocation + "/ExpertSDR"))
dir.mkdir(DocumentsLocation + "/ExpertSDR");
pathDefaultWaveIQ = DocumentsLocation + "/ExpertSDR/";
}
else
{
if(dir.mkdir(QDir::homePath() + "/ExpertSDR"))
pathDefaultWaveIQ = QDir::homePath() + "/ExpertSDR/";
else
{
QMessageBox msgBox;
msgBox.setText("Choose a directory where wave files will be located.");
msgBox.exec();
//
QString path = QDir::homePath();
if(path.isEmpty())
{
msgBox.setText("Wave file location:\n" + QDir::homePath());
msgBox.exec();
pathDefaultWaveIQ = QDir::homePath() + "/";
}
else
pathDefaultWaveIQ = path + "/";
}
}
pathDefaultWaveIQDefault = pathDefaultWaveIQ;
ui.lbWavePathIQ->setText(pathDefaultWaveIQ);
pProg0 = new QProcess(this);
pProg1 = new QProcess(this);
pProg2 = new QProcess(this);
pProg3 = new QProcess(this);
pProg4 = new QProcess(this);
//prepare to pupulate list in combobox with serial ports
ui.cbPttPortName->clear();
ui.cbAddKeyPortName->clear();
ui.cbKeyPortName->clear();
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
if (ports.size()!=0)
{
for (int i = 0; i < ports.size(); i++)
{
ui.cbPttPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
ui.cbAddKeyPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
ui.cbKeyPortName->addItem(ports.at(i).portName.toLocal8Bit().constData(),0);
}
}
#ifdef Q_OS_LINUX
pPttPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
pKeyPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
pAddKeyPort = new QextSerialPort("/dev/ttyS0", QextSerialPort::EventDriven);
#else
pPttPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
pKeyPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
pAddKeyPort = new QextSerialPort("COM1", QextSerialPort::EventDriven);
#endif /*Q_OS_LINUX*/
connect(pPttPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnPttDsr(bool)));
connect(pPttPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnPttCts(bool)));
connect(pKeyPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnKeyDsr(bool)));
connect(pKeyPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnKeyCts(bool)));
connect(pAddKeyPort, SIGNAL(dsrChanged(bool)), this, SLOT(OnAddKeyDsr(bool)));
connect(pAddKeyPort, SIGNAL(ctsChanged(bool)), this, SLOT(OnAddKeyCts(bool)));
connect(ui.LwOptions, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(ChangePage(QListWidgetItem*, QListWidgetItem*)));
connect(ui.pbOK, SIGNAL(clicked()), this, SLOT(OnOK()));
connect(ui.pbCancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
connect(ui.slTxImRejMag, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChange(int)));
connect(ui.slTxImRejPhase, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChange(int)));
connect(ui.slTxImRejMagCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeCw(int)));
connect(ui.sbTxImRejMagCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeCw(int)));
connect(ui.slTxImRejPhaseCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChangeCw(int)));
connect(ui.sbTxImRejPhaseCw, SIGNAL(valueChanged(int)), this, SLOT(OnTxPhaseChangeCw(int)));
connect(ui.slTxImRejMagAmFm, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeAmFm(int)));
connect(ui.sbTxImRejMagAmFm, SIGNAL(valueChanged(int)), this, SLOT(OnTxGainChangeAmFm(int)));
//.........这里部分代码省略.........
示例4: loadMembers
void SecurityManager::loadMembers()
{
if (isSql()) {
loadSqlMembers();
return;
}
const char *path = "serverdb/members.txt";
const char *backup = "serverdb/members.backup.txt";
{
QDir d;
d.mkdir("serverdb");
}
if (!QFile::exists(path) && QFile::exists(backup)) {
QFile::rename(backup, path);
}
memberFile.setFileName(path);
if (!memberFile.open(QFile::ReadWrite)) {
throw QObject::tr("Error: cannot open the file that contains the members (%1)").arg(path);
}
int pos = memberFile.pos();
while (!memberFile.atEnd()) {
QByteArray arr = memberFile.readLine();
QString s = QString::fromUtf8(arr.constData(), std::max(0,arr.length()-1)); //-1 to remove the \n
QStringList ls = s.split('%');
if (ls.size() >= 6 && isValid(ls[0])) {
Member m (ls[0], ls[1].trimmed(), ls[2][0].toLatin1() - '0', ls[2][1] == '1', ls[3].trimmed().toLatin1(), ls[4].trimmed().toLatin1(), ls[5].trimmed());
if (ls.size() >= 7) {
m.ban_expire_time = ls[6].toInt();
}
m.filepos = pos;
members[ls[0]] = m;
/* Update pos for next iteration */
pos = memberFile.pos();
if (m.isBanned()) {
bannedIPs.insert(m.ip, m.ban_expire_time);
bannedMembers.insert(m.name.toLower(), std::pair<QString, int>(m.ip, m.ban_expire_time));
}
if (m.authority() > 0) {
authed.insert(m.name);
}
playersByIp.insert(m.ip, m.name);
}
lastPlace = memberFile.pos();
}
//We also clean up the file by rewritting it with only the valid contents
QFile temp (backup);
if (!temp.open(QFile::WriteOnly | QFile::Truncate))
throw QObject::tr("Impossible to change %1").arg(backup);
pos = temp.pos();
for(auto it = members.begin(); it != members.end(); ++it) {
Member &m = it->second;
m.write(&temp);
m.filepos = pos;
pos = temp.pos();
}
lastPlace = temp.pos();
temp.flush();
memberFile.remove();
if (!temp.rename(path)) {
throw QObject::tr("Error: cannot rename the file that contains the members (%1 -> %2)").arg(backup).arg(path);
}
temp.rename(path);
if (!memberFile.open(QFile::ReadWrite)) {
throw QObject::tr("Error: cannot reopen the file that contains the members (%1)").arg(path);
}
}
示例5: createNewCC
bool DbPlugin::createNewCC (DBIndex *i)
{
FuturesData fd;
QStringList l;
fd.getSymbolList(l);
QString pl = QObject::tr("Parms");
QString fsl = QObject::tr("Futures Symbol");
QString gl = QObject::tr("Gapless");
PrefDialog *dialog = new PrefDialog(0);
dialog->setCaption(QObject::tr("New CC"));
dialog->createPage (pl);
dialog->setHelpFile(helpFile);
dialog->addComboItem(fsl, pl, l, 0);
dialog->addCheckItem(gl, pl, TRUE);
int rc = dialog->exec();
if (rc != QDialog::Accepted)
{
delete dialog;
return TRUE;
}
QString sym;
dialog->getCombo(fsl, sym);
bool f = dialog->getCheck(gl);
delete dialog;
QDir dir;
Config config;
QString s;
config.getData(Config::DataPath, s);
s.append("/CC");
if (! dir.exists(s))
{
if (! dir.mkdir(s, TRUE))
{
QMessageBox::information(0,
QObject::tr("Qtstalker: Error"),
QObject::tr("Could not create ~/.qtstalker/data/CC directory."));
return TRUE;
}
}
DBIndexItem item;
QString ts;
chartIndex->getIndexItem(sym, item);
item.getSymbol(ts);
if (ts.length())
{
qDebug("DbPlugin::createNewStock: duplicate symbol %s", ts.latin1());
return TRUE;
}
s.append("/" + sym);
if (open(s, i))
{
QMessageBox::information(0,
QObject::tr("Qtstalker: Error"),
QObject::tr("Disk error, cannot create chart"));
return TRUE;
}
type = CC1;
item.setSymbol(sym);
s = "CC";
item.setType(s);
s = sym + " - " + QObject::tr("Continuous Adjusted");
item.setTitle(s);
chartIndex->setIndexItem(indexKey, item);
s = QString::number(f);
sym = "Adjustment";
setData(sym, s);
return FALSE;
}
示例6: processDir
void LinkBackupThread::processDir(QDir& currentFromDir, QDir& currentToDir)
{
long numErrors = getLogger().errorCount();
if (numErrors > 1000)
{
QString errorMessage = QString("%1 errors found, quit?");
QMessageBox::StandardButton reply = QMessageBox::question(nullptr, "Test", errorMessage, QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::Yes) {
requestCancel();
} else {
getLogger().clearErrorCount();
}
}
TRACE_MSG(QString("Processing directory %1").arg(currentFromDir.canonicalPath()), 1);
// Process directories, then process files.
QList<QFileInfo> list = currentFromDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden | QDir::Readable);
QFileInfo info;
foreach (info, list) {
if (isCancelRequested()) {
return;
}
TRACE_MSG(QString("Found Dir to processes %1").arg(info.canonicalFilePath()), 2);
if (passes(info))
{
DEBUG_MSG(QString("Dir Passes: %1").arg(info.canonicalFilePath()), 2);
if (!currentToDir.mkdir(info.fileName())) {
ERROR_MSG(QString("Failed to create directory %1/%2").arg(currentToDir.canonicalPath(), info.fileName()), 1);
} else if (!currentToDir.cd(info.fileName())) {
ERROR_MSG(QString("Failed to cd to directory %1/%2").arg(currentToDir.canonicalPath(), info.fileName()), 1);
} else if (!currentFromDir.cd(info.fileName())) {
ERROR_MSG(QString("Failed to cd to directory %1/%2").arg(currentFromDir.canonicalPath(), info.fileName()), 1);
if (!currentToDir.cdUp()) {
ERROR_MSG("Failed to cd up a directory for the to directory", 1);
requestCancel();
return;
}
} else {
processDir(currentFromDir, currentToDir);
if (!currentToDir.cdUp()) {
ERROR_MSG("Failed to cd up a directory for the to directory", 1);
requestCancel();
return;
}
if (!currentFromDir.cdUp()) {
ERROR_MSG("Failed to cd up a directory for the from directory", 1);
requestCancel();
return;
}
}
}
else
{
DEBUG_MSG(QString("Skipping Dir: %1").arg(info.canonicalFilePath()), 2);
}
}
// Now handle files
list = currentFromDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::Hidden | QDir::Readable);
foreach (info, list) {
if (isCancelRequested()) {
return;
}
QString fullPathFileToRead = info.canonicalFilePath();
//TRACE_MSG(QString("Found File to test %1").arg(fullPathFileToRead), 2);
if (passes(info))
{
//TRACE_MSG(QString("File passes %1").arg(fullPathFileToRead), 2);
QFile fileToRead(fullPathFileToRead);
// Just in case someone deleted the file.
if (fileToRead.exists())
{
DBFileEntry* currentEntry = new DBFileEntry(info, m_fromDirWithoutTopDirName);
const DBFileEntry* linkEntry = m_oldEntries->findEntry(m_backupSet.getCriteria(), currentEntry, m_fromDirWithoutTopDirName);
QString pathToLinkFile = m_previousDirRoot;
// If not in the old backup, search the current backup.
if (linkEntry == nullptr)
{
linkEntry = m_currentEntries->findEntry(m_backupSet.getCriteria(), currentEntry, m_fromDirWithoutTopDirName);
pathToLinkFile = m_toDirRoot;
}
if (linkEntry == nullptr)
{
bool failedToCopy = false;
QString fullFileNameToWrite = m_toDirRoot + "/" + currentEntry->getPath();
bool needHash = (currentEntry->getHash().length() == 0);
if (needHash)
{
failedToCopy = !::getCopyLinkUtil().copyFileGenerateHash(fullPathFileToRead, fullFileNameToWrite);
if (!failedToCopy)
{
currentEntry->setHash(getCopyLinkUtil().getLastHash());
}
}
else if (!getCopyLinkUtil().copyFile(fullPathFileToRead, fullFileNameToWrite))
{
failedToCopy = true;
}
//.........这里部分代码省略.........
示例7: WriteXmlFile
bool MdiEditor::WriteXmlFile(QString filename)
{
//getParameters();
QFile file(filename);
if(file.open(QIODevice::WriteOnly | QIODevice::Truncate |QIODevice::Text))
{
QString str;
QDomDocument doc;
QDomText text;
QDomElement element;
QDomAttr attribute;
QDomProcessingInstruction instruction = doc.createProcessingInstruction("xml","version=\'1.0\'");
doc.appendChild(instruction);
QDomElement root = doc.createElement("project");
doc.appendChild(root);
//Images
QDomElement eimages=doc.createElement("images");
root.appendChild(eimages);
attribute=doc.createAttribute("image1");
attribute.setValue("/image1.png");
eimages.setAttributeNode(attribute);
QString filename;
filename.sprintf("%s/image1.png",pro_path.toLatin1().data());
cv::imwrite(filename.toLatin1().data(),image1);
attribute=doc.createAttribute("image2");
attribute.setValue("\\image2.png");
eimages.setAttributeNode(attribute);
filename.sprintf("%s\\image2.png",pro_path.toLatin1().data());
cv::imwrite(filename.toLatin1().data(),image2);
//layer
QDomElement elayers=doc.createElement("layers");
root.appendChild(elayers);
attribute=doc.createAttribute("num");
attribute.setValue(str.sprintf("%d",layer_num));
elayers.setAttributeNode(attribute);
for(int index=0;index<layer_num;index++)
{
QDomElement elayer=doc.createElement(str.sprintf("l%d",index));
elayers.appendChild(elayer);
QDir dir;
QString filename;
filename.sprintf("%s\\%d",pro_path.toLatin1().data(),index);
dir.mkdir(filename);
//masks
QDomElement emask=doc.createElement("masks");
elayer.appendChild(emask);
attribute=doc.createAttribute("mask1");
attribute.setValue(str.sprintf("\\%d\\mask1.png",index));
emask.setAttributeNode(attribute);
filename.sprintf("%s\\%d\\mask1.png",pro_path.toLatin1().data(),index);
cv::imwrite(filename.toLatin1().data(),parameters[index].mask1);
attribute=doc.createAttribute("mask2");
attribute.setValue(str.sprintf("\\%d\\mask2.png",index));
emask.setAttributeNode(attribute);
filename.sprintf("%s\\%d\\mask2.png",pro_path.toLatin1().data(),index);
cv::imwrite(filename.toLatin1().data(),parameters[index].mask2);
//parameters
QDomElement epara=doc.createElement("parameters");
elayer.appendChild(epara);
//weight
element=doc.createElement("weight");
epara.appendChild(element);
attribute=doc.createAttribute("ssim");
attribute.setValue(str.sprintf("%f",parameters[index].w_ssim));
element.setAttributeNode(attribute);
attribute=doc.createAttribute("tps");
attribute.setValue(str.sprintf("%f",parameters[index].w_tps));
//.........这里部分代码省略.........
示例8: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QStringList args = a.arguments();
if (args.size() < 4) {
out << "Usage: " << args[0] << " <version> <qtdir> <platform> [load]\n" << flush;
return 1;
}
const QString version = args[1];
const QDir qtdir = QDir(args[2]);
const QString platform = args[3];
if (args.size() > 5) {
if (args[4] == "load") {
silent = false;
}
}
if (!QRegularExpression("\\d\\.\\d\\.\\d").match(version).hasMatch()) {
out << "<version> has to be in the format #.#.#\n" << flush;
return 1;
}
const QString short_version = version.left(3);
GetFiles::version = version;
// mappings etc.
QList<FileGroup> mappings;
mappings.append(FileGroup("bin", &GetFiles::binaryFiles));
mappings.append(FileGroup("doc", &GetFiles::docFiles));
mappings.append(FileGroup("examples", &GetFiles::exampleFiles));
mappings.append(FileGroup("imports", &GetFiles::importsFiles));
mappings.append(FileGroup("include", &GetFiles::includeFolders));
mappings.append(FileGroup("lib", &GetFiles::libFiles));
mappings.append(FileGroup("libexec", &GetFiles::libExecFiles));
mappings.append(FileGroup("mkspecs", &GetFiles::mkSpecFiles));
mappings.append(FileGroup("phrasebooks", &GetFiles::phrasebookFiles));
mappings.append(FileGroup("plugins", &GetFiles::pluginNames));
mappings.append(FileGroup("qml", &GetFiles::qmlFiles));
mappings.append(FileGroup("translations", &GetFiles::translationFiles));
QStringList modules;
for (const FileGroup &files : mappings) {
modules.append((files.fileGetter)().keys());
}
modules.removeDuplicates();
out << "Copying files for the following modules: " << modules.join(", ") << "\n" << flush;
QDir baseDir;
for (const QString &module : modules) {
if (baseDir.exists(module + ".tar.gz")) {
out << "Skiping already existing module " << module << "\n" << flush;
continue;
}
out << "Copying files for module " << module << "\n" << flush;
baseDir.mkdir(module);
QDir dir(baseDir);
dir.cd(module);
for (const FileGroup &files : mappings) {
QStringList fs = (files.fileGetter)()[module];
if (fs.isEmpty()) {
continue;
}
out << " Copying " << files.name << " files...\n" << flush;
QDir fromDir(qtdir);
fromDir.cd(files.name);
QDir toDir(dir);
toDir.mkdir(files.name);
toDir.cd(files.name);
copyFiles(fs, fromDir, toDir);
}
out << " Creating install file for module " << module << "...\n" << flush;
{
QFile installFile(dir.absoluteFilePath("install.js"));
if (!installFile.open(QFile::WriteOnly | QFile::Truncate)) {
out << "Error opening install file: " << installFile.errorString() << "\n";
return -1;
}
QTextStream js(&installFile);
js << "FileSystem.mkpath(Paths.installPath);\n";
for (const FileGroup &groups : mappings) {
if (groups.fileGetter().contains(module)) {
js << "FileSystem.install(\"" << groups.name
<< "\", Paths.installPath + \"/" << groups.name << "\");\n";
}
}
js << "\n";
js.flush();
installFile.close();
}
out << " Creating removal file for module " << module << "...\n" << flush;
{
QFile removalFile(dir.absoluteFilePath("remove.js"));
if (!removalFile.open(QFile::WriteOnly | QFile::Truncate)) {
out << "Error opening remove file: " << removalFile.errorString() << "\n";
//.........这里部分代码省略.........
示例9: onFinished
void YouGetBridge::onFinished()
{
QJsonParseError json_error;
QJsonObject obj = QJsonDocument::fromJson(process->readAllStandardOutput(), &json_error).object();
if (json_error.error == QJsonParseError::NoError)
{
if (obj.contains("streams"))
{
QString title = obj["title"].toString();
QJsonObject streams = obj["streams"].toObject();
QJsonObject::const_iterator i;
for (i = streams.constBegin(); i != streams.constEnd(); i++)
{
QJsonObject item = i.value().toObject();
if (item.contains("src"))
{
QString container = item["container"].toString();
QJsonArray json_urls = item["src"].toArray();
QStringList names, urls;
// Make file list
for (int i = 0; i < json_urls.size(); i++)
{
names << QString("%1_%2.%3").arg(title, QString::number(i), container);
urls << json_urls[i].toString();
}
// Download
if (download)
{
// Build file path list
QDir dir = QDir(Settings::downloadDir);
QString dirname = title + '.' + container;
if (urls.size() > 1)
{
if (!dir.cd(dirname))
{
dir.mkdir(dirname);
dir.cd(dirname);
}
}
for (int i = 0; i < names.size(); i++)
names[i] = dir.filePath(names[i]);
// Download more than 1 video clips with danmaku
if (!danmaku.isEmpty() && urls.size() > 1)
new DanmakuDelayGetter(names, urls, danmaku, true);
// Download without danmaku or only 1 clip with danmaku
else
{
for (int i = 0; i < urls.size(); i++)
downloader->addTask(urls[i].toUtf8(), names[i], urls.size() > 1, danmaku.toUtf8());
}
QMessageBox::information(NULL, "Message", tr("Add download task successfully!"));
}
// Play
else
{
// Play more than 1 clips with danmaku
if (!danmaku.isEmpty() && urls.size() > 1)
new DanmakuDelayGetter(names, urls, danmaku, false);
// Play clips without danmaku or only 1 clip with danmaku
else
{
playlist->addFileAndPlay(names[0], urls[0], danmaku);
for (int i = 1; i < urls.size(); i++)
playlist->addFile(names[i], urls[i]);
}
if (Settings::autoCloseWindow)
webvideo->close();
}
return;
}
}
}
}
QMessageBox::warning(NULL, "Error", " Parse failed!\n" + QString::fromUtf8(process->readAllStandardError()));
}
示例10: QGeoTiledMappingManagerEngine
QGeoMappingManagerEngineCm::QGeoMappingManagerEngineCm(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString)
: QGeoTiledMappingManagerEngine(parameters),
m_parameters(parameters),
m_host("b.tile.cloudmade.com"),
m_token(QGeoServiceProviderFactoryCm::defaultToken)
{
Q_UNUSED(error)
Q_UNUSED(errorString)
setTileSize(QSize(256,256));
setMinimumZoomLevel(0.0);
setMaximumZoomLevel(18.0);
m_styleId = m_parameters.value("style", "1").toString();
//SL_MAP_TYPE
QList<QGraphicsGeoMap::MapType> types;
types << QGraphicsGeoMap::StreetMap;
setSupportedMapTypes(types);
m_nam = new QNetworkAccessManager(this);
//m_cache = new QNetworkDiskCache(this);
m_cacheSize = DEFAULT_TILE_CACHE_SIZE;
QList<QString> keys = m_parameters.keys();
if (keys.contains("mapping.proxy")) {
QString proxy = m_parameters.value("mapping.proxy").toString();
if (!proxy.isEmpty())
m_nam->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy, 8080));
}
if (keys.contains("mapping.host")) {
QString host = m_parameters.value("mapping.host").toString();
if (!host.isEmpty())
m_host = host;
}
if (keys.contains("mapping.cache.directory")) {
QString cacheDir = m_parameters.value("mapping.cache.directory").toString();
if (!cacheDir.isEmpty())
m_cacheDir = cacheDir;
//m_cache->setCacheDirectory(cacheDir);
}
else
{
// set default cache dir
// QDir dir = QDir::temp();
QDir dir = QDir(QDesktopServices::storageLocation(QDesktopServices::CacheLocation));
qDebug() << __FUNCTION__ << "Cache at" << dir;
dir.mkdir(DEFAULT_TILE_CACHE_DIR);
// QFileInfo info(dir.absolutePath());
// qDebug() << __FUNCTION__ << "Cache size" << info.size();
dir.cd(DEFAULT_TILE_CACHE_DIR);
//m_cache->setCacheDirectory(dir.path());
m_cacheDir = dir.path();
}
DBG_CM(TILES_M, INFO_L, "Setting tile cache dir to " << m_cacheDir);
if (keys.contains("mapping.cache.size")) {
bool ok = false;
qint64 cacheSize = m_parameters.value("mapping.cache.size").toString().toLongLong(&ok);
if (ok) {
//m_cache->setMaximumCacheSize(cacheSize);
m_cacheSize = cacheSize;
DBG_CM(TILES_M, INFO_L, "Setting tile cache size = " << m_cacheSize);
}
}
// first of all: delete all *.png files that may still be lurking in
// the old cache dir as they may affect the gallery (they are named
// png, but are not real png files)
QDir dir = QDir::temp();
if(dir.cd("maptiles-cm")) {
QStringList pngFilters;
pngFilters << "*.png";
dir.setNameFilters(pngFilters);
QStringList pngList = dir.entryList();
foreach(QString name, pngList)
dir.remove(name);
dir.cd("..");
dir.rmdir("maptiles-cm");
}
// if (m_cacheSize > 0) cleanCacheToSize(m_cacheSize);
}
示例11: desc
LeechCraft::Application::Application (int& argc, char **argv)
: QApplication (argc, argv)
, CatchExceptions_ (true)
{
Arguments_ = arguments ();
bpo::options_description desc ("Allowed options");
bpo::command_line_parser parser (argc, argv);
VarMap_ = Parse (parser, &desc);
if (VarMap_.count ("help"))
{
std::cout << "LeechCraft " << LEECHCRAFT_VERSION << " (http://leechcraft.org)" << std::endl;
std::cout << std::endl;
std::cout << desc << std::endl;
std::exit (EHelpRequested);
}
if (VarMap_.count ("version"))
{
std::cout << "LeechCraft " << LEECHCRAFT_VERSION << " (http://leechcraft.org)" << std::endl;
#ifdef Q_OS_WIN32
std::cout << " <this version does not have UNLIMITED CAT POWA :(>" << std::endl;
#else
std::cout << " this version can haz teh UNLIMITED CAT POWA :3 ε:" << std::endl;
#endif
std::exit (EVersionRequested);
}
if (VarMap_.count ("no-app-catch"))
CatchExceptions_ = false;
if (VarMap_.count ("clrsckt"))
QLocalServer::removeServer (GetSocketName ());
if (VarMap_.count ("restart"))
{
EnterRestartMode ();
return;
}
// Sanity checks
if (!VarMap_.count ("plugin") && IsAlreadyRunning ())
std::exit (EAlreadyRunning);
Util::InstallTranslator ("", "qt", "qt4");
QDir home = QDir::home ();
if (!home.exists (".leechcraft"))
if (!home.mkdir (".leechcraft"))
{
QMessageBox::critical (0,
"LeechCraft",
QDir::toNativeSeparators (tr ("Could not create path %1/.leechcraft")
.arg (QDir::homePath ())));
std::exit (EPaths);
}
// Things are sane, prepare
QCoreApplication::setApplicationName ("Leechcraft");
QCoreApplication::setApplicationVersion (LEECHCRAFT_VERSION);
QCoreApplication::setOrganizationName ("Deviant");
Translator_.reset (LeechCraft::Util::InstallTranslator (""));
qRegisterMetaType<QModelIndex> ("QModelIndex");
qRegisterMetaType<QModelIndex*> ("QModelIndexStar");
qRegisterMetaType<TagsManager::TagsDictionary_t> ("LeechCraft::TagsManager::TagsDictionary_t");
qRegisterMetaType<LeechCraft::Entity> ("LeechCraft::Entity");
qRegisterMetaType<LeechCraft::Entity> ("Entity");
qRegisterMetaType<LeechCraft::IHookProxy_ptr> ("LeechCraft::IHookProxy_ptr");
qRegisterMetaType<LeechCraft::Sync::ChainID_t> ("LeechCraft::Sync::ChainID_t");
qRegisterMetaType<LeechCraft::Sync::ChainID_t> ("Sync::ChainID_t");
qRegisterMetaType<LeechCraft::Sync::ChainID_t> ("ChainID_t");
qRegisterMetaType<QKeySequences_t> ("QKeySequences_t");
qRegisterMetaTypeStreamOperators<QKeySequences_t> ("QKeySequences_t");
qRegisterMetaTypeStreamOperators<TagsManager::TagsDictionary_t> ("LeechCraft::TagsManager::TagsDictionary_t");
qRegisterMetaTypeStreamOperators<LeechCraft::Entity> ("LeechCraft::Entity");
ParseCommandLine ();
setWindowIcon (QIcon (":/resources/images/leechcraft.svg"));
// Say hello to logs
qDebug () << "======APPLICATION STARTUP======";
qWarning () << "======APPLICATION STARTUP======";
// And finally!..
new LeechCraft::MainWindow ();
}
示例12: createHtml
bool KImGalleryPlugin::createHtml(const KURL& url, const QString& sourceDirName, int recursionLevel, const QString& imageFormat)
{
if(m_cancelled) return false;
if( !parent() || !parent()->inherits("KonqDirPart"))
return false;
KonqDirPart * part = static_cast<KonqDirPart *>(parent());
QStringList subDirList;
if (m_recurseSubDirectories && (recursionLevel >= 0)) { //recursionLevel == 0 means endless
QDir toplevel_dir = QDir( sourceDirName );
toplevel_dir.setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
subDirList = toplevel_dir.entryList();
for (QStringList::ConstIterator it = subDirList.begin(); it != subDirList.end() && !m_cancelled; it++) {
const QString currentDir = *it;
if (currentDir == "." || currentDir == "..") { continue;} //disregard the "." and ".." directories
QDir subDir = QDir( url.directory() + "/" + currentDir );
if (!subDir.exists()) {
subDir.setPath( url.directory() );
if (!(subDir.mkdir(currentDir, false))) {
KMessageBox::sorry(part->widget(), i18n("Couldn't create folder: %1").arg(subDir.path()));
continue;
} else {
subDir.setPath( url.directory() + "/" + currentDir );
}
}
if(!createHtml( KURL( subDir.path() + "/" + url.fileName() ), sourceDirName + "/" + currentDir,
recursionLevel > 1 ? recursionLevel - 1 : 0, imageFormat)) { return false; }
}
}
if (m_useCommentFile) {
loadCommentFile();
}
kdDebug(90170) << "sourceDirName: " << sourceDirName << endl;
//We're interested in only the patterns, so look for the first |
//#### perhaps an accessor should be added to KImageIO instead?
QString filter = KImageIO::pattern(KImageIO::Reading).section('|', 0, 0);
QDir imageDir( sourceDirName, filter.latin1(),
QDir::Name|QDir::IgnoreCase, QDir::Files|QDir::Readable);
const QString imgGalleryDir = url.directory();
kdDebug(90170) << "imgGalleryDir: " << imgGalleryDir << endl;
// Create the "thumbs" subdirectory if necessary
QDir thumb_dir( imgGalleryDir + QString::fromLatin1("/thumbs/"));
if (createDirectory(thumb_dir, imgGalleryDir, "thumbs") == false)
return false;
// Create the "images" subdirectory if necessary
QDir images_dir( imgGalleryDir + QString::fromLatin1("/images/"));
if (m_copyFiles) {
if (createDirectory(images_dir, imgGalleryDir, "images") == false)
return false;
}
QFile file( url.path() );
kdDebug(90170) << "url.path(): " << url.path() << ", thumb_dir: "<< thumb_dir.path()
<< ", imageDir: "<< imageDir.path() << endl;
if ( imageDir.exists() && file.open(IO_WriteOnly) ) {
QTextStream stream(&file);
stream.setEncoding(QTextStream::Locale);
createHead(stream);
createBody(stream, sourceDirName, subDirList, imageDir, url, imageFormat); //ugly
file.close();
return !m_cancelled;
} else {
KMessageBox::sorry(m_part->widget(),i18n("Couldn't open file: %1").arg(url.path(+1)));
return false;
}
}
示例13: initTestCase
void TestAusmt::initTestCase()
{
// Dirs
QDir srcDir (QStandardPaths::writableLocation(QStandardPaths::TempLocation));
if (!srcDir.exists(AUSMTSRC_SUBDIR)) {
QVERIFY(srcDir.mkdir(AUSMTSRC_SUBDIR));
}
QVERIFY(srcDir.cd(AUSMTSRC_SUBDIR));
GET_DIR;
GET_VAR_DIR;
GET_FILES_DIR;
GET_PATCHES_DIR;
// Dump AUSMT into src dir
QDir ausmtResDir (":/ausmtsrc/");
foreach (const QString &fileName, ausmtResDir.entryList(QDir::Files)) {
QFile file (ausmtResDir.absoluteFilePath(fileName));
if (srcDir.exists(fileName)) {
QVERIFY(QFileInfo(srcDir.absoluteFilePath(fileName)).isFile());
QVERIFY(srcDir.remove(fileName));
}
QVERIFY(file.copy(srcDir.absoluteFilePath(fileName)));
}
QDir ausmtTestResDir (":/ausmtsrc-test/");
foreach (const QString &fileName, ausmtTestResDir.entryList(QDir::Files)) {
QFile file (ausmtTestResDir.absoluteFilePath(fileName));
if (srcDir.exists(fileName)) {
QVERIFY(QFileInfo(srcDir.absoluteFilePath(fileName)).isFile());
QVERIFY(srcDir.remove(fileName));
}
QVERIFY(file.copy(srcDir.absoluteFilePath(fileName)));
}
// Make a better constants_root.sh
QFile constantsRoot (srcDir.absoluteFilePath(CONSTANTS_ROOT_SH));
QVERIFY(constantsRoot.open(QIODevice::WriteOnly));
QTextStream constantsRootStream (&constantsRoot);
constantsRootStream << QString("AUSMT_VAR_DIR=%1\n").arg(varDir.absolutePath());
constantsRootStream << QString("PATCH_ROOT_DIR=%1\n").arg(patchesDir.absolutePath());
constantsRootStream << QString("FILES_DIR=%1\n").arg(filesDir.absolutePath());
constantsRootStream << QString("NOTIFY_WRAPPER_EXEC=echo\n");
constantsRoot.close();
// Build AUSMT
QString buildName = srcDir.absoluteFilePath(BUILD_SH);
QFile build (buildName);
QVERIFY(build.exists());
QVERIFY(build.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
QProcess buildProcess;
buildProcess.setWorkingDirectory(srcDir.absolutePath());
buildProcess.start(PYTHON, QStringList() << buildName);
buildProcess.waitForFinished(-1);
QCOMPARE(buildProcess.exitCode(), 0);
foreach (const QString &fileName, dir.entryList(QDir::Files)) {
QFile file (dir.absoluteFilePath(fileName));
QVERIFY(file.setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ExeUser));
}
// Remove src
QVERIFY(srcDir.removeRecursively());
// Prepare patches
preparePatches();
}
示例14: setUrlToFile
int QgsSOAPRequestHandler::setUrlToFile( QImage* img )
{
QString uri;
QFile theFile;
QDir tmpDir;
QgsDebugMsg( "Entering." );
if ( findOutHostAddress( uri ) != 0 )
{
return 1;
}
#ifdef Q_OS_WIN
if ( !QFile::exists( QDir::currentPath() + "/tmp" ) )
{
QDir::current().mkdir( "tmp" );
}
tmpDir = QDir( QDir::currentPath() + "/tmp" );
#else // Q_OS_WIN
tmpDir = QDir( "/tmp" );
#endif
QgsDebugMsg( "Path to tmpDir is: " + tmpDir.absolutePath() );
//create a random folder under /tmp with map.jpg/png in it
//and return the link to the client
srand( time( nullptr ) );
int randomNumber = rand();
QString folderName = QString::number( randomNumber );
if ( !QFile::exists( tmpDir.absolutePath() + "/mas_tmp" ) )
{
QgsDebugMsg( "Trying to create mas_tmp folder" );
if ( !tmpDir.mkdir( "mas_tmp" ) )
{
return 2;
}
}
QDir tmpMasDir( tmpDir.absolutePath() + "/mas_tmp" );
if ( !tmpMasDir.mkdir( folderName ) )
{
QgsDebugMsg( "Trying to create random folder" );
return 3;
}
QgsDebugMsg( "Temp. folder is: " + tmpMasDir.absolutePath() + "/" + folderName );
if ( mFormat == "JPG" )
{
theFile.setFileName( tmpMasDir.absolutePath() + "/" + folderName + "/map.jpg" );
uri.append( "/mas_tmp/" + folderName + "/map.jpg" );
}
else if ( mFormat == "PNG" )
{
theFile.setFileName( tmpMasDir.absolutePath() + "/" + folderName + "/map.png" );
uri.append( "/mas_tmp/" + folderName + "/map.png" );
}
if ( !theFile.open( QIODevice::WriteOnly ) )
{
QgsDebugMsg( "Error, could not open file" );
return 4;
}
if ( !img->save( &theFile, mFormat.toLocal8Bit().data(), -1 ) )
{
QgsDebugMsg( "Error, could not save image" );
return 5;
}
QDomDocument xmlResponse;
QDomElement envelopeElement = xmlResponse.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "Envelope" );
xmlResponse.appendChild( envelopeElement );
QDomElement bodyElement = xmlResponse.createElementNS( "http://schemas.xmlsoap.org/soap/envelope/", "Body" );
envelopeElement.appendChild( bodyElement );
QDomElement getMapResponseElement = xmlResponse.createElementNS( "http://www.eu-orchestra.org/services/ms", "getMapResponse" );
QDomElement ahrefElement = xmlResponse.createElement( "a" );
ahrefElement.setAttribute( "href", uri );
//QString href("<a href=\""+uri+"\">"+uri+"</a>");
QDomText uriNode = xmlResponse.createTextNode( uri );
ahrefElement.appendChild( uriNode );
//getMapResponseElement.appendChild(uriNode);
getMapResponseElement.appendChild( ahrefElement );
bodyElement.appendChild( getMapResponseElement );
QByteArray xmlByteArray = xmlResponse.toByteArray();
setHttpResponse( &xmlByteArray, "text/xml" );
return 0;
}
示例15: setupDirectory
void setupDirectory(const QDir &dir)
{
if (!dir.mkdir("bin"))
abort();
if (!dir.mkdir("doc"))
abort();
if (!dir.mkdir("examples"))
abort();
if (!dir.mkdir("imports"))
abort();
if (!dir.mkdir("include"))
abort();
if (!dir.mkdir("lib"))
abort();
if (!dir.mkdir("lib/cmake"))
abort();
if (!dir.mkdir("lib/pkgconfig"))
abort();
if (!dir.mkdir("mkspecs"))
abort();
if (!dir.mkdir("phrasebooks"))
abort();
if (!dir.mkdir("plugins"))
abort();
if (!dir.mkdir("qml"))
abort();
if (!dir.mkdir("translations"))
abort();
}