本文整理汇总了C++中QString::chop方法的典型用法代码示例。如果您正苦于以下问题:C++ QString::chop方法的具体用法?C++ QString::chop怎么用?C++ QString::chop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QString
的用法示例。
在下文中一共展示了QString::chop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildDeBruijnGraphFromFastg
void AssemblyGraph::buildDeBruijnGraphFromFastg(QString fullFileName)
{
m_graphFileType = FASTG;
QFile inputFile(fullFileName);
if (inputFile.open(QIODevice::ReadOnly))
{
std::vector<QString> edgeStartingNodeNames;
std::vector<QString> edgeEndingNodeNames;
DeBruijnNode * node = 0;
QTextStream in(&inputFile);
while (!in.atEnd())
{
QApplication::processEvents();
QString nodeName;
double nodeReadDepth;
QString line = in.readLine();
//If the line starts with a '>', then we are beginning a new node.
if (line.startsWith(">"))
{
line.remove(0, 1); //Remove '>' from start
line.chop(1); //Remove ';' from end
QStringList nodeDetails = line.split(":");
QString thisNode = nodeDetails.at(0);
//A single quote as the last character indicates a negative node.
bool negativeNode = thisNode.at(thisNode.size() - 1) == '\'';
QStringList thisNodeDetails = thisNode.split("_");
if (thisNodeDetails.size() < 6)
throw "load error";
nodeName = thisNodeDetails.at(1);
if (negativeNode)
nodeName += "-";
else
nodeName += "+";
QString nodeReadDepthString = thisNodeDetails.at(5);
if (negativeNode)
{
//It may be necessary to remove a single quote from the end of the read depth
if (nodeReadDepthString.at(nodeReadDepthString.size() - 1) == '\'')
nodeReadDepthString.chop(1);
}
nodeReadDepth = nodeReadDepthString.toDouble();
//Make the node
node = new DeBruijnNode(nodeName, nodeReadDepth, ""); //Sequence string is currently empty - will be added to on subsequent lines of the fastg file
m_deBruijnGraphNodes.insert(nodeName, node);
//The second part of nodeDetails is a comma-delimited list of edge nodes.
//Edges aren't made right now (because the other node might not yet exist),
//so they are saved into vectors and made after all the nodes have been made.
if (nodeDetails.size() == 1)
continue;
QStringList edgeNodes = nodeDetails.at(1).split(",");
for (int i = 0; i < edgeNodes.size(); ++i)
{
QString edgeNode = edgeNodes.at(i);
QChar lastChar = edgeNode.at(edgeNode.size() - 1);
bool negativeNode = false;
if (lastChar == '\'')
{
negativeNode = true;
edgeNode.chop(1);
}
QStringList edgeNodeDetails = edgeNode.split("_");
if (edgeNodeDetails.size() < 2)
throw "load error";
QString edgeNodeName = edgeNodeDetails.at(1);
if (negativeNode)
edgeNodeName += "-";
else
edgeNodeName += "+";
edgeStartingNodeNames.push_back(nodeName);
edgeEndingNodeNames.push_back(edgeNodeName);
}
}
//If the line does not start with a '>', then this line is part of the
//sequence for the last node.
else
{
QByteArray sequenceLine = line.simplified().toLocal8Bit();
if (node != 0)
node->appendToSequence(sequenceLine);
}
}
//.........这里部分代码省略.........
示例2: import
bool AircraftData::import(QProgressDialog &progress, MainObject *mainObject){
int c = 0;
int found = 0;
progress.setRange(0, 2000);
progress.setWindowTitle("Scanning Aircraft Directories");
progress.show();
progress.repaint();
//= Cache File
QFile cacheFile( mainObject->data_file("aircraft.txt") );
if(!cacheFile.open(QIODevice::WriteOnly | QIODevice::Text)){
//qDebug() << "TODO Open error cachce file=";
return true;
}
QTextStream out(&cacheFile);
//= Get files Entries from Aircaft/ directory
QDir aircraftDir( mainObject->X->aircraft_path() );
aircraftDir.setFilter( QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
QStringList entries = aircraftDir.entryList();
progress.setRange(0, entries.size() + 20);
for( QStringList::ConstIterator entry=entries.begin(); entry!=entries.end(); ++entry ){
// Filter out default dir names, should be a QDir name filter?
if (*entry != "Instruments" && *entry != "Instruments-3d" && *entry != "Generic") {
progress.setValue(c);
progress.setLabelText(*entry);
progress.repaint();
//** get the List of *-set.xml files in dir
QDir dir( mainObject->X->aircraft_path(*entry) );
QStringList filters;
filters << "*-set.xml";
QStringList list_xml = dir.entryList(filters);
if(list_xml.count() > 0){ // << Scan MOdels
QString directory;
QString description;
QString author;
QString fdm;
QString xml_file;
QString aero;
//** Add Path Node
directory = QString(*entry);
//** Add Models
for (int i = 0; i < list_xml.size(); ++i){
xml_file = QString(list_xml.at(i));
aero = QString(xml_file);
aero.chop(8);
//*=parse the Xml file - f&*& long winded
QString file_path = mainObject->X->aircraft_path(*entry);
file_path.append("/");
file_path.append(list_xml.at(i));
QFile xmlFile( file_path);
if (xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)){
/* The file content is converted to UTF-8.
Some files are Windows, encoding and throw error with QxmlQuery etc
Its a hack and don't quite understand whats happening.. said pedro
*/
QString xmlString = QString(xmlFile.readAll()).toUtf8();
QXmlQuery query;
query.setFocus(xmlString);
//query.setFocus(&xmlFile); << Because file is not QTF8 using sting instead
query.setQuery("PropertyList/sim");
if (query.isValid()){
QString res;
query.evaluateTo(&res);
xmlFile.close();
QDomDocument dom;
dom.setContent("" + res + "");
QDomNodeList nodes = dom.elementsByTagName("sim");
QDomNode n = nodes.at(0);
description = n.firstChildElement("description").text();
author = n.firstChildElement("author").text().trimmed().replace(("\n"),"");
fdm = n.firstChildElement("flight-model").text();
} /* !query.isValid() */
} /* xmlFile.open() */
QStringList lines;
lines << directory << aero << xml_file << description << fdm << author << file_path;
out << lines.join("\t") << "\n";
found++;
//.........这里部分代码省略.........
示例3: toggleCommentSelection
void ScCodeEditor::toggleCommentSelection()
{
QTextCursor cursor = textCursor();
cursor.beginEditBlock();
if (isBlockOnlySelection(cursor)) {
const bool isComment = isSingleLineComment(cursor);
QTextCursor selectionCursor(cursor);
selectionCursor.setPosition(cursor.selectionStart());
QTextBlock currentBlock = selectionCursor.block();
int firstBlockIndentation = isComment ? 0
: indentationLevel(selectionCursor);
do {
QTextCursor blockCursor(currentBlock);
if (!isComment)
addSingleLineComment(blockCursor, firstBlockIndentation);
else
removeSingleLineComment(blockCursor);
currentBlock = currentBlock.next();
} while (currentBlock.isValid() && currentBlock.position() < cursor.selectionEnd());
if (!isComment) {
// fix up selection
QTextCursor newSelection(cursor);
if (cursor.anchor() < cursor.position()) {
newSelection.setPosition(newSelection.selectionStart());
newSelection.movePosition(QTextCursor::StartOfBlock);
newSelection.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
} else {
newSelection.setPosition(newSelection.selectionEnd());
newSelection.setPosition(cursor.selectionStart(), QTextCursor::KeepAnchor);
newSelection.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
}
setTextCursor(newSelection);
}
} else {
QString selectionText = cursor.selectedText();
QTextCursor selectionCursor(cursor);
if (isSelectionComment(selectionText)) {
selectionText = selectionText.trimmed().remove(0, 2);
selectionText.chop(2);
selectionCursor.insertText(selectionText);
} else {
selectionText = QString("/*") + selectionText + QString("*/");
selectionCursor.insertText(selectionText);
}
// fix up selection
const int position = selectionCursor.position();
const int anchor = selectionCursor.anchor();
if (position > anchor) {
cursor.setPosition(position - selectionText.size());
cursor.setPosition(position, QTextCursor::KeepAnchor);
} else {
cursor.setPosition(position);
cursor.setPosition(position - selectionText.size(), QTextCursor::KeepAnchor);
}
setTextCursor(cursor);
}
cursor.endEditBlock();
}
示例4: readProcessOutput
void MiningPage::readProcessOutput()
{
QByteArray output;
minerProcess->reset();
output = minerProcess->readAll();
QString outputString(output);
if (!outputString.isEmpty())
{
QStringList list = outputString.split("\n", QString::SkipEmptyParts);
int i;
for (i=0; i<list.size(); i++)
{
QString line = list.at(i);
// Ignore protocol dump
if (!line.startsWith("[") || line.contains("JSON protocol") || line.contains("HTTP hdr"))
continue;
if (ui->debugCheckBox->isChecked())
{
ui->list->addItem(line.trimmed());
ui->list->scrollToBottom();
}
if (line.contains("(yay!!!)"))
reportToList("Share accepted", SHARE_SUCCESS, getTime(line));
else if (line.contains("(booooo)"))
reportToList("Share rejected", SHARE_FAIL, getTime(line));
else if (line.contains("LONGPOLL detected new block"))
reportToList("LONGPOLL detected a new block", LONGPOLL, getTime(line));
else if (line.contains("Supported options:"))
reportToList("Miner didn't start properly. Try checking your settings.", ERROR, NULL);
else if (line.contains("The requested URL returned error: 403"))
reportToList("Couldn't connect. Please check your username and password.", ERROR, NULL);
else if (line.contains("HTTP request failed"))
reportToList("Couldn't connect. Please check pool server and port.", ERROR, NULL);
else if (line.contains("JSON-RPC call failed"))
reportToList("Couldn't communicate with server. Retrying in 30 seconds.", ERROR, NULL);
else if (line.contains("thread ") && line.contains("khash/s"))
{
QString threadIDstr = line.at(line.indexOf("thread ")+7);
int threadID = threadIDstr.toInt();
int threadSpeedindx = line.indexOf(",");
QString threadSpeedstr = line.mid(threadSpeedindx);
threadSpeedstr.chop(8);
threadSpeedstr.remove(", ");
threadSpeedstr.remove(" ");
threadSpeedstr.remove('\n');
double speed=0;
speed = threadSpeedstr.toDouble();
threadSpeed[threadID] = speed;
updateSpeed();
}
}
}
}
示例5: run
//.........这里部分代码省略.........
QImage snapshot = QImage(width, height, channels == 1 ? QImage::Format_Mono : QImage::Format_RGB888);
int rowBytes = channels * width;
for (int y = 0; y < height; ++y) {
unsigned char *scanLine = snapshot.scanLine(y);
qint64 readBytes = io.read((char *) scanLine, rowBytes);
Q_ASSERT(readBytes == rowBytes);
(void)readBytes;
}
QImage thumb = thumbnail(snapshot);
thumbnails.insert(info.commentNumber, thumb);
}
Q_ASSERT(process.state() != QProcess::Running);
} else if (isProfiling()) {
profile = new trace::Profile();
while (!io.atEnd()) {
char line[256];
qint64 lineLength;
lineLength = io.readLine(line, 256);
if (lineLength == -1)
break;
trace::Profiler::parseLine(line, profile);
}
} else {
QByteArray output;
output = process.readAllStandardOutput();
if (output.length() < 80) {
msg = QString::fromUtf8(output);
}
}
}
/*
* Wait for process termination
*/
process.waitForFinished(-1);
if (process.exitStatus() != QProcess::NormalExit) {
msg = QLatin1String("Process crashed");
} else if (process.exitCode() != 0) {
msg = QLatin1String("Process exited with non zero exit code");
}
/*
* Parse errors.
*/
QList<ApiTraceError> errors;
process.setReadChannel(QProcess::StandardError);
QRegExp regexp("(^\\d+): +(\\b\\w+\\b): ([^\\r\\n]+)[\\r\\n]*$");
while (!process.atEnd()) {
QString line = process.readLine();
if (regexp.indexIn(line) != -1) {
ApiTraceError error;
error.callIndex = regexp.cap(1).toInt();
error.type = regexp.cap(2);
error.message = regexp.cap(3);
errors.append(error);
} else if (!errors.isEmpty()) {
// Probably a multiligne message
ApiTraceError &previous = errors.last();
if (line.endsWith("\n")) {
line.chop(1);
}
previous.message.append('\n');
previous.message.append(line);
}
}
/*
* Emit signals
*/
if (m_captureState) {
ApiTraceState *state = new ApiTraceState(parsedJson);
emit foundState(state);
}
if (m_captureThumbnails && !thumbnails.isEmpty()) {
emit foundThumbnails(thumbnails);
}
if (isProfiling() && profile) {
emit foundProfile(profile);
}
if (!errors.isEmpty()) {
emit retraceErrors(errors);
}
emit finished(msg);
}
示例6: sqlStatement
/*!
Returns a SQL statement of type \a type for the table \a tableName
with the values from \a rec. If \a preparedStatement is true, the
string will contain placeholders instead of values.
This method can be used to manipulate tables without having to worry
about database-dependent SQL dialects. For non-prepared statements,
the values will be properly escaped.
*/
QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
const QSqlRecord &rec, bool preparedStatement) const
{
int i;
QString s;
s.reserve(128);
switch (type) {
case SelectStatement:
for (i = 0; i < rec.count(); ++i) {
if (rec.isGenerated(i))
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
}
if (s.isEmpty())
return s;
s.chop(2);
s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(tableName);
break;
case WhereStatement:
if (preparedStatement) {
for (int i = 0; i < rec.count(); ++i) {
s.append(prepareIdentifier(rec.fieldName(i), FieldName,this));
if (rec.isNull(i))
s.append(QLatin1String(" IS NULL"));
else
s.append(QLatin1String(" = ?"));
s.append(QLatin1String(" AND "));
}
} else {
for (i = 0; i < rec.count(); ++i) {
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this));
QString val = formatValue(rec.field(i));
if (val == QLatin1String("NULL"))
s.append(QLatin1String(" IS NULL"));
else
s.append(QLatin1String(" = ")).append(val);
s.append(QLatin1String(" AND "));
}
}
if (!s.isEmpty()) {
s.prepend(QLatin1String("WHERE "));
s.chop(5); // remove tailing AND
}
break;
case UpdateStatement:
s.append(QLatin1String("UPDATE ")).append(tableName).append(
QLatin1String(" SET "));
for (i = 0; i < rec.count(); ++i) {
if (!rec.isGenerated(i) || !rec.value(i).isValid())
continue;
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1Char('='));
if (preparedStatement)
s.append(QLatin1Char('?'));
else
s.append(formatValue(rec.field(i)));
s.append(QLatin1String(", "));
}
if (s.endsWith(QLatin1String(", ")))
s.chop(2);
else
s.clear();
break;
case DeleteStatement:
s.append(QLatin1String("DELETE FROM ")).append(tableName);
break;
case InsertStatement: {
s.append(QLatin1String("INSERT INTO ")).append(tableName).append(QLatin1String(" ("));
QString vals;
for (i = 0; i < rec.count(); ++i) {
if (!rec.isGenerated(i) || !rec.value(i).isValid())
continue;
s.append(prepareIdentifier(rec.fieldName(i), QSqlDriver::FieldName, this)).append(QLatin1String(", "));
if (preparedStatement)
vals.append(QLatin1Char('?'));
else
vals.append(formatValue(rec.field(i)));
vals.append(QLatin1String(", "));
}
if (vals.isEmpty()) {
s.clear();
} else {
vals.chop(2); // remove trailing comma
s[s.length() - 2] = QLatin1Char(')');
s.append(QLatin1String("VALUES (")).append(vals).append(QLatin1Char(')'));
}
break; }
}
return s;
}
示例7: checkMention
void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &sender, UserLevelFlags userLevel)
{
const QRegExp notALetterOrNumber = QRegExp("[^a-zA-Z0-9]");
int firstSpace = message.indexOf(' ');
QString fullMentionUpToSpaceOrEnd = (firstSpace == -1) ? message.mid(1) : message.mid(1, firstSpace - 1);
QString mentionIntact = fullMentionUpToSpaceOrEnd;
while (fullMentionUpToSpaceOrEnd.size())
{
const ServerInfo_User *onlineUser = userlistProxy->getOnlineUser(fullMentionUpToSpaceOrEnd);
if (onlineUser) // Is there a user online named this?
{
if (userName.toLower() == fullMentionUpToSpaceOrEnd.toLower()) // Is this user you?
{
// You have received a valid mention!!
soundEngine->playSound("chat_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
cursor.insertText(mention, mentionFormat);
message = message.mid(mention.size());
showSystemPopup(sender);
} else {
QString correctUserName = QString::fromStdString(onlineUser->name());
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(onlineUser->user_level()) + "_" + correctUserName);
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
message = message.mid(correctUserName.size() + 1);
}
cursor.setCharFormat(defaultFormat);
return;
}
if (isModeratorSendingGlobal(userLevel, fullMentionUpToSpaceOrEnd)) {
// Moderator Sending Global Message
soundEngine->playSound("all_mention");
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
showSystemPopup(sender);
cursor.setCharFormat(defaultFormat);
return;
}
if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 || fullMentionUpToSpaceOrEnd.size() < 2)
{
cursor.insertText("@" + mentionIntact, defaultFormat);
message = message.mid(mentionIntact.size() + 1);
cursor.setCharFormat(defaultFormat);
return;
}
fullMentionUpToSpaceOrEnd.chop(1);
}
// no valid mention found
checkWord(cursor, message);
}
示例8: UpdateRegistry
//.........这里部分代码省略.........
key = QLatin1String("/CLSID/") + classId;
settings->setValue(key + QLatin1String("/."), className + QLatin1String(" Class"));
if (file.endsWith(QLatin1String("exe"), Qt::CaseInsensitive))
settings->setValue(key + QLatin1String("/AppID"), appId);
if (control)
settings->setValue(key + QLatin1String("/Control/."), QVariant(QLatin1String("")));
if (insertable)
settings->setValue(key + QLatin1String("/Insertable/."), QVariant(QLatin1String("")));
if (file.endsWith(QLatin1String("dll"), Qt::CaseInsensitive))
settings->setValue(key + QLatin1String("/InProcServer32/."), file);
else
settings->setValue(key + QLatin1String("/LocalServer32/."),
QLatin1Char('\"') + file + QLatin1String("\" -activex"));
settings->setValue(key + QLatin1String("/MiscStatus/."), control ? QLatin1String("1") : QLatin1String("0"));
settings->setValue(key + QLatin1String("/MiscStatus/1/."), QString::number(olemisc));
settings->setValue(key + QLatin1String("/Programmable/."), QVariant(QLatin1String("")));
settings->setValue(key + QLatin1String("/ToolboxBitmap32/."), QLatin1Char('\"') +
file + QLatin1String("\", 101"));
settings->setValue(key + QLatin1String("/TypeLib/."), libId);
settings->setValue(key + QLatin1String("/Version/."), classVersion);
settings->setValue(key + QLatin1String("/VersionIndependentProgID/."), versionLessProgId);
settings->setValue(key + QLatin1String("/ProgID/."), progId);
QString mime = QLatin1String(mo->classInfo(mo->indexOfClassInfo("MIME")).value());
if (!mime.isEmpty()) {
QStringList mimeTypes = mime.split(QLatin1Char(';'));
for (int m = 0; m < mimeTypes.count(); ++m) {
mime = mimeTypes.at(m);
if (mime.isEmpty())
continue;
QString extension;
while (mime.contains(QLatin1Char(':'))) {
extension = mime.mid(mime.lastIndexOf(QLatin1Char(':')) + 1);
mime.chop(extension.length() + 1);
// Prepend '.' before extension, if required.
extension = extension.trimmed();
if (!extension.startsWith(dot))
extension.prepend(dot);
}
if (!extension.isEmpty()) {
key = slash + extension;
settings->setValue(key + QLatin1String("/."), module + dot + className);
settings->setValue(key + QLatin1String("/Content Type"), mime);
mime.replace(slash, QLatin1Char('\\'));
key = QLatin1String("/MIME/Database/Content Type/") + mime;
settings->setValue(key + QLatin1String("/CLSID"), classId);
settings->setValue(key + QLatin1String("/Extension"), extension);
}
}
}
delete object;
qCDebug(lcAxRegistration).nospace().noquote() << "Registered \"" << progId
<< "\"/" << classId << ", \"" << file << "\" at \"" << keyPath
<< "\", insertable=" << insertable << ", control=" << control
<< ", olemisc=" << hex << showbase << olemisc
<< ", mime=" << mime;
}
qAxFactory()->registerClass(classNameIn, settings.data());
}
} else {
if (qAxOutProcServer) {
settings->remove(QLatin1String("/AppID/") + appId + QLatin1String("/."));
示例9: ts
QPair<QStringList, QStringList> ModelGenerator::createModelParams() const
{
QString setgetDecl;
QString setgetImpl;
QString crtparams;
QString getOptDecl;
QString getOptImpl;
QString initParams;
QList<QPair<QString, QString> > writableFields;
bool optlockMethod = false;
TableSchema ts(tableName);
QList<QPair<QString, QString> > fieldList = ts.getFieldList();
QString autoFieldName = ts.autoValueFieldName();
for (QListIterator<QPair<QString, QString> > it(fieldList); it.hasNext(); ) {
const QPair<QString, QString> &p = it.next();
QString var = fieldNameToVariableName(p.first);
// Getter method
setgetDecl += QString(" %1 %2() const;\n").arg(p.second, var);
setgetImpl += QString("%1 %2::%3() const\n{\n return d->%4;\n}\n\n").arg(p.second, modelName, var, p.first);
if (!excludedSetter()->contains(p.first, Qt::CaseInsensitive) && p.first != autoFieldName) {
// Setter method
QString str = fieldNameToEnumName(p.first);
setgetDecl += QString(" void set%1(%2);\n").arg(str, createParam(p.second, p.first));
setgetImpl += QString("void %1::set%2(%3)\n{\n d->%4 = %5;\n}\n\n").arg(modelName, str, createParam(p.second, p.first), p.first, var);
// Appends to crtparams-string
crtparams += createParam(p.second, p.first);
crtparams += ", ";
writableFields << QPair<QString, QString>(p.first, p.second);
if (p.second == "int" || p.second == "float" || p.second == "double") {
initParams += QString("\n d->") + p.first + " = 0;";
}
}
if (p.first == LOCK_REVISION_FIELD)
optlockMethod = true;
}
crtparams.chop(2);
initParams += (initParams.isEmpty()) ? ' ' : '\n';
// Creates parameters of get() method
int idx = ts.primaryKeyIndex();
QString getparams;
if (idx < 0) {
getparams = crtparams;
} else {
const QPair<QString, QString> &pair = fieldList[idx];
getparams = createParam(pair.second, pair.first);
}
// Creates a declaration and a implementation of 'get' method for optimistic lock
if (idx >= 0 &&optlockMethod) {
const QPair<QString, QString> &pair = fieldList[idx];
getOptDecl = QString(" static %1 get(%2, int lockRevision);\n").arg(modelName, createParam(pair.second, pair.first));
getOptImpl = QString("%1 %1::get(%2, int lockRevision)\n" \
"{\n" \
" TSqlORMapper<%1Object> mapper;\n" \
" TCriteria cri;\n" \
" cri.add(%1Object::%3, %4);\n" \
" cri.add(%1Object::LockRevision, lockRevision);\n" \
" return %1(mapper.findFirst(cri));\n" \
"}\n\n").arg(modelName, createParam(pair.second, pair.first), fieldNameToEnumName(pair.first), fieldNameToVariableName(pair.first));
}
QStringList headerArgs;
headerArgs << modelName.toUpper() << modelName << setgetDecl << crtparams << getparams << getOptDecl;
// Creates a model implementation
QString createImpl;
createImpl += QString(" %1Object obj;\n").arg(modelName);
QListIterator<QPair<QString, QString> > fi(writableFields);
while (fi.hasNext()) {
const QPair<QString, QString> &p = fi.next();
createImpl += QString(" obj.%1 = %2;\n").arg(p.first, fieldNameToVariableName(p.first));
}
createImpl += " if (!obj.create()) {\n";
createImpl += " obj.clear();\n";
createImpl += " }\n";
createImpl += QString(" return %1(obj);\n").arg(modelName);
// Creates a implementation of get() method
QString getImpl;
if (idx < 0) {
// If no primary index exists
getImpl += QString(" TCriteria cri;\n");
fi.toFront();
while (fi.hasNext()) {
const QPair<QString, QString> &p = fi.next();
getImpl += QString(" cri.add(%1Object::%2, %3);\n").arg(modelName, fieldNameToEnumName(p.first), fieldNameToVariableName(p.first));
}
}
//.........这里部分代码省略.........
示例10: appendUnparsed
void DisassemblerLines::appendUnparsed(const QString &unparsed)
{
QString line = unparsed.trimmed();
if (line.isEmpty())
return;
if (line.startsWith(QLatin1String("Current language:")))
return;
if (line.startsWith(QLatin1String("Dump of assembler"))) {
m_lastFunction.clear();
return;
}
if (line.startsWith(QLatin1String("The current source")))
return;
if (line.startsWith(QLatin1String("End of assembler"))) {
m_lastFunction.clear();
return;
}
if (line.startsWith(QLatin1String("=> ")))
line = line.mid(3);
if (line.startsWith(QLatin1String("0x"))) {
// Address line. Split at the tab.
int tab1 = line.indexOf(QLatin1Char('\t'));
if (tab1 == -1) {
appendComment(line);
return;
}
int tab2 = line.indexOf(QLatin1Char('\t'), tab1 + 1);
if (tab2 == -1)
tab2 = tab1;
QString address = line.left(tab1);
if (address.endsWith(QLatin1Char(':')))
address.chop(1);
int pos1 = address.indexOf(QLatin1Char('<')) + 1;
DisassemblerLine dl;
dl.bytes = line.mid(tab1, tab2 - tab1).trimmed();
m_bytesLength = qMax(m_bytesLength, tab2 - tab1);
dl.data = line.mid(tab2).trimmed();
if (pos1 && address.indexOf(QLatin1String("<UNDEFINED> instruction:")) == -1) {
if (address.endsWith(QLatin1Char('>')))
address.chop(1);
int pos2 = address.indexOf(QLatin1Char('+'), pos1);
if (pos1 < pos2) {
QString function = address.mid(pos1, pos2 - pos1);
if (function != m_lastFunction) {
DisassemblerLine dl;
dl.data = _("Function: ") + function;
m_data.append(dl);
m_lastFunction = function;
}
}
dl.address = address.left(pos1 - 1).toULongLong(0, 0);
dl.function = m_lastFunction;
dl.offset = address.mid(pos2).toUInt();
} else {
// Plain data like "0x0000cd64:\tadd\tlr, pc, lr\n"
dl.address = address.toULongLong(0, 0);
dl.function = m_lastFunction;
dl.offset = 0;
}
m_rowCache[dl.address] = m_data.size() + 1;
m_data.append(dl);
} else {
// Comment or code line.
QTextStream ts(&line);
DisassemblerLine dl;
ts >> dl.lineNumber;
dl.data = line.mid(ts.pos());
m_data.append(dl);
}
}
示例11: start
void PropagateRemoteMove::start()
{
if (propagator()->_abortRequested.fetchAndAddRelaxed(0))
return;
QString origin = propagator()->adjustRenamedPath(_item->_file);
qCDebug(lcPropagateRemoteMove) << origin << _item->_renameTarget;
QString targetFile(propagator()->getFilePath(_item->_renameTarget));
if (origin == _item->_renameTarget) {
// The parent has been renamed already so there is nothing more to do.
finalize();
return;
}
QString remoteSource = propagator()->_remoteFolder + origin;
QString remoteDestination = QDir::cleanPath(propagator()->account()->davUrl().path() + propagator()->_remoteFolder + _item->_renameTarget);
auto &vfs = propagator()->syncOptions()._vfs;
auto itype = _item->_type;
ASSERT(itype != ItemTypeVirtualFileDownload && itype != ItemTypeVirtualFileDehydration);
if (vfs->mode() == Vfs::WithSuffix && itype != ItemTypeDirectory) {
const auto suffix = vfs->fileSuffix();
bool sourceHadSuffix = remoteSource.endsWith(suffix);
bool destinationHadSuffix = remoteDestination.endsWith(suffix);
// Remote source and destination definitely shouldn't have the suffix
if (sourceHadSuffix)
remoteSource.chop(suffix.size());
if (destinationHadSuffix)
remoteDestination.chop(suffix.size());
QString folderTarget = _item->_renameTarget;
// Users can rename the file *and at the same time* add or remove the vfs
// suffix. That's a complicated case where a remote rename plus a local hydration
// change is requested. We don't currently deal with that. Instead, the rename
// is propagated and the local vfs suffix change is reverted.
// The discovery would still set up _renameTarget without the changed
// suffix, since that's what must be propagated to the remote but the local
// file may have a different name. folderTargetAlt will contain this potential
// name.
QString folderTargetAlt = folderTarget;
if (itype == ItemTypeFile) {
ASSERT(!sourceHadSuffix && !destinationHadSuffix);
// If foo -> bar.owncloud, the rename target will be "bar"
folderTargetAlt = folderTarget + suffix;
} else if (itype == ItemTypeVirtualFile) {
ASSERT(sourceHadSuffix && destinationHadSuffix);
// If foo.owncloud -> bar, the rename target will be "bar.owncloud"
folderTargetAlt.chop(suffix.size());
}
QString localTarget = propagator()->getFilePath(folderTarget);
QString localTargetAlt = propagator()->getFilePath(folderTargetAlt);
// If the expected target doesn't exist but a file with different hydration
// state does, rename the local file to bring it in line with what the discovery
// has set up.
if (!FileSystem::fileExists(localTarget) && FileSystem::fileExists(localTargetAlt)) {
QString error;
if (!FileSystem::uncheckedRenameReplace(localTargetAlt, localTarget, &error)) {
done(SyncFileItem::NormalError, tr("Could not rename %1 to %2, error: %3")
.arg(folderTargetAlt, folderTarget, error));
return;
}
qCInfo(lcPropagateRemoteMove) << "Suffix vfs required local rename of"
<< folderTargetAlt << "to" << folderTarget;
}
}
qCDebug(lcPropagateRemoteMove) << remoteSource << remoteDestination;
_job = new MoveJob(propagator()->account(), remoteSource, remoteDestination, this);
connect(_job.data(), &MoveJob::finishedSignal, this, &PropagateRemoteMove::slotMoveJobFinished);
propagator()->_activeJobList.append(this);
_job->start();
}
示例12: while
void
VolumeRGBBase::createLowresVolume(bool redo)
{
//---------------
int nRGB = 3;
if (Global::volumeType() == Global::RGBAVolume)
nRGB = 4;
//---------------
int px2, py2, pz2;
px2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.x);
py2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.y);
pz2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.z);
m_subSamplingLevel = 1;
while (px2+py2+pz2 > qMin(26, Global::textureSize()-1)) // limit lowres volume size
{
m_subSamplingLevel *= 2;
px2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.x/m_subSamplingLevel);
py2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.y/m_subSamplingLevel);
pz2 = StaticFunctions::getPowerOf2(m_fullVolumeSize.z/m_subSamplingLevel);
}
// max hardware texture size is 512x512x512
if ((px2 > 9 || py2 > 9 || pz2 > 9) &&
m_subSamplingLevel == 1)
m_subSamplingLevel = 2;
m_lowresVolumeSize = m_fullVolumeSize/m_subSamplingLevel;
int height= m_lowresVolumeSize.x;
int width = m_lowresVolumeSize.y;
int depth = m_lowresVolumeSize.z;
if (m_lowresVolume) delete [] m_lowresVolume;
m_lowresVolume = new unsigned char[nRGB*height*width*depth];
int slabSize = XmlHeaderFunctions::getSlabsizeFromHeader(m_volumeFile);
QString rgbfile = m_volumeFile;
rgbfile.chop(6);
VolumeFileManager rgbaFileManager[4];
QString rFilename = rgbfile + QString("red");
QString gFilename = rgbfile + QString("green");
QString bFilename = rgbfile + QString("blue");
QString aFilename = rgbfile + QString("alpha");
rgbaFileManager[0].setBaseFilename(rFilename);
rgbaFileManager[1].setBaseFilename(gFilename);
rgbaFileManager[2].setBaseFilename(bFilename);
rgbaFileManager[3].setBaseFilename(aFilename);
for(int a=0; a<nRGB; a++)
{
rgbaFileManager[a].setDepth(m_depth);
rgbaFileManager[a].setWidth(m_width);
rgbaFileManager[a].setHeight(m_height);
rgbaFileManager[a].setHeaderSize(13);
rgbaFileManager[a].setSlabSize(slabSize);
}
int nbytes = m_width*m_height;
if (m_subSamplingLevel == 1)
{
uchar *tmp;
tmp = new uchar [m_width*m_height];
for(int k=0; k<m_depth; k++)
{
for (int a=0; a<nRGB; a++)
{
uchar *vslice = rgbaFileManager[a].getSlice(k);
memcpy(tmp, vslice, nbytes);
for (int j=0; j<m_width*m_height; j++)
m_lowresVolume[nRGB*(k*m_width*m_height+j) + a] = tmp[j];
}
}
}
else
{
int iend,jend,kend;
iend = height;
jend = width;
kend = depth;
uchar *tmp;
tmp = new uchar [m_width*m_height];
int totcount = 2*m_subSamplingLevel-1;
int count=0;
uchar **volX;
volX = 0;
if (m_subSamplingLevel > 1)
{
volX = new unsigned char*[totcount];
for(int i=0; i<totcount; i++)
volX[i] = new unsigned char[nRGB*jend*iend];
}
uchar *tmp1;
//.........这里部分代码省略.........
示例13: memset
void
VolumeRGBBase::generateHistograms(bool redo)
{
//---------------
int nRGB = 3;
if (Global::volumeType() == Global::RGBAVolume)
nRGB = 4;
//---------------
memset(m_1dHistogramR, 0, 256*4);
memset(m_2dHistogramR, 0, 256*256*4);
memset(m_1dHistogramG, 0, 256*4);
memset(m_2dHistogramG, 0, 256*256*4);
memset(m_1dHistogramB, 0, 256*4);
memset(m_2dHistogramB, 0, 256*256*4);
memset(m_1dHistogramA, 0, 256*4);
memset(m_2dHistogramA, 0, 256*256*4);
float *flhist1DR, *flhist2DR;
float *flhist1DG, *flhist2DG;
float *flhist1DB, *flhist2DB;
float *flhist1DA, *flhist2DA;
flhist1DR = new float[256]; memset(flhist1DR, 0, 256*4);
flhist2DR = new float[256*256]; memset(flhist2DR, 0, 256*256*4);
flhist1DG = new float[256]; memset(flhist1DG, 0, 256*4);
flhist2DG = new float[256*256]; memset(flhist2DG, 0, 256*256*4);
flhist1DB = new float[256]; memset(flhist1DB, 0, 256*4);
flhist2DB = new float[256*256]; memset(flhist2DB, 0, 256*256*4);
if (nRGB == 4)
{
flhist1DA = new float[256]; memset(flhist1DA, 0, 256*4);
flhist2DA = new float[256*256]; memset(flhist2DA, 0, 256*256*4);
}
//----------------------------- process data ------------------------
uchar *tmp[3];
tmp[0] = new unsigned char [m_width*m_height];
tmp[1] = new unsigned char [m_width*m_height];
tmp[2] = new unsigned char [m_width*m_height];
if (nRGB==4)
tmp[3] = new unsigned char [m_width*m_height];
int slabSize = XmlHeaderFunctions::getSlabsizeFromHeader(m_volumeFile);
QString rgbfile = m_volumeFile;
rgbfile.chop(6);
VolumeFileManager rgbaFileManager[4];
QString rFilename = rgbfile + QString("red");
QString gFilename = rgbfile + QString("green");
QString bFilename = rgbfile + QString("blue");
QString aFilename = rgbfile + QString("alpha");
rgbaFileManager[0].setBaseFilename(rFilename);
rgbaFileManager[1].setBaseFilename(gFilename);
rgbaFileManager[2].setBaseFilename(bFilename);
rgbaFileManager[3].setBaseFilename(aFilename);
for(int a=0; a<nRGB; a++)
{
rgbaFileManager[a].setDepth(m_depth);
rgbaFileManager[a].setWidth(m_width);
rgbaFileManager[a].setHeight(m_height);
rgbaFileManager[a].setHeaderSize(13);
rgbaFileManager[a].setSlabSize(slabSize);
}
MainWindowUI::mainWindowUI()->menubar->parentWidget()->\
setWindowTitle(QString("Reading Volume"));
Global::progressBar()->show();
int nbytes = m_width*m_height;
for(int k=0; k<m_depth; k++)
{
Global::progressBar()->setValue((int)((float)k/(float)m_depth));
qApp->processEvents();
for (int a=0; a<nRGB; a++)
{
uchar *vslice = rgbaFileManager[a].getSlice(k);
memcpy(tmp[a], vslice, nbytes);
}
for (int j=0; j<m_width*m_height; j++)
{
uchar r = tmp[0][j];
uchar g = tmp[1][j];
uchar b = tmp[2][j];
flhist1DR[r]++; flhist2DR[g*256 + r]++;
flhist1DG[g]++; flhist2DG[b*256 + g]++;
flhist1DB[b]++; flhist2DB[r*256 + b]++;
if (nRGB == 4)
{
uchar a = tmp[3][j];
uchar rgb = qMax(r, qMax(g, b));
flhist1DA[a]++; flhist2DA[rgb*256 + a]++;
}
}
//.........这里部分代码省略.........
示例14: if
void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
{
QString objClass = getClassName(e);
if (objClass.isEmpty())
return;
QDomNodeList nl;
QString exportMacro;
int i;
QDomElement n;
QStringList::ConstIterator it;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("exportmacro"));
if (nl.length() == 1)
exportMacro = nl.item(0).firstChild().toText().data();
QStringList::ConstIterator ns = namespaces.constBegin();
while (ns != namespaces.constEnd()) {
out << "namespace " << *ns << " {" << endl;
++ns;
}
out << "class ";
if (!exportMacro.isEmpty())
out << exportMacro << ' ';
out << bareNameOfClass << " : public " << objClass << ", public Ui::" << bareNameOfClass << endl << '{' << endl;
/* qmake ignore Q_OBJECT */
out << " Q_OBJECT" << endl;
out << endl;
out << "public:" << endl;
// constructor
if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);" << endl;
} else if (objClass == QLatin1String("QWidget")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0);" << endl;
} else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);" << endl;
isMainWindow = true;
} else {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0);" << endl;
}
// destructor
out << " ~" << bareNameOfClass << "();" << endl;
out << endl;
// database connections
dbConnections = unique(dbConnections);
bool hadOutput = false;
for (it = dbConnections.constBegin(); it != dbConnections.constEnd(); ++it) {
if (!(*it).isEmpty()) {
// only need pointers to non-default connections
if ((*it) != QLatin1String("(default)") && !(*it).isEmpty()) {
out << indent << "QSqlDatabase* " << *it << "Connection;" << endl;
hadOutput = true;
}
}
}
if (hadOutput)
out << endl;
QStringList publicSlots, protectedSlots, privateSlots;
QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;
QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
for (i = 0; i < (int) nl.length(); i++) {
n = nl.item(i).toElement();
if (n.parentNode().toElement().tagName() != QLatin1String("slots")
&& n.parentNode().toElement().tagName() != QLatin1String("connections"))
continue;
if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
if (functionName.endsWith(QLatin1Char(';')))
functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if (access == QLatin1String(QLatin1String("protected"))) {
protectedSlots += functionName;
protectedSlotTypes += returnType;
protectedSlotSpecifier += specifier;
} else if (access == QLatin1String("private")) {
privateSlots += functionName;
privateSlotTypes += returnType;
privateSlotSpecifier += specifier;
} else {
publicSlots += functionName;
publicSlotTypes += returnType;
publicSlotSpecifier += specifier;
}
}
QStringList publicFuncts, protectedFuncts, privateFuncts;
QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;
QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
//.........这里部分代码省略.........
示例15: process
//.........这里部分代码省略.........
while (parentWindow->hostname == "") {} //Stall until hostname is ready
QFile hostnameFile("/mnt/etc/hostname");
hostnameFile.open(QFile::WriteOnly);
hostnameFile.write(parentWindow->hostname.toUtf8());
hostnameFile.close();
standardOutput.append("[theos_installer] Generating locales...\n");
QFile::copy("/etc/locale.gen", "/mnt/etc/locale.gen");
standardOutput.append("[theos_installer] Executing command arch-chroot /mnt locale-gen \n");
emit output(standardOutput);
p->start("arch-chroot /mnt locale-gen");
p->waitForFinished(-1);
standardOutput.append("[theos_installer] Executing command arch-chroot /mnt mkinitcpio -p linux\n");
emit output(standardOutput);
p->start("arch-chroot /mnt mkinitcpio -p linux");
p->waitForFinished(-1);
emit message("Downloading and installing bootloader...");
standardOutput.append("[theos_installer] Executing command pacstrap /mnt os-prober grub\n");
emit output(standardOutput);
p->start("pacstrap /mnt os-prober efibootmgr grub");
p->waitForFinished(-1);
QString disk = parentWindow->partition;
disk.chop(1);
if (QDir("/sys/firmware/efi").exists()) {
standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub\n");
p->start("arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub");
p->waitForFinished(-1);
} else {
standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=i386-pc " + disk + "\n");
emit output(standardOutput);
p->start("arch-chroot /mnt grub-install --target=i386-pc " + disk);
p->waitForFinished(-1);
}
QFile grubDefault("/mnt/etc/default/grub");
grubDefault.open(QFile::ReadOnly);
QString grubDefaults(grubDefault.readAll());
grubDefault.close();
QStringList grubDefaultsArray = grubDefaults.split("\n");
for (QString line : grubDefaultsArray) {
if (line.startsWith("GRUB_CMDLINE_LINUX_DEFAULT")) {
int index = grubDefaultsArray.indexOf(line);
grubDefaultsArray.removeAt(index);
grubDefaultsArray.insert(index, "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"");
}
}
grubDefaults = "";
for (QString line : grubDefaultsArray) {
grubDefaults.append(line + "\n");
}
p->waitForFinished(-1);