本文整理汇总了C++中qstringlist::const_iterator::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::isEmpty方法的具体用法?C++ const_iterator::isEmpty怎么用?C++ const_iterator::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::const_iterator
的用法示例。
在下文中一共展示了const_iterator::isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseURL
static KUrl parseURL( int mRealArgType, const QString& str )
{
if ( mRealArgType == 33 ) { // LDAP server
// The format is HOSTNAME:PORT:USERNAME:PASSWORD:BASE_DN
QStringList items = str.split( ':' );
if ( items.count() == 5 ) {
QStringList::const_iterator it = items.constBegin();
KUrl url;
url.setProtocol( "ldap" );
url.setHost( urlpart_decode( *it++ ) );
bool ok;
const int port = (*it++).toInt( &ok );
if ( ok )
url.setPort( port );
else if ( !it->isEmpty() )
kWarning(5150) <<"parseURL: malformed LDAP server port, ignoring: \"" << *it << "\"";
url.setPath( "/" ); // workaround KUrl parsing bug
url.setUser( urlpart_decode( *it++ ) );
url.setPass( urlpart_decode( *it++ ) );
url.setQuery( urlpart_decode( *it ) );
return url;
} else
kWarning(5150) <<"parseURL: malformed LDAP server:" << str;
}
// other URLs : assume wellformed URL syntax.
return KUrl( str );
}
示例2: parseQstat
void SessionListWidget::parseQstat(QString const& qstat)
{
QStringList lines = qstat.split('\n');
JobDefinition *job = NULL;
QMap<QString, QString> jobSpec, jobVars;
QRegExp rxJobId("[0-9]+\\.pbs01");
QRegExp rxKey("[A-Za-z_\\.]+");
QString key(""), value("");
for(QStringList::const_iterator line = lines.begin();
line != lines.end();
line++)
{
if(line->isEmpty()) { /* empty */ }
else if(line->startsWith("Job Id:")) {
if(job != NULL) {
job->update(jobSpec);
sessions.append(*job);
delete job;
job = NULL;
jobSpec.clear();
jobVars.clear();
}
rxJobId.indexIn(*line);
job = new JobDefinition(rxJobId.cap());
}
else if(line->startsWith(" ")) { /* keys start with 4 spaces */
if(key == "Variable_List") {
QStringList vars(jobSpec[key].split(","));
for(QStringList::const_iterator i = vars.begin();
i != vars.end();
i++)
{
int eq = i->indexOf('=');
jobVars.insert(i->left(eq), i->mid(eq + 1));
}
}
rxKey.indexIn(*line);
key = rxKey.cap(0);
value = line->mid(line->indexOf('=') + 2);
jobSpec.insert(key, value);
}
else if(line->at(0) == '\t') {
/* append to the previous key */
jobSpec[key].append(line->mid(1));
}
}
if(job) {
job->update(jobSpec);
sessions.append(*job);
}
qDebug() << sessions;
}
示例3: absoluteFileName
QString CreateDesktopEntryOperation::absoluteFileName()
{
const QString filename = arguments().first();
// give filename is already absolute
if (QFileInfo(filename).isAbsolute())
return filename;
// we're not searching for the first time, let's re-use the old value
if (hasValue(QLatin1String("directory")))
return QDir(value(QLatin1String("directory")).toString()).absoluteFilePath(filename);
const QProcessEnvironment env;
QStringList XDG_DATA_DIRS = env.value(QLatin1String("XDG_DATA_DIRS")).split(QLatin1Char(':'),
QString::SkipEmptyParts);
QStringList XDG_DATA_HOME = env.value(QLatin1String("XDG_DATA_HOME")).split(QLatin1Char(':'),
QString::SkipEmptyParts);
XDG_DATA_DIRS.push_back(QLatin1String("/usr/share")); // default path
XDG_DATA_HOME.push_back(QDir::home().absoluteFilePath(QLatin1String(".local/share"))); // default path
const QStringList directories = XDG_DATA_DIRS + XDG_DATA_HOME;
QString directory;
for (QStringList::const_iterator it = directories.begin(); it != directories.end(); ++it) {
if (it->isEmpty())
continue;
directory = QDir(*it).absoluteFilePath(QLatin1String("applications"));
QDir dir(directory);
// let's see whether this dir exists or we're able to create it
if (!dir.exists() && !QDir().mkpath(directory))
continue;
// we just try whether we're able to open the file in ReadWrite
QFile file(QDir(directory).absoluteFilePath(filename));
const bool existed = file.exists();
if (!file.open(QIODevice::ReadWrite))
continue;
file.close();
if (!existed)
file.remove();
break;
}
if (!QDir(directory).exists())
QDir().mkpath(directory);
setValue(QLatin1String("directory"), directory);
return QDir(directory).absoluteFilePath(filename);
}
示例4: getCpuUsageInformation
void MCpuMonitorPrivate::getCpuUsageInformation(unsigned long &total, unsigned long &idle)
{
QFile statFile("/proc/stat");
if (statFile.exists() && statFile.open(QIODevice::ReadOnly)) {
char buf[256];
QStringList l;
unsigned long sum = 0;
unsigned long tmp;
qint64 readBytes = statFile.readLine(buf, 256);
if (readBytes > 0)
l = QString::fromAscii(buf).split(' ');
int idx = 0;
QStringList::const_iterator end = l.constEnd();
for (QStringList::const_iterator i = l.constBegin(); i != end; ++i) {
if (!i->isEmpty()) {
if (idx) {
bool success = true;
tmp = i->toULong(&success);
if (success) {
sum += tmp;
if (idx == 4)
idle = tmp;
}
}
idx++;
}
}
total = sum;
}
}
示例5: LoadDatasetInternal
bool MainWindow::LoadDatasetInternal(QStringList files, QString targetFilename,
bool bNoUserInteraction)
{
if(files.empty()) {
T_ERROR("No files!");
return false;
}
PleaseWaitDialog pleaseWait(this);
pleaseWait.SetText("Loading dataset, please wait ...");
pleaseWait.AttachLabel(&m_MasterController);
// First check to make sure the list of files we've been given makes sense.
for(QStringList::const_iterator fn = files.begin();
fn != files.end(); ++fn) {
if(fn->isEmpty()) {
T_ERROR("Empty filelist");
return false;
}
if(!SysTools::FileExists(std::string(fn->toAscii()))) {
QString strText = tr("File %1 not found.").arg(*fn);
T_ERROR("%s", strText.toStdString().c_str());
if(!bNoUserInteraction) {
ShowCriticalDialog( "Load Error", strText);
}
return false;
}
}
// now determine if we've been given a UVF, and can just open it and be done,
// or if we need to convert the files.
// If we were given multiple files, we don't need to do any work; we *know*
// that needs to be converted.
shared_ptr<LuaScripting> ss(m_MasterController.LuaScript());
bool needs_conversion = true;
if(files.size() == 1) {
// check to see if we need to convert this file to a supported format.
if(!ss->cexecRet<bool>("tuvok.io.needsConversion",files[0].toStdString())) {
needs_conversion = false;
// It might also be the case that the checksum is bad && we need to
// report an error, but we don't bother with the checksum if they've
// asked us not to in the preferences.
if(!m_bQuickopen &&
false == ss->cexecRet<bool>("tuvok.io.verify", files[0].toStdString()))
{
QString strText = tr("File %1 appears to be a broken UVF file: "
"the header looks ok, "
"but the checksum does not match.").arg(files[0]);
T_ERROR("%s", strText.toStdString().c_str());
if (!bNoUserInteraction) {
ShowCriticalDialog("Load Error", strText);
}
return false;
}
}
}
QString filename = files[0];
if(needs_conversion) {
if (!bNoUserInteraction && targetFilename.isEmpty()) {
targetFilename = GetConvFilename(files[0]);
}
if (targetFilename.isEmpty()) {
T_ERROR("User interaction disabled but no targetFilename given");
return false;
}
std::list<std::string> stdfiles;
for(QStringList::const_iterator fn = files.begin();
fn != files.end(); ++fn) {
stdfiles.push_back(std::string(fn->toAscii()));
}
PleaseWaitDialog pleaseWait(this);
pleaseWait.SetText("Converting, please wait ...");
pleaseWait.AttachLabel(&m_MasterController);
try {
ss->cexec("tuvok.io.convertDataset", stdfiles,
std::string(targetFilename.toAscii()), m_strTempDir,
bNoUserInteraction, false);
filename = targetFilename;
} catch(const tuvok::io::IOException& e) {
// create a (hopefully) useful error message
std::ostringstream error;
error << "Unable to convert ";
std::copy(stdfiles.begin(), stdfiles.end(),
std::ostream_iterator<std::string>(error, ", "));
error << " into " << std::string(targetFilename.toAscii())
<< ": " << e.what();
T_ERROR("%s", error.str().c_str());
if(!bNoUserInteraction) {
ShowCriticalDialog("Conversion Error", QString(error.str().c_str()));
}
// now close that dialog and bail.
pleaseWait.close();
//.........这里部分代码省略.........