本文整理汇总了C++中QFile::close方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::close方法的具体用法?C++ QFile::close怎么用?C++ QFile::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFile
的用法示例。
在下文中一共展示了QFile::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void FileEnvProcess::start(const QString& program, const QStringList& arguments, OpenMode mode)
{
QByteArray programBa = program.toLatin1();
const char* programCharPtr = programBa.data();
QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
tmpRideFilePtr->open(QIODevice::WriteOnly);
addHeader(tmpRideFilePtr);
tmpRideFilePtr->write(programCharPtr);
tmpRideFilePtr->write(" ");
QByteArray tmpByteArray;
for(size_t i = 0; i < arguments.size(); i++)
{
tmpByteArray.append(arguments.at(i) + " ");
tmpRideFilePtr->write(tmpByteArray);
tmpByteArray.clear();
}
tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
tmpRideFilePtr->write("\necho \"Finished execution.\"");
tmpRideFilePtr->close();
QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
testProcess.execute("chmod", stringlst);
testProcess.start(*tmpFileNameStrPtr, mode); //don't run this->execute; this would result in infinate recursion!!!
testProcess.waitForFinished(-1);
QByteArray output = testProcess.readAllStandardOutput();
cout << cct::bold("\nOutput: ") << output.data() << ":End" << endl;
outputLocTePtr->append(output.data());
cout << "exiting FileEnvProcess::start(...)" << endl;
}
示例2: save
/**
* @brief Article::save
*/
void Article::save(){
//1er cas si le fichier a déjà été sauvegardé, on ne le sauvegarde pas une nouvelle fois
if (!modified)
return;
//2e cas
else {
QFile fichier (NotesManager::getInstance()->getFilename(id));
//Si le fichier n'est pas encore crée, il le crée
if (fichier.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream flux(&fichier);
flux.setCodec("UTF-8");
//Type de la note
flux << "article" << endl;
//Informations sur la note
flux << title << endl;
flux << content << endl;
modified = false;
fichier.close();
}
else {
throw NoteException(QObject::tr("Unable to load the file ") + fichier.fileName() + QObject::tr(" for saving"));
}
}
}
示例3: fi
bool QMacPasteboardMimeQt3Any::loadMimeRegistry()
{
if(!library_file.isOpen()) {
if(!qt_mac_openMimeRegistry(true, QIODevice::ReadWrite, library_file)) {
QFile global;
if(qt_mac_openMimeRegistry(true, QIODevice::ReadOnly, global)) {
qt_mac_loadMimeRegistry(global, mime_registry, current_max);
global.close();
}
if(!qt_mac_openMimeRegistry(false, QIODevice::ReadWrite, library_file)) {
qWarning("QMacPasteboardMimeAnyQt3Mime: Failure to open mime resources %s -- %s", library_file.fileName().toLatin1().constData(),
library_file.errorString().toLatin1().constData());
return false;
}
}
}
QFileInfo fi(library_file);
if(!mime_registry_loaded.isNull() && mime_registry_loaded == fi.lastModified())
return true;
mime_registry_loaded = fi.lastModified();
qt_mac_loadMimeRegistry(library_file, mime_registry, current_max);
return true;
}
示例4: init
void Session::init() {
qDebug() << "Loading sessions...";
QFile* configFile = new QFile ( Core::configurationPath().absolutePath() +"/sessions.xml" );
s_elems.clear();
if ( s_dom ) {
s_dom->clear();
delete s_dom;
}
s_dom = new QDomDocument ( "Sessions" );
if ( configFile->exists() ) {
configFile->open ( QIODevice::ReadOnly );
s_dom->setContent ( configFile );
const QDomElement documentElem = s_dom->documentElement();
const QDomNodeList l_domList = documentElem.elementsByTagName ( "Session" );
for ( int i = 0; i < l_domList.count(); i++ ) {
QDomElement l_node = l_domList.at ( i ).toElement();
const QUuid l_uuid ( l_node.attribute ( "uuid" ) );
s_elems.insert ( l_uuid, new QDomElement ( l_domList.at ( i ).toElement() ) );
}
qDebug() << l_domList.count() << "sessions loaded.";
} else {
configFile->open ( QIODevice::WriteOnly | QIODevice::Truncate );
QDomElement l_elem = s_dom->createElement ( "Sessions" );
s_dom->appendChild ( l_elem );
configFile->write ( s_dom->toString ( 4 ).toLocal8Bit() );
qDebug() << "Created session listing.";
}
configFile->close();
}
示例5: save
void AutoMateUi::save() {
std::vector<Version> vers = applications_model->getSelected();
QDomDocument doc("export");
QDomElement root = doc.createElement("template");
doc.appendChild(root);
for(std::vector<Version>::iterator itr = vers.begin(); itr != vers.end(); ++itr)
{
QDomElement inst = doc.createElement("install");
if (! itr->is_last)
inst.setAttribute("version",itr->version().c_str());
QDomText name = doc.createTextNode(itr->name().c_str());
inst.appendChild(name);
root.appendChild(inst);
}
QString flname = QFileDialog::getSaveFileName(this,"Select file to save", "", "XML files(*.xml)");
QFile *fl = new QFile(flname);
if (!fl->open(QIODevice::WriteOnly | QIODevice::Text)) {
statusBar()->showMessage("Writing to file failed", status_message_delay);
return;
}
fl->write(doc.toString().toLocal8Bit());
fl->close();
statusBar()->showMessage("Selection saved", status_message_delay);
}
示例6: Btn_onclicked
void Widget::Btn_onclicked()
{
// 创建文件操作对象
QFile *fp = new QFile("test.txt");
// 检查文件是否存在
if (!fp->exists()) {
QMessageBox::critical(this, "Error", fp->errorString());
return;
}
// 打开文件
if (!fp->open(QIODevice::ReadWrite|QIODevice::Text)) {
QMessageBox::critical(this, "Error", fp->errorString());
return;
}
// 使用文本流对文件进行操作
QTextStream out(fp);
//out.setCodec("UTF-8"); // 设置编码
QString text = out.readAll();
ui->textEdit->setText(text);
// 移动指针到末端并写入
//fp->seek(fp->size());
//out << "\r\n" << QString("321TEST");
// 关闭文件
fp->close();
delete fp;
// 设置textedit滚动到末端
QTextCursor cursor = ui->textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
ui->textEdit->setTextCursor(cursor);
}
示例7: SetOuputDefaultDir
void MainWindow::SetOuputDefaultDir()
{
QString path = "configure.conf";
QByteArray byteArrayData = 0;
QFile* defaultPathFile = new QFile(path);
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(),
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
int x = QString::compare(dir, _defaultOutputPath, Qt::CaseInsensitive);
if (x != 0)
{
defaultPathFile->remove(path);
defaultPathFile->setFileName(path);
if (defaultPathFile->open(QIODevice::WriteOnly | QIODevice::Text) == true)
{
byteArrayData = dir.toLatin1();
defaultPathFile->write(byteArrayData);
}
_defaultOutputPath = dir;
ui->_leDefaultDirPath->setText(dir);
}
defaultPathFile->close();
}
示例8: loadCfgFile
void form_UserRegistration::loadCfgFile()
{
QFile cfgFile;
QTextStream rStream(&cfgFile);
QString line;
vector <QString> str;
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("cp1251"));
cfgFile.setFileName("ovd.cfg");
cfgFile.open(QIODevice::ReadOnly | QIODevice::Text);
do // загружаем названия частоиспользуемых ОВД
{
line = rStream.readLine();
if (line.contains("len_ovd"))
{
len_ovd.ovd = line.remove(QRegExp("(.*=)"));
// cout << len_ovd.toAscii().data() << endl;
}
else
if (line.contains("okt_ovd"))
{
okt_ovd.ovd = line.remove(QRegExp("(.*=)"));
// cout << okt_ovd.toAscii().data() << endl;
}
else
if (line.contains("perv_ovd"))
{
perv_ovd.ovd = line.remove(QRegExp("(.*=)"));
// cout << perv_ovd.toAscii().data() << endl;
}
else
if (line.contains("len_oufms"))
{
len_oufms.ovd = line.remove(QRegExp("(.*=)"));
// cout << len_oufms.toAscii().data() << endl;
}
else
if (line.contains("okt_oufms"))
{
okt_oufms.ovd = line.remove(QRegExp("(.*=)"));
// cout << okt_oufms.toAscii().data() << endl;
}
else
if (line.contains("perv_oufms"))
{
perv_oufms.ovd = line.remove(QRegExp("(.*=)"));
// cout << perv_oufms.toAscii().data() << endl;
}
}
while (!line.isNull());
cfgFile.close();
cfgFile.setFileName("streets.cfg");
cfgFile.open(QIODevice::ReadOnly | QIODevice::Text);
do // загружаем списки улиц и распределяем их по овд
{ // так в лень было переписывать все в одну функцию... поэтому пока что так =)
str.clear();
line = rStream.readLine();
if (line.contains("len_ovd="))
{
int amount = line.remove(QRegExp("(.*=)")).toInt() - 1;
for (int i = 0; i <= amount; i++) // пока не указанное количество улиц
{
line = rStream.readLine();
str.push_back(line);
}
len_ovd.streets = str;
}
else
if (line.contains("okt_ovd="))
{
int amount = line.remove(QRegExp("(.*=)")).toInt() - 1;
for (int i = 0; i <= amount; i++) // пока не указанное количество улиц
{
line = rStream.readLine();
str.push_back(line);
}
okt_ovd.streets = str;
}
else
if (line.contains("perv_ovd="))
{
int amount = line.remove(QRegExp("(.*=)")).toInt() - 1;
for (int i = 0; i <= amount; i++) // пока не указанное количество улиц
{
line = rStream.readLine();
str.push_back(line);
}
perv_ovd.streets = str;
}
} while (!line.isNull());
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
}
示例9: if
//.........这里部分代码省略.........
uint32_t binVersion_u32 = static_cast<uint32_t>(ccObject::GetCurrentDBVersion());
if (out.write((char*)&binVersion_u32,4) < 0)
return CC_FERR_WRITING;
CC_FILE_ERROR result = CC_FERR_NO_ERROR;
//we check if all linked entities are in the sub tree we are going to save
//(such as vertices for a mesh!)
ccHObject::Container toCheck;
toCheck.push_back(object);
while (!toCheck.empty())
{
ccHObject* currentObject = toCheck.back();
assert(currentObject);
toCheck.pop_back();
//we check objects that have links to other entities (meshes, polylines, etc.)
std::unordered_set<const ccHObject*> dependencies;
if (currentObject->isA(CC_TYPES::MESH) || currentObject->isKindOf(CC_TYPES::PRIMITIVE))
{
ccMesh* mesh = ccHObjectCaster::ToMesh(currentObject);
if (mesh->getAssociatedCloud())
dependencies.insert(mesh->getAssociatedCloud());
if (mesh->getMaterialSet())
dependencies.insert(mesh->getMaterialSet());
if (mesh->getTexCoordinatesTable())
dependencies.insert(mesh->getTexCoordinatesTable());
if (mesh->getTexCoordinatesTable())
dependencies.insert(mesh->getTexCoordinatesTable());
}
else if (currentObject->isA(CC_TYPES::SUB_MESH))
{
dependencies.insert(currentObject->getParent());
}
else if (currentObject->isKindOf(CC_TYPES::POLY_LINE))
{
CCLib::GenericIndexedCloudPersist* cloud = static_cast<ccPolyline*>(currentObject)->getAssociatedCloud();
ccPointCloud* pc = dynamic_cast<ccPointCloud*>(cloud);
if (pc)
dependencies.insert(pc);
else
ccLog::Warning(QString("[BIN] Poyline '%1' is associated to an unhandled vertices structure?!").arg(currentObject->getName()));
}
else if (currentObject->isKindOf(CC_TYPES::SENSOR))
{
ccIndexedTransformationBuffer* buffer = static_cast<ccSensor*>(currentObject)->getPositions();
if (buffer)
dependencies.insert(buffer);
}
else if (currentObject->isA(CC_TYPES::LABEL_2D))
{
cc2DLabel* label = static_cast<cc2DLabel*>(currentObject);
for (unsigned i=0;i<label->size();++i)
{
const cc2DLabel::PickedPoint& pp = label->getPoint(i);
dependencies.insert(pp.cloud);
}
}
else if (currentObject->isA(CC_TYPES::FACET))
{
ccFacet* facet = static_cast<ccFacet*>(currentObject);
if (facet->getOriginPoints())
dependencies.insert(facet->getOriginPoints());
if (facet->getContourVertices())
dependencies.insert(facet->getContourVertices());
if (facet->getPolygon())
dependencies.insert(facet->getPolygon());
if (facet->getContour())
dependencies.insert(facet->getContour());
}
else if (currentObject->isKindOf(CC_TYPES::IMAGE))
{
ccImage* image = static_cast<ccImage*>(currentObject);
if (image->getAssociatedSensor())
dependencies.insert(image->getAssociatedSensor());
}
for (std::unordered_set<const ccHObject*>::const_iterator it = dependencies.begin(); it != dependencies.end(); ++it)
{
if (!object->find((*it)->getUniqueID()))
{
ccLog::Warning(QString("[BIN] Dependency broken: entity '%1' must also be in selection in order to save '%2'").arg((*it)->getName()).arg(currentObject->getName()));
result = CC_FERR_BROKEN_DEPENDENCY_ERROR;
}
}
//release some memory...
dependencies.clear();
for (unsigned i=0; i<currentObject->getChildrenNumber(); ++i)
toCheck.push_back(currentObject->getChild(i));
}
if (result == CC_FERR_NO_ERROR)
if (!object->toFile(out))
result = CC_FERR_CONSOLE_ERROR;
out.close();
return result;
}
示例10: parseFile
bool XMLTVParser::parseFile(
QString filename, QList<ChanInfo> *chanlist,
QMap<QString, QList<ProgInfo> > *proglist)
{
QDomDocument doc;
QFile f;
if (!dash_open(f, filename, QIODevice::ReadOnly))
{
VERBOSE(VB_IMPORTANT, QString("Error unable to open '%1' for reading.")
.arg(filename));
return false;
}
QString errorMsg = "unknown";
int errorLine = 0;
int errorColumn = 0;
if (!doc.setContent(&f, &errorMsg, &errorLine, &errorColumn))
{
VERBOSE(VB_IMPORTANT, QString("Error in %1:%2: %3")
.arg(errorLine).arg(errorColumn).arg(errorMsg));
f.close();
return true;
}
f.close();
// now we calculate the localTimezoneOffset, so that we can fix
// the programdata if needed
QString config_offset = gCoreContext->GetSetting("TimeOffset", "None");
// we disable this feature by setting it invalid (> 840min = 14hr)
int localTimezoneOffset = 841;
if (config_offset == "Auto")
{
// we mark auto with the -ve of the disable magic number
localTimezoneOffset = -841;
}
else if (config_offset != "None")
{
localTimezoneOffset = TimezoneToInt(config_offset);
if (abs(localTimezoneOffset) > 840)
{
VERBOSE(VB_XMLTV, QString("Ignoring invalid TimeOffset %1")
.arg(config_offset));
localTimezoneOffset = 841;
}
}
QDomElement docElem = doc.documentElement();
QUrl baseUrl(docElem.attribute("source-data-url", ""));
QUrl sourceUrl(docElem.attribute("source-info-url", ""));
if (sourceUrl.toString() == "http://labs.zap2it.com/")
{
VERBOSE(VB_IMPORTANT, "Don't use tv_grab_na_dd, use the"
"internal datadirect grabber.");
exit(GENERIC_EXIT_SETUP_ERROR);
}
QString aggregatedTitle;
QString aggregatedDesc;
QString groupingTitle;
QString groupingDesc;
QDomNode n = docElem.firstChild();
while (!n.isNull())
{
QDomElement e = n.toElement();
if (!e.isNull())
{
if (e.tagName() == "channel")
{
ChanInfo *chinfo = parseChannel(e, baseUrl);
chanlist->push_back(*chinfo);
delete chinfo;
}
else if (e.tagName() == "programme")
{
ProgInfo *pginfo = parseProgram(e, localTimezoneOffset);
if (pginfo->startts == pginfo->endts)
{
/* Not a real program : just a grouping marker */
if (!pginfo->title.isEmpty())
groupingTitle = pginfo->title + " : ";
if (!pginfo->description.isEmpty())
groupingDesc = pginfo->description + " : ";
}
else
{
if (pginfo->clumpidx.isEmpty())
{
if (!groupingTitle.isEmpty())
{
pginfo->title.prepend(groupingTitle);
//.........这里部分代码省略.........
示例11: str
const KstTimezones::ZoneMap KstTimezones::allZones()
{
// Have we already done all the hard work? If not, create the cache.
if (m_zones)
return *m_zones;
m_zones = new ZoneMap();
// Go read the database.
//
// On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
// is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure.
//
// For Unix its all easy except knowing where to look. Try the LSB location first.
QFile f;
m_zoneinfoDir = "/usr/share/zoneinfo";
f.setName(m_zoneinfoDir + "/zone.tab");
if (!f.open(IO_ReadOnly))
{
m_zoneinfoDir = "/usr/lib/zoneinfo";
f.setName(m_zoneinfoDir + "/zone.tab");
if (!f.open(IO_ReadOnly))
{
m_zoneinfoDir = ::getenv("TZDIR");
f.setName(m_zoneinfoDir + "/zone.tab");
if (m_zoneinfoDir.isEmpty() || !f.open(IO_ReadOnly))
{
// Solaris support. Synthesise something that looks like a zone.tab.
//
// /bin/grep -h ^Zone /usr/share/lib/zoneinfo/src/* | /bin/awk '{print "??\t+9999+99999\t" $2}'
//
// where the country code is set to "??" and the lattitude/longitude
// values are dummies.
m_zoneinfoDir = "/usr/share/lib/zoneinfo";
KTempFile temp;
KShellProcess reader;
reader << "/bin/grep" << "-h" << "^Zone" << m_zoneinfoDir << "/src/*" << temp.name() << "|" <<
"/bin/awk" << "'{print \"??\\t+9999+99999\\t\" $2}'";
// Note the use of blocking here...it is a trivial amount of data!
temp.close();
reader.start(KProcess::Block);
f.setName(temp.name());
if (!temp.status() || !f.open(IO_ReadOnly))
{
return *m_zones;
}
}
}
}
// Parse the zone.tab.
QTextStream str(&f);
QRegExp lineSeparator("[ \t]");
QRegExp ordinateSeparator("[+-]");
KSharedPtr<KstTimezoneSource> db(new KstTimezoneSource(m_zoneinfoDir));
while (!str.atEnd())
{
QString line = str.readLine();
if (line.isEmpty() || '#' == line[0])
continue;
QStringList tokens = KStringHandler::perlSplit(lineSeparator, line, 4);
if (tokens.count() < 3)
{
continue;
}
// Got three tokens. Now check for two ordinates plus first one is "".
QStringList ordinates = KStringHandler::perlSplit(ordinateSeparator, tokens[1], 2);
if (ordinates.count() < 2)
{
continue;
}
float latitude = convertCoordinate(ordinates[1]);
float longitude = convertCoordinate(ordinates[2]);
// Add entry to list.
if (tokens[0] == "??")
tokens[0] = "";
KstTimezone *timezone = new KstTimezone(db, tokens[2], tokens[0], latitude, longitude, tokens[3]);
add(timezone);
}
f.close();
return *m_zones;
}
示例12: genButtonClicked
void ConfigStation::genButtonClicked()
{
QDir dir;
dir.setPath( c.PARAMSDIR + "/staInfo");
QStringList files;
QString fileName = "*.sta";
files = dir.entryList(QStringList(fileName), QDir::Files | QDir::NoSymLinks);
for(int i=0;i<files.count();i++)
{
if(files[i] == filenameLE->text() + ".sta")
{
if(!korean) QMessageBox::warning( this, "Information", "Duplicate Station file name.\nPlease use other name.");
else QMessageBox::warning( this, codec->toUnicode("정보"), codec->toUnicode("중복되는 파일명을 가진 파일이 존재합니다.\n다른 파일명을 사용하십시오."));
return;
}
}
if(filenameLE->text() == "")
{
if(!korean) QMessageBox::warning( this, "Information", "Please Input a file name.");
else QMessageBox::warning( this, codec->toUnicode("정보"), codec->toUnicode("파일명을 입력하십시오.(영문, 숫자만 사용)") );
return;
}
if(descLE->text() == "")
{
QMessageBox::warning( this, "Information", "Please Input a description.");
if(!korean) QMessageBox::warning( this, "Information", "Please Input a description.");
else QMessageBox::warning( this, codec->toUnicode("정보"), codec->toUnicode("관측소 설명란을 입력하십시오.(영문, 숫자만 사용)") );
return;
}
int count = 0;
for(int i=0;i<sta.size();i++)
{
if(sta[count] == "")
break;
count++;
}
QFile file;
/* generate station file. */
QString staFileName = c.PARAMSDIR + "/staInfo/" + filenameLE->text() + ".sta";
file.setFileName( staFileName );
if( file.open( QIODevice::WriteOnly ) )
{
QTextStream stream( &file ) ;
stream << "Filename:" << filenameLE->text() << "\n";
stream << "Description:" << descLE->text() << "\n" ;
for(int i=0;i<count;i++)
{
if(comp[i] == "Z/N/E")
{
stream << sta[i] << " " << chan[i] << "Z" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
stream << sta[i] << " " << chan[i] << "N" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
stream << sta[i] << " " << chan[i] << "E" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
}
else if(comp[i] == "Z")
stream << sta[i] << " " << chan[i] << "Z" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
else if(comp[i] == "N")
stream << sta[i] << " " << chan[i] << "N" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
else if(comp[i] == "E")
stream << sta[i] << " " << chan[i] << "E" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
else if(comp[i] == "N/E")
{
stream << sta[i] << " " << chan[i] << "N" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
stream << sta[i] << " " << chan[i] << "E" << " " << loc[i] << " " << net[i] << " " << lat[i] << " " << lon[i] << " " << elev[i] << "\n";
}
}
file.close() ;
}
QString cmd = "cp " + staFileName + " " + c.PARAMSDIR + "/sta.info";
system(cmd.toLatin1().data());
STAFILE stafile;
FileGenerator *gen = new FileGenerator;
stafile = gen->makeSTAFILE(c, false);
gen->pick_ew_gen(c, stafile);
gen->pick_FP_gen(c, stafile);
gen->hinv_gen(c, stafile);
gen->tanklist_gen(c, stafile);
gen->binder_gen(c, stafile);
gen->ew2mseed_gen(c, stafile);
gen->nlloc_gen(false, c, stafile);
QMessageBox msgBox;
if(!korean) msgBox.setText("Staions Info. file generated and loaded.");
else msgBox.setText(codec->toUnicode("관측소 정보 파일 생성 완료."));
msgBox.exec();
accept();
}
示例13: nextSPICE
/*!
* \brief Converts a spice netlist into Qucs format and outputs it.
*/
void SimMessage::nextSPICE()
{
QString Line;
for(;;) { // search for next SPICE component
Line = *(Collect.begin());
Collect.erase(Collect.begin());
if(Line == "*") { // worked on all components ?
startSimulator(); // <<<<<================== go on ===
return;
}
// FIXME #warning SPICE section below not being covered?
qDebug() << "goin thru SPICE branch on simmmessage.cpp";
if(Line.left(5) == "SPICE") {
if(Line.at(5) != 'o') insertSim = true;
else insertSim = false;
break;
}
Collect.append(Line);
}
QString FileName = Line.section('"', 1,1);
Line = Line.section('"', 2); // port nodes
if(Line.isEmpty()) makeSubcircuit = false;
else makeSubcircuit = true;
QString prog;
QStringList com;
prog = QucsSettings.BinDir + "qucsconv" + executableSuffix;
if(makeSubcircuit)
com << "-g" << "_ref";
com << "-if" << "spice" << "-of" << "qucs";
QFile SpiceFile;
if(FileName.indexOf(QDir::separator()) < 0) // add path ?
SpiceFile.setFileName(QucsSettings.QucsWorkDir.path() + QDir::separator() + FileName);
else
SpiceFile.setFileName(FileName);
if(!SpiceFile.open(QIODevice::ReadOnly)) {
ErrText->appendPlainText(tr("ERROR: Cannot open SPICE file \"%1\".").arg(FileName));
FinishSimulation(-1);
return;
}
if(makeSubcircuit) {
Stream << "\n.Def:" << misc::properName(FileName) << " ";
Line.replace(',', ' ');
Stream << Line;
if(!Line.isEmpty()) Stream << " _ref";
}
Stream << "\n";
ProgressText = "";
qDebug() << "start QucsConv" << prog << com.join(" ");
SimProcess.start(prog, com);
if(!SimProcess.Running) {
ErrText->appendPlainText(tr("SIM ERROR: Cannot start QucsConv!"));
FinishSimulation(-1);
return;
}
QByteArray SpiceContent = SpiceFile.readAll();
SpiceFile.close();
QString command(SpiceContent); //to convert byte array to string
SimProcess.setStandardInputFile(command); //? FIXME works?
qDebug() << command;
connect(&SimProcess, SIGNAL(wroteToStdin()), SLOT(slotCloseStdin()));
}
示例14: QWebView
MainWindow::MainWindow(const QUrl& url)
{
progress = 0;
QFile file;
file.setFileName(":/jquery.min.js");
file.open(QIODevice::ReadOnly);
jQuery = file.readAll();
jQuery.append("\nvar qt = { 'jQuery': jQuery.noConflict(true) };");
file.close();
//! [1]
QNetworkProxyFactory::setUseSystemConfiguration(true);
//! [2]
view = new QWebView(this);
view->load(url);
connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
locationEdit = new QLineEdit(this);
locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy());
connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));
QToolBar *toolBar = addToolBar(tr("导航"));
toolBar->addAction(view->pageAction(QWebPage::Back));
toolBar->addAction(view->pageAction(QWebPage::Forward));
toolBar->addAction(view->pageAction(QWebPage::Reload));
toolBar->addAction(view->pageAction(QWebPage::Stop));
toolBar->addWidget(locationEdit);
//! [2]
QMenu *fileMenu = menuBar()->addMenu(tr("文件(&F)"));
QAction *newWindowAction = new QAction(tr("新建窗口"),this);
connect(newWindowAction, SIGNAL(triggered()),SLOT(newWindow()));
fileMenu->addAction(newWindowAction);
QAction *closeWindowAction = new QAction(tr("关闭窗口"),this);
connect(closeWindowAction, SIGNAL(triggered()),SLOT(closeWindow()));
fileMenu->addAction(closeWindowAction);
QMenu *viewMenu = menuBar()->addMenu(tr("查看(&V)"));
QAction* viewSourceAction = new QAction(tr("页面源代码"), this);
connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource()));
viewMenu->addAction(view->pageAction(QWebPage::Stop));
viewMenu->addAction(view->pageAction(QWebPage::Reload));
viewMenu->addSeparator();
viewMenu->addAction(viewSourceAction);
//! [3]
QMenu *historyMenu = menuBar()->addMenu(tr("历史(&H)"));
historyMenu->addAction(view->pageAction(QWebPage::Back));
historyMenu->addAction(view->pageAction(QWebPage::Forward));
QMenu *effectMenu = menuBar()->addMenu(tr("效果(&E)"));
effectMenu->addAction(tr("高亮所有链接"), this, SLOT(highlightAllLinks()));
rotateAction = new QAction(this);
rotateAction->setIcon(style()->standardIcon(QStyle::SP_FileDialogDetailedView));
rotateAction->setCheckable(true);
rotateAction->setText(tr("倒转图像"));
connect(rotateAction, SIGNAL(toggled(bool)), this, SLOT(rotateImages(bool)));
effectMenu->addAction(rotateAction);
QMenu *toolsMenu = menuBar()->addMenu(tr("工具(&T)"));
toolsMenu->addAction(tr("移除 GIF 动画"), this, SLOT(removeGifImages()));
toolsMenu->addAction(tr("移除所有内联框架"), this, SLOT(removeInlineFrames()));
toolsMenu->addAction(tr("移除所有对象元素"), this, SLOT(removeObjectElements()));
toolsMenu->addAction(tr("移除所有嵌入元素"), this, SLOT(removeEmbeddedElements()));
QMenu *helpMenu = menuBar()->addMenu(tr("帮助(&H)"));
helpMenu->addAction(tr("关于 Looplorer"), this, SLOT(aboutLooplorer()));
setCentralWidget(view);
setUnifiedTitleAndToolBarOnMac(true);
view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
clickLink();
windowNum++;
}
示例15: parseToFile
void Parser::parseToFile()
{
dirFilters();
#ifdef Q_OS_LINUX
if(!itsDir->exists(itsArgv[1]))
#else
if(!itsDir->exists(QString::fromLocal8Bit(itsArgv[1])))
#endif
{
qCritical() << "EROR: path to list don't exist\n";
return;
}
#ifdef Q_OS_LINUX
itsDir->cd(itsArgv[1]);
#else
itsDir->cd(QString::fromLocal8Bit(itsArgv[1]));
#endif
QFile file;
QFileInfo info;
#ifdef Q_OS_LINUX
file.setFileName(itsArgv[2]);
#else
file.setFileName(QString::fromLocal8Bit(itsArgv[2]));
#endif
info.setFile(file);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qCritical() << "ERROR opening file:" << file.fileName();
return;
}
QTextStream out(&file);
#ifdef Q_OS_LINUX
out << "ROOT DIR:\n" << QDir::toNativeSeparators(itsArgv[1]) << ":" << "\n";
#else
out << "ROOT DIR:\n" << QDir::toNativeSeparators(QString::fromLocal8Bit(itsArgv[1])) << ":" << "\n";
#endif
QString filePath = info.absoluteFilePath();
if(itsOptions.testFlag(RECURSIVE))
{
recursive(filePath, out);
}
else
{
notRecursive(filePath, out);
}
QString p = info.filePath();
QString n = info.fileName();
QTextStream itsOut(stdout);
itsOut << "\nSaving file: " << info.fileName()
<< " into "
<< QDir::toNativeSeparators(p.remove(p.size() - n.size(), p.size() - 1))
<< "\n";
file.close();
}