QWidget *DBFRedactorDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { const DBFRedactor::Field& field = m_redactor->field(index.column()); switch (field.type) { case DBFRedactor::TYPE_DATE: { QDateEdit *edit = new QDateEdit(parent); edit->setCalendarPopup(true); return edit; break; } case DBFRedactor::TYPE_FLOAT: case DBFRedactor::TYPE_NUMERIC: { QDoubleSpinBox *edit = new QDoubleSpinBox(parent); edit->setDecimals(field.secondLenght); QString tempString; tempString.fill('9', field.firstLenght - 1); edit->setMinimum(tempString.toDouble() * (-1)); tempString.fill('9', field.firstLenght); edit->setMaximum(tempString.toDouble()); return edit; break; } default: { QLineEdit *edit = new QLineEdit(parent); edit->setMaxLength(field.firstLenght); return edit; } } return 0; }
static void tabify(QString &s) { if (!Config::indentKeepTabs()) return; int i = 0; const int tabSize = Config::indentTabSize(); forever { for (int j = i; j < s.length(); ++j) { if (s.at(j) != QLatin1Char(' ') && s.at(j) != QLatin1Char('\t')) { if (j > i) { QString t = s.mid(i, j - i); int spaces = 0; for (int k = 0; k < t.length(); ++k) spaces += (t.at(k) == QLatin1Char(' ') ? 1 : tabSize); s.remove(i, t.length()); int tabs = spaces / tabSize; spaces = spaces - (tabSize * tabs); QString tmp; tmp.fill(QLatin1Char(' '), spaces); if (spaces > 0) s.insert(i, tmp); tmp.fill(QLatin1Char('\t'), tabs); if (tabs > 0) s.insert(i, tmp); } break; } } i = s.indexOf(QLatin1Char('\n'), i); if (i == -1) break; ++i; } }
QString CLHelp::formatHelp(QString parameter, QString help, bool html) { if (html) { return "<tr><td><b>"+parameter+"</b></td><td>"+help+"</td></tr>"; } else { int par_width = 20; int help_width = 80 - par_width; QString s; s = s.fill( ' ', par_width - (parameter.count()+2) ); s = s + parameter + ": "; QString f; f = f.fill(' ', par_width); QString s2 = formatText(help, help_width); int pos = s2.indexOf('\n'); while (pos != -1) { s2 = s2.insert(pos+1, f); pos = s2.indexOf('\n', pos+1); } return s + s2 + "\n"; } }
void QgsPropertyKey::dump( int tabs ) const { QString tabString; tabString.fill( '\t', tabs ); QgsDebugMsg( QString( "%1name: %2" ).arg( tabString, name() ) ); tabs++; tabString.fill( '\t', tabs ); if ( ! mProperties.isEmpty() ) { QHashIterator < QString, QgsProperty* > i( mProperties ); while ( i.hasNext() ) { if ( i.next().value()->isValue() ) { QgsPropertyValue * propertyValue = static_cast<QgsPropertyValue*>( i.value() ); if ( QVariant::StringList == propertyValue->value().type() ) { QgsDebugMsg( QString( "%1key: <%2> value:" ).arg( tabString, i.key() ) ); propertyValue->dump( tabs + 1 ); } else { QgsDebugMsg( QString( "%1key: <%2> value: %3" ).arg( tabString, i.key(), propertyValue->value().toString() ) ); } } else { QgsDebugMsg( QString( "%1key: <%2> subkey: <%3>" ) .arg( tabString, i.key(), dynamic_cast<QgsPropertyKey*>( i.value() )->name() ) ); i.value()->dump( tabs + 1 ); } #if 0 qDebug( "<%s>", name().toUtf8().constData() ); if ( i.value()->isValue() ) { qDebug( " <%s>", i.key().toUtf8().constData() ); } i.value()->dump(); if ( i.value()->isValue() ) { qDebug( " </%s>", i.key().toUtf8().constData() ); } qDebug( "</%s>", name().toUtf8().constData() ); #endif } } } // QgsPropertyKey::dump
void Widget::fillFunction() { //! [21] QString str = "Berlin"; str.fill('z'); // str == "zzzzzz" str.fill('A', 2); // str == "AA" //! [21] }
QString echoBlock(int tabs, const QString &in) { QStringList pars = in.split('\n', QString::KeepEmptyParts); if(!pars.isEmpty() && pars.last().isEmpty()) pars.removeLast(); QStringList lines; int n; for(n = 0; n < pars.count(); ++n) { QStringList list = wrapString(pars[n], CONF_WRAP); for(int n2 = 0; n2 < list.count(); ++n2) lines.append(list[n2]); } QString str; for(n = 0; n < lines.count(); ++n) { QString out; out.fill(9, tabs); // 9 == tab character if(lines[n].isEmpty()) out += QString("printf \"\\n\"\n"); else out += QString("printf \"%1\\n\"\n").arg(c_escape(lines[n])); str += out; } return str; }
void XsdSchemaDebugger::dumpInheritance(const SchemaType::Ptr &type, int level) { QString prefix; prefix.fill(QLatin1Char(' '), level); qDebug("%s-->%s", qPrintable(prefix), qPrintable(type->displayName(m_namePool))); if (type->wxsSuperType()) dumpInheritance(type->wxsSuperType(), ++level); }
void XsdSchemaDebugger::dumpParticle(const XsdParticle::Ptr &particle, int level) { QString prefix; prefix.fill(QLatin1Char(' '), level); qDebug("%s min=%s max=%s", qPrintable(prefix), qPrintable(QString::number(particle->minimumOccurs())), qPrintable(particle->maximumOccursUnbounded() ? QLatin1String("unbounded") : QString::number(particle->maximumOccurs()))); if (particle->term()->isElement()) { qDebug("%selement (%s)", qPrintable(prefix), qPrintable(XsdElement::Ptr(particle->term())->displayName(m_namePool))); } else if (particle->term()->isModelGroup()) { const XsdModelGroup::Ptr group(particle->term()); if (group->compositor() == XsdModelGroup::SequenceCompositor) { qDebug("%ssequence", qPrintable(prefix)); } else if (group->compositor() == XsdModelGroup::AllCompositor) { qDebug("%sall", qPrintable(prefix)); } else if (group->compositor() == XsdModelGroup::ChoiceCompositor) { qDebug("%schoice", qPrintable(prefix)); } for (int i = 0; i < group->particles().count(); ++i) dumpParticle(group->particles().at(i), level + 5); } else if (particle->term()->isWildcard()) { XsdWildcard::Ptr wildcard(particle->term()); qDebug("%swildcard (process=%d)", qPrintable(prefix), wildcard->processContents()); } }
int classISQL::getResultsHeader( SQLHSTMT hStmt, SWORD nColumns, QString *pqsHorizSep ) { QString qsColumnHeader = ""; QString qsColumn = ""; QString qsColumnName = ""; int nCol; SQLLEN nMaxLength = 10; SQLCHAR szColumnName[101] = ""; *pqsHorizSep = ""; for ( nCol = 1; nCol <= nColumns; nCol++ ) { int nWidth; SQLColAttribute( hStmt, nCol, SQL_DESC_DISPLAY_SIZE, 0, 0, 0, &nMaxLength ); SQLColAttribute( hStmt, nCol, SQL_DESC_LABEL, szColumnName, sizeof(szColumnName), 0, 0 ); qsColumnName = (const char *)szColumnName; nWidth = max( nMaxLength, qsColumnName.length() ); nWidth = min( nWidth, MAX_COLUMN_WIDTH ); qsColumn.fill( '-', nWidth ); qsColumn += "-"; *pqsHorizSep += ( "+" + qsColumn ); qsColumn.sprintf( "| %-*s", nWidth, szColumnName ); qsColumnHeader += qsColumn; } *pqsHorizSep += "+\n"; qsColumnHeader += "|\n"; txtResults->append( *pqsHorizSep ); txtResults->append( qsColumnHeader ); txtResults->append( *pqsHorizSep ); return qsColumnHeader.length(); }
QVariant FLUtil::nextCounter( const QString & name, FLSqlCursor * cursor_ ) { if ( !cursor_ ) return QVariant(); FLTableMetaData *tMD = cursor_->metadata(); if ( !tMD ) return QVariant(); FLFieldMetaData *field = tMD->field( name ); if ( !field ) return QVariant(); int type = field->type(); if ( type != QVariant::String && type != QVariant::Double ) return QVariant(); unsigned int len = field->length(); QString cadena; FLSqlQuery q( 0, cursor_->db()->connectionName() ); q.setForwardOnly( true ); q.setTablesList( tMD->name() ); q.setSelect( name ); q.setFrom( tMD->name() ); q.setWhere( "LENGTH(" + name + ")=" + QString::number( len ) ); q.setOrderBy( name + " DESC" ); if ( !q.exec() ) return QVariant(); double maxRange = pow( 10, len ); double numero = maxRange; while ( numero >= maxRange ) { if ( !q.next() ) { numero = 1; break; } numero = q.value( 0 ).toDouble(); numero++; } if ( type == QVariant::String ) { cadena = QString::number( numero, 'f', 0 ); if ( cadena.length() < len ) { QString str; str.fill( '0', ( len - cadena.length() ) ); cadena = str + cadena; } return QVariant( cadena ); } if ( type == QVariant::Double ) return QVariant( numero ); return QVariant(); }
void ForumPageParser::printTagsRecursively(QtGumboNodePtr node, int &level) { BFR_RETURN_VOID_IF(!node || !node->isValid(), "invalid node"); if (!node->isElement()) return; #ifdef BFR_PRINT_DEBUG_OUTPUT QString levelStr; levelStr.fill('-', level); QString idAttrValue = "<empty id>"; if (node->hasAttribute("id")) idAttrValue = ", id = " + node->getIdAttribute(); QString classAttrValue = "<empty class>"; if (node->hasClassAttribute()) classAttrValue = ", class = " + node->getClassAttribute(); ConsoleLogger->info("{} {} {} {}", levelStr, node->getTagName(), idAttrValue, classAttrValue); QtGumboNodes children = node->getChildren(); for (auto iChild = children.begin(); iChild != children.end(); ++iChild) { level += 4; printTagsRecursively(*iChild, level); level -= 4; } #else Q_UNUSED(level); #endif }
void DeviceTree::PopulateTree(DiSEqCDevDevice *node, DiSEqCDevDevice *parent, uint childnum, uint depth) { QString indent; indent.fill(' ', 8 * depth); if (node) { QString id = QString::number(node->GetDeviceID()); addSelection(indent + node->GetDescription(), id); uint num_ch = node->GetChildCount(); for (uint ch = 0; ch < num_ch; ch++) PopulateTree(node->GetChild(ch), node, ch, depth+1); } else { QString id; if (parent) id = QString::number(parent->GetDeviceID()); id += ":" + QString::number(childnum); addSelection(indent + "(Unconnected)", id); } }
/*! Converts the location to a string to be prepended to error messages. */ QString Location::toString() const { QString str; if (isEmpty()) { str = programName; } else { Location loc2 = *this; loc2.setEtc(false); loc2.pop(); if (!loc2.isEmpty()) { QString blah = tr("In file included from "); for (;;) { str += blah; str += loc2.top(); loc2.pop(); if (loc2.isEmpty()) break; str += tr(","); str += QLatin1Char('\n'); blah.fill(' '); } str += tr(":"); str += QLatin1Char('\n'); } str += top(); } return str; }
/** @brief Returns HTML formated mixer representation @param[in] dest defines which mixer line to create. If dest < 0 then create empty channel slot for channel -dest ( dest=-2 -> CH2) if dest >=0 then create used channel based on model mix data from slot dest (dest=4 -> model mix[4]) @retval string mixer line in HTML */ QString MixesPanel::getMixerText(int dest, bool * new_ch) { QString str; if (new_ch) *new_ch = 0; if (dest < 0) { str = modelPrinter.printMixerName(-dest); //highlight channel if needed if (-dest == (int)highlightedSource) { str = "<b>" + str + "</b>"; } if (new_ch) *new_ch = 1; } else { MixData *md = &model->mixData[dest]; //md->destCh from 1 to 32 str = modelPrinter.printMixerName(md->destCh); if ((dest == 0) || (model->mixData[dest-1].destCh != md->destCh)) { if (new_ch) *new_ch = 1; //highlight channel if needed if (md->destCh == highlightedSource) { str = "<b>" + str + "</b>"; } } else { str.fill(' '); } str += modelPrinter.printMixerLine(md, highlightedSource); } return str.replace(" ", " "); }
void RICTLMB2B30Widget::leIdentificationChanged(QString newText) { m_identification.clear(); if( ! ui->leIdentification->text().isEmpty()){ // If the field contains some value. if(ui->rbDecimal->isChecked()){ // Parse to hexadecimal. quint64 decimal = ui->leIdentification->text().toULongLong(); m_identification.setNum(decimal,16); }else if(ui->rbHexadecimal->isChecked()){ // Do not parse, simple set it m_identification.append(ui->leIdentification->text()); } QString finalIdentification; finalIdentification.fill('0', 16 - m_identification.size()); finalIdentification.append(m_identification); m_identification.clear(); m_identification.append(finalIdentification); ui->labelIdentificationStatus->setText(tr("Hexadecimal identification %1.").arg(m_identification)); }else{ // If the identification field is empty, then clear the field instead of // trying to handle it. ui->labelIdentificationStatus->clear(); } }
QString indent( int n = 0 ) { static int i = 0; i += n; QString space; return space.fill( ' ', i ); }
QString PHPObjectValue::toString(int indent) { QString ind; ind.fill(' ', indent); QString s; Variable* v; for(v = m_list->first(); v; v = m_list->next()) { s += "\n"; s += ind; if(v->isReference()) { s += v->name() + " => &" + v->value()->owner()->name(); } else { if(v->value()->isScalar()) { s += v->name() + " => " + v->value()->toString(); } else { s += v->name() + " = (" + v->value()->typeName() + ")"; s += v->value()->toString(indent+3); } } } return s; }
void VigenereCipherTab::splitText(int keyLength) { int comboCount = ui->comboBox->count(); if(comboCount < keyLength) { for(int i = comboCount; i < keyLength; i++) ui->comboBox->insertItem(i, QString::number(i+1)+"."); } else if(comboCount > keyLength) { for(int i = comboCount-1; i >= keyLength; i--) ui->comboBox->removeItem(i); } QString key; ui->txtKey->setText(key.fill('A', keyLength)); if(keyLength <= 0) { QList<float> dict; ui->frequencyChart->setDict(dict); return; } ui->comboBox->setCurrentIndex(0); setSubDict(0); }
void CrossReferenceEditDialog::generateBasketList(KComboBox *targetList, BasketListViewItem *item, int indent) { if(!item) { // include ALL top level items and their children. for(int i = 0; i < Global::bnpView->topLevelItemCount(); ++i) this->generateBasketList(targetList, Global::bnpView->topLevelItem(i)); } else { BasketScene* bv = item->basket(); //TODO: add some fancy deco stuff to make it look like a tree list. QString pad; QString text = item->text(0); //user text text.prepend(pad.fill(' ', indent *2)); //create the link text QString link = "basket://"; link.append(bv->folderName().toLower()); //unique ref. QStringList data; data.append(link); data.append(bv->icon()); targetList->addItem(item->icon(0), text, QVariant(data)); int subBasketCount = item->childCount(); if(subBasketCount > 0) { indent++; for(int i = 0; i < subBasketCount; ++i) { this->generateBasketList(targetList, (BasketListViewItem*)item->child(i), indent); } } } }
void WP34sFlashDialog::setConsoleWidth(QTextEdit* aConsole) { QFontMetrics metrics(aConsole->font()); QString prototype; prototype.fill(CONSOLE_PROTOTYPE_CHAR, CONSOLE_WIDTH); aConsole->setMinimumWidth(metrics.width(prototype)); }
void RenderObject::printTree(int indent) const { QString ind; ind.fill(' ', indent); int childcount = 0; for(RenderObject* c = firstChild(); c; c = c->nextSibling()) childcount++; kdDebug() << ind << renderName() << (childcount ? (QString::fromLatin1("[") + QString::number(childcount) + QString::fromLatin1("]")) : QString::null) << "(" << (style() ? style()->refCount() : 0) << ")" << ": " << (void*)this << " il=" << (int)isInline() << " ci=" << (int) childrenInline() << " fl=" << (int)isFloating() << " rp=" << (int)isReplaced() << " an=" << (int)isAnonymousBox() << " ps=" << (int)isPositioned() << " cp=" << (int)containsPositioned() << " lt=" << (int)layouted() << " cw=" << (int)containsWidget() << " (" << xPos() << "," << yPos() << "," << width() << "," << height() << ")" << endl; RenderObject *child = firstChild(); while( child != 0 ) { child->printTree(indent+2); child = child->nextSibling(); } }
void AllegroTextBox::Draw() { int bbx; int bby; int bbw; int bbh; QString display = m_value; if (m_passwordMode) display.fill('*'); al_get_text_dimensions(m_boxFont, display.toStdString().c_str(), &bbx, &bby, &bbw, &bbh); int x1 = GetXPos(); int y1 = GetYPos(); int x2 = x1 + GetWidth(); int y2 = y1 + GetHeight(); al_draw_filled_rectangle(x1, y1, x2, y2, m_backgroundColor); al_draw_rectangle(x1, y1, x2, y2, GetFocus() ? m_focusedBorder : m_defaultBorder, 1); bool Overflow = (bbw > GetWidth() - m_sidePadding * 2); al_set_clipping_rectangle((m_xPos+m_sidePadding), m_yPos, (GetWidth()-m_sidePadding*2), GetHeight()); al_draw_text(m_boxFont, m_textColor, Overflow ? (m_xPos+GetWidth()-m_sidePadding) : (m_xPos+m_sidePadding), (m_yPos + (GetHeight() / 2) - bbh/2), Overflow ? ALLEGRO_ALIGN_RIGHT : ALLEGRO_ALIGN_LEFT, display.toStdString().c_str()); al_reset_clipping_rectangle(); }
/** @brief Returns HTML formated mixer representation @param[in] dest defines which mixer line to create. If dest < 0 then create empty channel slot for channel -dest ( dest=-2 -> CH2) if dest >=0 then create used channel based on model mix data from slot dest (dest=4 -> model mix[4]) @retval string mixer line in HTML */ QString MixesPanel::getMixerText(int dest, bool * new_ch) { QString str; bool newChannel = false; if (dest < 0) { str = modelPrinter.printMixerName(-dest); //highlight channel if needed if (-dest == (int)highlightedSource) { str = "<b>" + str + "</b>"; } newChannel = true; } else { MixData & mix = model->mixData[dest]; //mix->destCh from 1 to 32 str = modelPrinter.printMixerName(mix.destCh); if ((dest == 0) || (model->mixData[dest-1].destCh != mix.destCh)) { newChannel = true; //highlight channel if needed if (mix.destCh == highlightedSource) { str = "<b>" + str + "</b>"; } } else { str.fill(' '); } str += modelPrinter.printMixerLine(mix, !newChannel, highlightedSource); } if (new_ch) *new_ch = newChannel; return str.replace(" ", " "); }
void LinkDialog::generateBasketList(QTreeWidget *tree, QTreeWidgetItem *item, int indent) { if(!item) { for(int i = 0; i < tree->topLevelItemCount(); ++i) generateBasketList(tree, tree->topLevelItem(i), indent); } else { //TODO: add some fancy deco stuff to make it look like a tree list. QString pad; int pageNumber = item->data(0, Qt::UserRole).toInt(); //page number. QString text = item->data(0, Qt::DisplayRole).toString(); text.prepend(pad.fill(' ', indent *2)); ui->pageLink->addItem(item->icon(0), text, QVariant(pageNumber)); int subBasketCount = item->childCount(); if(subBasketCount > 0) { indent++; for(int i = 0; i < subBasketCount; ++i) { generateBasketList(tree, item->child(i), indent); } } } }
QString TableEditor::indent( int n ) { QString str; str.fill(' ', n); str.prepend('\n'); return str; }
QString KWord13Picture::getOasisPictureName( void ) const { if ( ! m_valid || ! m_tempFile ) return QString(); // We need a 32 digit hex value of the picture number // Please note: it is an exact 32 digit value, truncated if the value is more than 512 bits wide. :-) QString number; number.fill('0',32); // ### TODO: have a real counter instead of using the pointers number += QString::number( (long long)( (void*) m_tempFile ) , 16 ); // in hex QString strExtension( m_storeName.lower() ); const int result = m_storeName.findRev( '.' ); if ( result >= 0 ) { strExtension = m_storeName.mid( result ); } QString ooName( "Pictures/" ); ooName += number.right( 32 ); ooName += strExtension; return ooName; }
//! A size hint QSize QwtCounter::sizeHint() const { QString tmp; int w = tmp.setNum(minValue()).length(); int w1 = tmp.setNum(maxValue()).length(); if ( w1 > w ) w = w1; w1 = tmp.setNum(minValue() + step()).length(); if ( w1 > w ) w = w1; w1 = tmp.setNum(maxValue() - step()).length(); if ( w1 > w ) w = w1; tmp.fill('9', w); QFontMetrics fm(d_data->valueEdit->font()); w = fm.width(tmp) + 2; #if QT_VERSION >= 0x040000 if ( d_data->valueEdit->hasFrame() ) w += 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth); #else w += 2 * d_data->valueEdit->frameWidth(); #endif // Now we replace default sizeHint contribution of d_data->valueEdit by // what we really need. w += QWidget::sizeHint().width() - d_data->valueEdit->sizeHint().width(); const int h = qwtMin(QWidget::sizeHint().height(), d_data->valueEdit->minimumSizeHint().height()); return QSize(w, h); }
void Q3GCache::statistics() const { #if defined(QT_DEBUG) QString line; line.fill(QLatin1Char('*'), 80); qDebug("%s", line.ascii()); qDebug("CACHE STATISTICS:"); qDebug("cache contains %d item%s, with a total cost of %d", count(), count() != 1 ? "s" : "", tCost); qDebug("maximum cost is %d, cache is %d%% full.", mCost, (200*tCost + mCost) / (mCost*2)); qDebug("find() has been called %d time%s", lruList->finds, lruList->finds != 1 ? "s" : ""); qDebug("%d of these were hits, items found had a total cost of %d.", lruList->hits,lruList->hitCosts); qDebug("%d item%s %s been inserted with a total cost of %d.", lruList->inserts,lruList->inserts != 1 ? "s" : "", lruList->inserts != 1 ? "have" : "has", lruList->insertCosts); qDebug("%d item%s %s too large or had too low priority to be inserted.", lruList->insertMisses, lruList->insertMisses != 1 ? "s" : "", lruList->insertMisses != 1 ? "were" : "was"); qDebug("%d item%s %s been thrown away with a total cost of %d.", lruList->dumps, lruList->dumps != 1 ? "s" : "", lruList->dumps != 1 ? "have" : "has", lruList->dumpCosts); qDebug("Statistics from internal dictionary class:"); dict->statistics(); qDebug("%s", line.ascii()); #endif }
/** * @brief 创建一个字符串,格式为: "序号: + N个字符 + 结尾的x." * 例如:"2:--------x." * @param sn - 代表字符串的顺序,便于区别 * @return - 返回随机生成的字符串 */ QString generateMessage(int sn, char symbol) { QString str; str.fill(symbol, qrand() % 10 + 5); str.prepend(QString::number(sn) + ":"); str.append("x."); return str; }
/* static */ int UIGChooserItem::textWidth(const QFont &font, QPaintDevice *pPaintDevice, int iCount) { /* Return text width: */ QFontMetrics fm(font, pPaintDevice); QString strString; strString.fill('_', iCount); return fm.width(strString); }