void dump() const { QTextStream outs(stderr, QIODevice::WriteOnly); QList<Line> lines; foreach (const char *func, counters.keys()) { const Counters &fCount = counters[func]; for (int i = 0, ei = fCount.size(); i != ei; ++i) { quint64 count = fCount[i]; if (!count) continue; Line line; line.func = func; unmangle(i, line.tag1, line.tag2); line.count = count; lines.append(line); } } qSort(lines.begin(), lines.end(), Line::less); outs << lines.size() << " counters:" << endl; foreach (const Line &line, lines) outs << qSetFieldWidth(10) << line.count << qSetFieldWidth(0) << " | " << line.func << " | " << pretty(line.tag1) << " | " << pretty(line.tag2) << endl; }
// get a structured representation of this region QString memory_region::get_as_structured_text() { QString l_tmp; QTextStream struct_string(&l_tmp); int depth = 1; struct_string.setFieldAlignment(QTextStream::AlignLeft); struct_string << "Struct: " << region_name << endl; for (struct_members_t::const_iterator it = structure.members.begin(); it != structure.members.end(); ++it) { // for each member // genereate indrection depth QString derefs; for (int i = 0; i < it->deref_depth; ++i) derefs.append("ptr to "); // print 'field: value [type]' struct_string << " " << qSetFieldWidth(12 + (depth * 2)) << left << it->name + ":" << qSetFieldWidth(20) << it->value_as_text << qSetFieldWidth(0) << left << " [" << it->size << "-byte " << (derefs.length() ? derefs : "") << (it->is_array ? "array of " : "") << enum_convert <member_type_t>::to_string(it->type) << (it->deref_is_array ? " array" : "") << "]" << endl; } struct_string << left << "Total Size: " << raw.length() << " bytes" << endl << endl; return l_tmp; }
void dumpMouseRelatedParams(QTextStream &s, const Event &ev) { s << "btn: " << button(ev) << " "; s << "btns: " << buttons(ev) << " "; s << "pos: " << qSetFieldWidth(4) << ev.x() << qSetFieldWidth(0) << "," << qSetFieldWidth(4) << ev.y() << qSetFieldWidth(0) << " "; s << "gpos: " << qSetFieldWidth(4) << ev.globalX() << qSetFieldWidth(0) << "," << qSetFieldWidth(4) << ev.globalY() << qSetFieldWidth(0) << " "; }
QDebug RDFServiceBasic::logMessage(int level, char const *func, char const *loc) const { int dmsgc = attributes_["debug_message_count"].toInt(); attributes_["debug_message_count"] = QVariant(dmsgc + 1); QDebug log = parentContext()->logMessage(level, func, loc); log.nospace() << "[RDFService(" << name_ << ' ' << (void *)this << ") " << qSetFieldWidth(4) << dmsgc << qSetFieldWidth(0) << "]"; return log.space(); }
QString txEmissionsBase::saveSourceData() const { QDir reportDir; const QString fullPath = reportDir.relativeFilePath(m_fullReportsPath) + QDir::separator() + "SourceData_" + m_calculationOptions->defStandardName( m_calculationOptions->val_standard() ) + "_" + m_currTime + ".dat"; QFile srcData(fullPath); if ( !srcData.open(QFile::WriteOnly) ) { throw txError("Can not open file " + fullPath + "!"); } QTextStream fout(&srcData); fout << right << qSetFieldWidth(COLUMNWIDTH); for ( ptrdiff_t i=0; i<SRCDATACAPTIONS_EMISSIONS.size(); i++ ) { fout << SRCDATACAPTIONS_EMISSIONS[i]; } fout << qSetFieldWidth(0) << "\n" << fixed << qSetFieldWidth(COLUMNWIDTH) << qSetRealNumberPrecision(PRECISION+1); for ( ptrdiff_t i=0; i<m_numberOfPoints; i++ ) { fout << qSetFieldWidth(COLUMNWIDTH); fout << i + 1; fout << ma_n[i] << ma_Me_brutto[i] << ma_Ne_brutto[i] << ma_N_fan[i] << ma_w[i] << ma_t0[i] << ma_B0[i] << ma_Ra[i] << ma_dPn[i] << ma_Gair[i] << ma_Gfuel[i] << ma_CNOx[i] << ma_gNOx[i] << ma_CCO[i] << ma_CCH[i] << ma_CCO2in[i] << ma_CCO2out[i] << ma_CO2[i] << ma_Ka1m[i] << ma_KaPerc[i] << ma_FSN[i] << ma_Pr[i] << ma_ts[i] << ma_tauf[i] << ma_qmdw[i] << ma_qmdew[i] << ma_rd[i]; fout << qSetFieldWidth(0) << "\n"; } srcData.close(); return "libtoxic: Source data file \"" + fullPath + "\" created.\n"; }
QByteArray Noam::TcpProtocol::encode( const QByteArray& dataToSend ) { QByteArray result; QTextStream textStream( &result ); textStream << qSetFieldWidth( 6 ) << qSetPadChar( '0' ) << right << dataToSend.length(); textStream << qSetFieldWidth( 0 ) << dataToSend; textStream.flush(); return result; }
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context) { const ushort unicode = qc.unicode(); str << "U+" << qSetFieldWidth(4) << qSetPadChar('0') << uppercasedigits << hex << unicode << dec << qSetFieldWidth(0) << ' '; const EnumLookup *specialChar = enumLookup(unicode, specialCharactersEnumLookup, sizeof(specialCharactersEnumLookup) / sizeof(EnumLookup)); if (specialChar) str << specialChar->description; else str << "'" << qc << '\''; const int category = qc.category(); if (category != context.category) { str << " category=" << enumName(category, categoryEnumLookup, sizeof(categoryEnumLookup) / sizeof(EnumLookup)); context.category = category; } #if QT_VERSION >= 0x050100 const int script = qc.script(); if (script != context.script) { str << " script=" << enumName(script, scriptEnumLookup, sizeof(scriptEnumLookup) / sizeof(EnumLookup)) << '(' << script << ')'; context.script = script; } #endif // Qt 5 const int direction = qc.direction(); if (direction != context.direction) { str << " direction=" << enumName(direction, directionEnumLookup, sizeof(directionEnumLookup) / sizeof(EnumLookup)); context.direction = direction; } #if QT_VERSION >= 0x050000 const int joiningType = qc.joiningType(); if (joiningType != context.joiningType) { str << " joiningType=" << enumName(joiningType, joiningTypeEnumLookup, sizeof(joiningTypeEnumLookup) / sizeof(EnumLookup)); context.joiningType = joiningType; } #endif // Qt 5QWidget const int decompositionTag = qc.decompositionTag(); if (decompositionTag != context.decompositionTag) { str << " decomposition=" << enumName(decompositionTag, decompositionEnumLookup, sizeof(decompositionEnumLookup) / sizeof(EnumLookup)); context.decompositionTag = decompositionTag; } const int unicodeVersion = qc.unicodeVersion(); if (unicodeVersion != context.unicodeVersion) { str << " version=" << enumName(unicodeVersion, unicodeVersionEnumLookup, sizeof(unicodeVersionEnumLookup) / sizeof(EnumLookup)); context.unicodeVersion = unicodeVersion; } }
QString MOPACInputDialog::generateInputDeck() { // Generate an input deck based on the settings of the dialog QString buffer; QTextStream mol(&buffer); mol << " AUX LARGE "; mol << "CHARGE=" << m_charge << ' '; switch (m_multiplicity) { case 2: mol << "DOUBLET "; break; case 3: mol << "TRIPLET "; break; case 4: mol << "QUARTET "; break; case 5: mol << "QUINTET "; break; case 1: default: mol << "SINGLET "; } mol << getCalculationType(m_calculationType) << ' '; mol << getTheoryType(m_theoryType) << '\n'; mol << m_title << "\n\n"; // Now to output the actual molecular coordinates QString optimizationFlag; if (m_calculationType == SP) optimizationFlag = " 0 "; // we could actually obey constraints easily else optimizationFlag = " 1 "; // Cartesian coordinates if (m_molecule && m_coordType == CARTESIAN) { QList<Atom *> atoms = m_molecule->atoms(); foreach (Atom *atom, atoms) { mol << qSetFieldWidth(4) << right << QString(OpenBabel::etab.GetSymbol(atom->atomicNumber())) << qSetFieldWidth(15) << qSetRealNumberPrecision(5) << forcepoint << fixed << right << atom->pos()->x() << optimizationFlag << atom->pos()->y() << optimizationFlag << atom->pos()->z() << optimizationFlag << qSetFieldWidth(0) << '\n'; }
QString txReducedPower::saveSourceData() const { QDir reportDir; const QString fullPath = reportDir.relativeFilePath(m_fullReportsPath) + QDir::separator() + "SourceData_R85_" + m_currTime + ".dat"; QFile srcData(fullPath); if ( !srcData.open(QFile::WriteOnly) ) { throw txError("Can not open file " + fullPath + "!"); } QTextStream fout(&srcData); fout << right << qSetFieldWidth(COLUMNWIDTH); for ( ptrdiff_t i=0; i<SRCDATACAPTIONS_REDPOWER.size(); i++ ) { fout << SRCDATACAPTIONS_REDPOWER[i]; } fout << qSetFieldWidth(0) << "\n" << fixed << qSetFieldWidth(COLUMNWIDTH) << qSetRealNumberPrecision(PRECISION+1); for ( ptrdiff_t i=0; i<m_numberOfPoints; i++ ) { fout << qSetFieldWidth(COLUMNWIDTH); fout << i + 1; fout << ma_n[i] << ma_Me_brutto[i] << ma_t0[i] << ma_B0[i] << ma_Ra[i] << ma_S[i] << ma_pk[i] << ma_Gfuel[i] << ma_N_k[i] << ma_N_fan[i] << ma_t_cool[i] << ma_t_oil[i] << ma_tk[i] << ma_tks[i] << ma_t_fuel[i] << ma_pks[i] << ma_Gair[i]; fout << qSetFieldWidth(0) << "\n"; } srcData.close(); return "libtoxic: Source data file \"" + fullPath + "\" created.\n"; }
void IssuesWidget::storeSyncIssues(QTextStream &ts) { int topLevelItems = _ui->_treeWidget->topLevelItemCount(); for (int i = 0; i < topLevelItems; i++) { QTreeWidgetItem *child = _ui->_treeWidget->topLevelItem(i); if (child->isHidden()) continue; ts << right // time stamp << qSetFieldWidth(20) << child->data(0, Qt::DisplayRole).toString() // separator << qSetFieldWidth(0) << "," // file name << qSetFieldWidth(64) << child->data(1, Qt::DisplayRole).toString() // separator << qSetFieldWidth(0) << "," // folder << qSetFieldWidth(30) << child->data(2, Qt::DisplayRole).toString() // separator << qSetFieldWidth(0) << "," // action << qSetFieldWidth(15) << child->data(3, Qt::DisplayRole).toString() << qSetFieldWidth(0) << endl; } }
// Return printable string formatted like the output of the dxdiag tool. QString GpuDescription::toString() const { QString result; QTextStream str(&result); str << " Card name: " << description << "\n Driver Name: " << driverName << "\n Driver Version: " << driverVersion.toString() << "\n Vendor ID: 0x" << qSetPadChar(QLatin1Char('0')) << uppercasedigits << hex << qSetFieldWidth(4) << vendorId << "\n Device ID: 0x" << qSetFieldWidth(4) << deviceId << "\n SubSys ID: 0x" << qSetFieldWidth(8) << subSysId << "\n Revision ID: 0x" << qSetFieldWidth(4) << revision << dec; return result; }
void GotoStatement::print(OStream &os) const { os << qSetFieldWidth(4) << m_number << qSetFieldWidth(0) << " "; os << "GOTO "; if (m_dest == nullptr) { os << "*no dest*"; } else if (m_dest->getOper() != opIntConst) { m_dest->print(os); } else { os << getFixedDest(); } }
QString msToPrettyTime(qint64 pos) { pos /= 1000; QString status_message; QTextStream(&status_message) << pos / 60 << ":" << qSetPadChar('0') << qSetFieldWidth(2) << pos % 60; return status_message; }
void QSpyWrk::dumpHex(const QByteArray& data) { int i = 0, j = 0; QString s; if (m_verbosity) { while ( i < data.count() ) { s.clear(); for (j = 0; j < 16 && i < data.count(); ++j) { quint8 c = data[i++]; s += QString(" %1").arg(c & 0xff, 2, 16, QChar('0')); } cout << qSetFieldWidth(42) << ' ' << qSetFieldWidth(0) << s << endl; } } }
static inline QDebug & operator << (QDebug &dbg, InitTimer const &timer) { return dbg << "[" << qSetFieldWidth (4) << timer.begin.elapsed () / 1000 << qSetFieldWidth (0) << '.' << qSetPadChar ('0') << qSetFieldWidth (3) << timer.begin.elapsed () % 1000 << qSetFieldWidth (0) << qSetPadChar (' ') << "] " ; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData) { QTextStream out(file); out << "\n"; out << "-- Exported from ResInsight" << "\n"; out << eclipseKeyWord << "\n" << right << qSetFieldWidth(16); caf::ProgressInfo pi(resultData.size(), QString("Writing data to file %1").arg(file->fileName()) ); size_t progressSteps = resultData.size() / 20; size_t i; for (i = 0; i < resultData.size(); i++) { out << resultData[i]; if ( (i + 1) % 5 == 0) { out << "\n"; } if (i % progressSteps == 0) { pi.setProgress(i); } } out << "\n" << "/" << "\n"; }
QString format_matrix_float(Mat mat) { QString formatted; QTextStream stream(&formatted, QIODevice::WriteOnly); stream.setRealNumberNotation(QTextStream::FixedNotation); stream.setRealNumberPrecision(2); stream.setFieldAlignment(QTextStream::AlignRight); for(int i = 0; i < mat.rows; i++) { for(int j = 0; j < mat.cols; j++) { stream << qSetFieldWidth(4) << mat.at<float>(i,j) << " "; } stream << qSetFieldWidth(0) << endl; } return formatted; }
QString txPointsOfCycle::createReports() { const QString filenamePoints = m_commonParameters->val_srcFileNamePoints(); QFile dataFile(filenamePoints); if ( !dataFile.open(QFile::WriteOnly) ) { throw txError("Can not open file " + filenamePoints + "!"); } QTextStream fout(&dataFile); fout << right << qSetFieldWidth(COLUMNWIDTH); for ( ptrdiff_t i=0; i<SRCDATACAPTIONS_EMISSIONS.size(); i++ ) { fout << SRCDATACAPTIONS_EMISSIONS[i]; } fout << qSetFieldWidth(0) << "\n" << fixed; for ( ptrdiff_t i=0; i<m_numberOfPoints; i++ ) { fout << qSetFieldWidth(COLUMNWIDTH) << qSetRealNumberPrecision(0); fout << (i + 1) << ma_n[i]; fout << qSetRealNumberPrecision(PRECISION); fout << ma_Me_brutto[i] << ma_Ne_brutto[i] << ma_N_fan[i]; fout << qSetRealNumberPrecision(PRECISION+1); fout << ma_w[i]; fout << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0" << "0"; fout << qSetFieldWidth(0) << "\n"; } dataFile.close(); return "libtoxic: File \"" + filenamePoints + "\" rewrited.\n"; }
void QSpyWrk::dump(const long time, const int track, const QString& chan, const QString& event, const QString& data) { cout << right << qSetFieldWidth(7) << time; cout << qSetFieldWidth(0) << left << ' '; cout << qSetFieldWidth(5) << right << track; cout << qSetFieldWidth(3) << chan; cout << qSetFieldWidth(0) << left << ' '; cout << qSetFieldWidth(25) << event; cout << qSetFieldWidth(0) << ' ' << data << endl; }
void ProtocolWidget::copyToClipboard() { QString text; QTextStream ts(&text); int topLevelItems = _ui->_treeWidget->topLevelItemCount(); for (int i = 0; i < topLevelItems; i++) { QTreeWidgetItem *child = _ui->_treeWidget->topLevelItem(i); ts << left // time stamp << qSetFieldWidth(10) << child->data(0,Qt::DisplayRole).toString() // file name << qSetFieldWidth(64) << child->data(1,Qt::DisplayRole).toString() // folder << qSetFieldWidth(15) << child->data(2, Qt::DisplayRole).toString() // action << qSetFieldWidth(15) << child->data(3, Qt::DisplayRole).toString() // size << qSetFieldWidth(10) << child->data(4, Qt::DisplayRole).toString() << qSetFieldWidth(0) << endl; } QApplication::clipboard()->setText(text); emit guiLog(tr("Copied to clipboard"), tr("The sync status has been copied to the clipboard.")); }
bool MemoryMap::dumpInit(const QString &fileName, const quint32 level) const { MemoryMapNode *init_task = _roots.at(0); if(!init_task) return false; QFile fout(fileName); if (!fout.open(QFile::WriteOnly|QFile::Truncate)) return false; QTextStream out(&fout); out << left << qSetFieldWidth(0) << "0x" << hex << qSetFieldWidth(16) << init_task->address() << qSetFieldWidth(0) << " " << left << qSetFieldWidth(6) << QString::number(init_task->probability(), 'f', 4) << qSetFieldWidth(0) << " \"" << init_task->fullName() << "\"" << qSetFieldWidth(0) << " (" << init_task->type()->prettyName() << ")" << endl; dumpInitHelper(out, init_task, 0, level); fout.close(); return true; }
void XYZWriter::write() { if (m_world.parameters().outputXyzMode == 0) { int num = 0; if (m_world.parameters().outputXyzE == true) { num += m_world.numElectronAgents(); } if (m_world.parameters().outputXyzH == true) { num += m_world.numHoleAgents(); } if (m_world.parameters().outputXyzD == true) { num += m_world.numDefects(); } if (m_world.parameters().outputXyzT == true) { num += m_world.numTraps(); } m_stream << qSetFieldWidth(0) << num << newline; m_stream << m_world.parameters().currentStep << newline; m_stream << qSetRealNumberPrecision(m_world.parameters().outputPrecision) << qSetFieldWidth(0) << right << scientific; if (m_world.parameters().outputXyzE == true) { Grid &grid = m_world.electronGrid(); QList<ChargeAgent*> &charges = m_world.electrons(); foreach( ChargeAgent* pCharge, charges) { ChargeAgent &charge = *pCharge; int site = charge.getCurrentSite(); m_stream << 'E' << ' ' << grid.getIndexX(site) << ' ' << grid.getIndexY(site) << ' ' << grid.getIndexZ(site) << ' ' << site << ' ' << &charge << ' ' << charge.lifetime() << ' ' << charge.pathlength() << '\n'; }
QwtText ViSpectrumPlotPicker::trackerText(const QPoint &position) const { QColor bg(Qt::white); bg.setAlpha(200); QPointF point = invTransform(position); QString valueX = QString::number(point.x(), 'f', 4); QString valueY = QString::number(mPlot->valueAt(point.x()), 'f', 4); qint32 stringSizeX = qMax(mLabelX.size(), mLabelY.size()) + 2; qint32 stringSizeY = qMax(valueX.size(), valueY.size()); QString string; QTextStream stream(&string); stream << qSetFieldWidth(stringSizeX) << left << (mLabelX + ": ") << qSetFieldWidth(stringSizeY) << left << valueX << qSetFieldWidth(0) << left << mUnitX << endl; stream << qSetFieldWidth(stringSizeX) << left << (mLabelY + ": ") << qSetFieldWidth(stringSizeY) << right << valueY << qSetFieldWidth(0) << mUnitY; QwtText text(string); text.setFont(QFont("Courier")); text.setBackgroundBrush( QBrush( bg )); return text; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QFile data("data.txt"); if(data.open(QFile::WriteOnly|QFile::Truncate)) { QTextStream out(&data); out<<QObject::tr("score:")<<qSetFieldWidth(10)<<left<<90<<endl; } return a.exec(); }
void tst_QDebug::stateSaver() const { MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); { QDebugStateSaver saver(d); d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42; } d.space() << 42; } QCOMPARE(s_msg, QString::fromLatin1("02a 42 ")); }
QString hoursAndMinutes( int duration ) { if ( duration == 0 ) { if ( CONFIGURATION.durationFormat == Configuration::Minutes ) return QObject::tr( "00:00" ); else return formatDecimal( 0.0 ); } int minutes = duration / 60; int hours = minutes / 60; minutes = minutes % 60; if ( CONFIGURATION.durationFormat == Configuration::Minutes ) { QString text; QTextStream stream( &text ); stream << qSetFieldWidth( 2 ) << qSetPadChar( QLatin1Char('0' ) ) << hours << qSetFieldWidth( 0 ) << ":" << qSetFieldWidth( 2 ) << minutes; return text; } else { //Decimal return formatDecimal(hours + minutes / 60.0 ); } }
QString tabletEventToString(const Event &ev, const QString &prefix) { QString string; QTextStream s(&string); dumpBaseParams(s, ev, prefix); dumpMouseRelatedParams(s, ev); s << "hires: " << qSetFieldWidth(8) << ev.hiResGlobalX() << qSetFieldWidth(0) << "," << qSetFieldWidth(8) << ev.hiResGlobalY() << qSetFieldWidth(0) << " "; s << "prs: " << qSetFieldWidth(4) << fixed << ev.pressure() << reset << " "; s << KisTabletDebugger::tabletDeviceToString((QTabletEvent::TabletDevice) ev.device()) << " "; s << KisTabletDebugger::pointerTypeToString((QTabletEvent::PointerType) ev.pointerType()) << " "; s << "id: " << ev.uniqueId() << " "; s << "xTilt: " << ev.xTilt() << " "; s << "yTilt: " << ev.yTilt() << " "; s << "rot: " << ev.rotation() << " "; s << "z: " << ev.z() << " "; s << "tp: " << ev.tangentialPressure() << " "; return string; }
void ActivityWidget::storeActivityList( QTextStream& ts ) { ActivityList activities = _model->activityList(); foreach( Activity activity, activities ) { ts << right // account name << qSetFieldWidth(30) << activity._accName // separator << qSetFieldWidth(0) << "," // date and time << qSetFieldWidth(34) << activity._dateTime.toString() // separator << qSetFieldWidth(0) << "," // file << qSetFieldWidth(30) << activity._file // separator << qSetFieldWidth(0) << "," // subject << qSetFieldWidth(100) << activity._subject // separator << qSetFieldWidth(0) << "," // message (mostly empty) << qSetFieldWidth(55) << activity._message // << qSetFieldWidth(0) << endl; }
void QSpyWrk::dumpStr(const long time, const QString& event, const QString& data) { cout << right << qSetFieldWidth(7) << time; cout << qSetFieldWidth(6) << NO_CHANNEL; cout << qSetFieldWidth(3) << NO_CHANNEL; cout << qSetFieldWidth(0) << left << ' '; cout << qSetFieldWidth(25) << event; cout << qSetFieldWidth(0) << ' ' << data << endl; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); eps = 0.001; maximumNumberOfIterations = 50; stream.setString(&outputString); stream << qSetFieldWidth(5); stream << qSetRealNumberPrecision(4); QShortcut *fOpen = new QShortcut(QKeySequence("Ctrl+O"),this); QObject::connect(fOpen,SIGNAL(activated()),this,SLOT(on_action_Open_triggered())); QShortcut *Exit = new QShortcut(QKeySequence("Ctrl+E"),this); QObject::connect(Exit,SIGNAL(activated()),this,SLOT(on_action_Exit_triggered())); }