Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Set QStrings to empty by using .clear(), not assigning "" && no need to...

Set QStrings to empty by using .clear(), not assigning "" && no need to initialize QStrings with "", unless using .isNull()
parent aebf18b8
......@@ -108,7 +108,7 @@ public:
void setProgress(KoUpdater * progressUpdater);
/// Begin an undoable paint operation
void beginTransaction(const QString& transactionName = "");
void beginTransaction(const QString& transactionName = QString());
/// Return the transaction's text message
QString transactionText();
......
......@@ -110,7 +110,7 @@ public:
bool getBool(const QString & name, bool def = false) const;
QString getString(const QString & name, const QString & def = "") const;
QString getString(const QString & name, const QString & def = QString()) const;
KisCubicCurve getCubicCurve(const QString & name, const KisCubicCurve & curve = KisCubicCurve()) const;
......
......@@ -36,7 +36,6 @@ struct Entry::Private {
Entry::Entry() :
d(new Private)
{
d->name = "";
d->schema = 0;
d->valid = false;
}
......
......@@ -143,7 +143,7 @@ QList<KisNodeSP> KisNodeQueryPath::queryNodes(KisImageWSP image, KisNodeSP curre
QString KisNodeQueryPath::toString() const
{
QString str = "";
QString str;
if (!d->relative) {
str = '/';
} else if (d->elements.count() == 0) {
......
......@@ -184,10 +184,9 @@ static QString p_enum(QDataStream &buf){
static quint32 parseEntry(QDataStream &buf){
quint32 nlen;
QString value = "";
QString value;
buf >> nlen;
if (nlen == 0){
nlen = 4;
......
......@@ -180,9 +180,9 @@ quint32 AbrStructParser::parseEntry(QDataStream &buf){
if (nlen == 0){
nlen = 4;
}
QString value = "";
QString value;
if (nlen == MAGIC_OBJC_LENGTH){
value = p_objc(buf);
qDebug() << ABR_PRESET_START << ABR_OBJECT << value;
......
......@@ -25,7 +25,7 @@
class KRITAUI_EXPORT KisTransactionBasedCommand : public KUndo2Command
{
public:
KisTransactionBasedCommand(const QString &text = "", KUndo2Command *parent = 0);
KisTransactionBasedCommand(const QString &text = QString(), KUndo2Command *parent = 0);
~KisTransactionBasedCommand();
......
......@@ -386,7 +386,7 @@ bool KisExifIO::saveTo(KisMetaData::Store* store, QIODevice* ioDevice, HeaderTyp
try {
const KisMetaData::Entry& entry = *it;
dbgFile << "Trying to save: " << entry.name() << " of " << entry.schema()->prefix() << ":" << entry.schema()->uri();
QString exivKey = "";
QString exivKey;
if (entry.schema()->uri() == KisMetaData::Schema::TIFFSchemaUri) {
exivKey = "Exif.Image." + entry.name();
} else if (entry.schema()->uri() == KisMetaData::Schema::EXIFSchemaUri) { // Distinguish between exif and gps
......
......@@ -198,7 +198,7 @@ int KoFavoriteResourceManager::numFavoritePresets()
void KoFavoriteResourceManager::saveFavoritePresets()
{
QString favoriteList = "";
QString favoriteList;
for (int pos = 0; pos < m_favoritePresetsList.size(); pos++)
{
......
......@@ -64,7 +64,7 @@ private:
bool loadMetaData(KisNode* node);
void initSelectionForMask(KisMask *mask);
void loadSelection(const QString& location, KisSelectionSP dstSelection);
QString getLocation(KisNode* node, const QString& suffix = "");
QString getLocation(KisNode* node, const QString& suffix = QString());
private:
KisImageWSP m_image;
......
......@@ -67,7 +67,7 @@ private:
bool saveSelection(KisNode* node);
bool saveFilterConfiguration(KisNode* node);
bool saveMetaData(KisNode* node);
QString getLocation(KisNode* node, const QString& suffix = "");
QString getLocation(KisNode* node, const QString& suffix = QString());
private:
......
......@@ -652,7 +652,7 @@ bool Connection::useDatabase(const QString &dbName, bool kexiCompatible, bool *c
if (!d->usedDatabase.isEmpty() && !closeDatabase()) //close db if already used
return false;
d->usedDatabase = "";
d->usedDatabase.clear();
if (!drv_useDatabase(my_dbName, cancelled, msgHandler)) {
if (cancelled && *cancelled)
......@@ -752,7 +752,7 @@ bool Connection::closeDatabase()
if (!drv_closeDatabase())
return false;
d->usedDatabase = "";
d->usedDatabase.clear();
// KexiDBDbg << "Connection::closeDatabase(): " << ret;
return ret;
}
......
......@@ -118,7 +118,7 @@ Field* Field::copy() const
void Field::init()
{
m_parent = 0;
m_name = "";
m_name.clear();
m_type = InvalidType;
m_precision = 0;
m_visibleDecimalPlaces = -1;
......
......@@ -933,7 +933,7 @@ QString QuerySchema::debugString() const
if (d->tableAliases.isEmpty())
aliases = "<NONE>";
else {
aliases = "";
aliases.clear();
int i = -1;
foreach(TableSchema* table, d->tables) {
i++;
......
......@@ -1357,7 +1357,7 @@ QList<int> KexiDB::stringListToIntList(const QStringList &list, bool *ok)
// Based on KConfigGroupPrivate::serializeList() from kconfiggroup.cpp (kdelibs 4)
QString KexiDB::serializeList(const QStringList &list)
{
QString value = "";
QString value;
if (!list.isEmpty()) {
QStringList::ConstIterator it = list.constBegin();
......
......@@ -190,7 +190,7 @@ QString SvgSavingContext::saveImage(const QImage &image)
// get the mime type from the temp file content
KMimeType::Ptr mimeType = KMimeType::findByFileContent(imgFile.fileName());
// get extension from mimetype
QString ext = "";
QString ext;
QStringList patterns = mimeType->patterns();
if (patterns.count())
ext = patterns.first().mid(1);
......@@ -228,7 +228,7 @@ QString SvgSavingContext::saveImage(KoImageData *image)
// get the mime type from the temp file content
KMimeType::Ptr mimeType = KMimeType::findByFileContent(imgFile.fileName());
// get extension from mimetype
QString ext = "";
QString ext;
QStringList patterns = mimeType->patterns();
if (patterns.count())
ext = patterns.first().mid(1);
......
......@@ -27,7 +27,7 @@
#include <QCloseEvent>
KoPAViewMode::KoPAViewMode( KoPAViewBase * view, KoPACanvasBase * canvas, QString name)
KoPAViewMode::KoPAViewMode( KoPAViewBase * view, KoPACanvasBase * canvas, const QString &name)
: m_canvas( canvas )
, m_toolProxy( canvas->toolProxy() )
, m_view( view )
......
......@@ -48,7 +48,7 @@ class KOPAGEAPP_EXPORT KoPAViewMode : public QObject
Q_OBJECT
public:
KoPAViewMode(KoPAViewBase * view, KoPACanvasBase * canvas, QString name = "");
KoPAViewMode(KoPAViewBase * view, KoPACanvasBase * canvas, const QString& name = QString());
virtual ~KoPAViewMode();
virtual void paint(KoPACanvasBase* canvas, QPainter& painter, const QRectF &paintRect) = 0;
......
......@@ -407,7 +407,7 @@ QString KoTextDebug::paraAttributes(const QTextBlockFormat &blockFormat)
break;
case KoParagraphStyle::TabPositions:
key = "tab-stops";
value = "";
value.clear();
foreach(const QVariant & qvtab, qvariant_cast<QList<QVariant> >(properties[id])) {
KoText::Tab tab = qvtab.value<KoText::Tab>();
value.append("{");
......@@ -653,7 +653,7 @@ QString KoTextDebug::tableAttributes(const QTextTableFormat &tableFormat)
value = "justify";
break;
default:
value = "";
value.clear();
break;
}
break;
......
......@@ -267,7 +267,7 @@ QString KoTextWriter::Private::saveTableStyle(const QTextTable& table)
{
KoTableStyle *originalTableStyle = styleManager->tableStyle(table.format().intProperty(KoTableStyle::StyleId));
QString generatedName;
QString internalName = "";
QString internalName;
if (originalTableStyle)
{
internalName = QString(QUrl::toPercentEncoding(originalTableStyle->name(), "", " ")).replace('%', '_');
......@@ -458,7 +458,7 @@ void KoTextWriter::Private::saveParagraph(const QTextBlock &block, int from, int
if ((!previousFragmentLink.isEmpty()) && (charFormat.anchorHref() != previousFragmentLink || !charFormat.isAnchor())) {
// Close the current text:a
closeTagRegion();
previousFragmentLink = "";
previousFragmentLink.clear();
}
if (charFormat.isAnchor() && charFormat.anchorHref() != previousFragmentLink) {
......
......@@ -398,7 +398,7 @@ Qt::Alignment KoTableStyle::alignmentFromString(const QString &align)
QString KoTableStyle::alignmentToString(Qt::Alignment alignment)
{
QString align = "";
QString align;
if (alignment == Qt::AlignLeft)
align = "left";
else if (alignment == Qt::AlignRight)
......
......@@ -209,7 +209,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
int loop = (number-1)/26;
int rem = (number-1)%26;
QChar letter = (char)(rem+97);
QString alpha = "";
QString alpha;
for (int i=0; i<=loop; i++) {
alpha.append(letter);
}
......@@ -217,7 +217,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
} else {
int loop = (number-1)/26;
QChar letter;
QString alpha = "";
QString alpha;
if (loop>0) {
letter = (char)(loop+96);
alpha.append(letter);
......@@ -235,7 +235,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
int loop = (number-1)/26;
int rem = (number-1)%26;
QChar letter = (char)(rem+65);
QString alpha = "";
QString alpha;
for (int i=0; i<=loop; i++) {
alpha.append(letter);
}
......@@ -243,7 +243,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
} else {
int loop = (number-1)/26;
QChar letter;
QString alpha = "";
QString alpha;
if (loop>0) {
letter = (char)(loop+64);
alpha.append(letter);
......@@ -257,7 +257,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
}
case RomanLowerCase:
{
QString roman = "";
QString roman;
int loop = number/1000;
for (int i=1; i<=loop && number/1000!=0; i++) {
roman.append("m");
......@@ -304,7 +304,7 @@ QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition
}
case RomanUpperCase:
{
QString roman = "";
QString roman;
int loop = number/1000;
for (int i=1; i<=loop && number/1000!=0; i++) {
roman.append("M");
......
......@@ -292,7 +292,7 @@ KoColor KoColor::fromXML(const QDomElement& elt, const QString & bitDepthId, con
profileName = aliases.value(profileName);
}
if (!KoColorSpaceRegistry::instance()->profileByName(profileName)) {
profileName = "";
profileName.clear();
}
}
const KoColorSpace* cs = KoColorSpaceRegistry::instance()->colorSpace(modelId, bitDepthId, profileName);
......
......@@ -423,7 +423,7 @@ QString KoColorConversionSystem::bestPathToDot(const QString& srcKey, const QStr
dot += QString(" \"%1\" [color=red]\n").arg(srcNode->id());
dot += QString(" \"%1\" [color=red]\n").arg(dstNode->id());
foreach(Vertex* oV, d->vertexes) {
QString options = "";
QString options;
if (p->vertexes.contains(oV)) {
options = "[color=red]";
}
......
......@@ -171,7 +171,6 @@ void KoRdfLocation::updateFromEditorData()
}
if (!m_isGeo84) {
if (!m_joiner.isValid()) {
QString tmp = "";
Node newV = createNewUUIDNode();
QSharedPointer<Soprano::Model> m = m_rdf->model();
......@@ -313,7 +312,6 @@ void KoRdfLocation::setName(const QString &name)
}
if (!m_isGeo84) {
if (!m_joiner.isValid()) {
QString tmp = "";
Node newV = createNewUUIDNode();
QSharedPointer<Soprano::Model> m = m_rdf->model();
......@@ -354,7 +352,6 @@ void KoRdfLocation::setDlat(double dlat)
}
if (!m_isGeo84) {
if (!m_joiner.isValid()) {
QString tmp = "";
Node newV = createNewUUIDNode();
QSharedPointer<Soprano::Model> m = m_rdf->model();
......
......@@ -23,7 +23,7 @@
void KoPropertiesTest::testDeserialization()
{
QString test = "";
QString test;
KoProperties props;
props.setProperty("bla", "bla");
......
......@@ -97,7 +97,7 @@ private slots:
void setPieExplodeFactor(DataSet *dataSet, int percent);
// Axes
void addAxis(AxisDimension, const QString& title = "");
void addAxis(AxisDimension, const QString& title = QString());
void removeAxis(Axis *axis);
void setAxisShowTitle(Axis *axis, bool show);
void setAxisTitle(Axis *axis, const QString& title);
......
......@@ -1736,7 +1736,7 @@ void DataSet::saveOdf(KoShapeSavingContext &context) const
style.addProperty("chart:data-label-symbol", "true");
if (d->symbolsActivated) {
QString symbolName = "";
QString symbolName;
QString symbolType = "named-symbol";
if (!d->markerIsAutoSet) {
......
......@@ -349,12 +349,12 @@ TokenList EnhancedPathFormula::scan(const QString &formula) const
} else if (ch == '(') { // a '(' ? then this must be a function identifier
tokens.append(FormulaToken(FormulaToken::TypeFunction, tokenText, tokenStart));
tokenStart = i;
tokenText = "";
tokenText.clear();
state = Start;
} else { // we're done with identifier
tokens.append(FormulaToken(FormulaToken::TypeReference, tokenText, tokenStart));
tokenStart = i;
tokenText = "";
tokenText.clear();
state = Start;
}
break;
......@@ -372,7 +372,7 @@ TokenList EnhancedPathFormula::scan(const QString &formula) const
state = InExpIndicator;
} else { // we're done with integer number
tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));
tokenText = "";
tokenText.clear();
state = Start;
};
break;
......@@ -386,7 +386,7 @@ TokenList EnhancedPathFormula::scan(const QString &formula) const
state = InExpIndicator;
} else { // we're done with floating-point number
tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));
tokenText = "";
tokenText.clear();
state = Start;
};
break;
......@@ -406,7 +406,7 @@ TokenList EnhancedPathFormula::scan(const QString &formula) const
tokenText.append(expr[i++]);
} else { // we're done with floating-point number
tokens.append(FormulaToken(FormulaToken::TypeNumber, tokenText, tokenStart));
tokenText = "";
tokenText.clear();
state = Start;
}
break;
......
......@@ -66,7 +66,7 @@ QString DocumentListWindow::currentDocument()
int selectedRow = m_docListDialog->listView->currentIndex().row();
QString name = m_docListDialog->listView->model()->index(selectedRow, 0).data().toString();
QString type = m_docListDialog->listView->model()->index(selectedRow, 2).data().toString();
QString ext = "";
QString ext;
if (QString::compare(type, "document", Qt::CaseInsensitive) == 0 ) {
ext = ".odt";
......
......@@ -69,7 +69,7 @@ QString GoogleDocumentList::author ()
void GoogleDocumentList::append(GoogleDocument *entry)
{
if (entry != 0 ) {
QString iconPath = "";
QString iconPath;
if (QString::compare(entry->documentType(), "document", Qt::CaseInsensitive) == 0) {
iconPath = ":/images/document.png";
} else if (QString::compare(entry->documentType(), "spreadsheet", Qt::CaseInsensitive) == 0) {
......
......@@ -120,7 +120,7 @@ void GoogleDocumentService::handleNetworkData(QNetworkReply *networkReply)
return;
}
spreadAuthToken = authToken;
authToken = "";
authToken.clear();
loggedin = true;
qDebug() << "Received Spreadsheet token = " << spreadAuthToken;
listDocuments();
......@@ -185,7 +185,7 @@ void GoogleDocumentService::downloadDocument(const QString & _url, const QString
QString url = _url;
QString type = _type;
url.replace("docId", "docID", Qt::CaseInsensitive);
QString exportFormat = "";
QString exportFormat;
if(QString::compare(type, "spreadsheet", Qt::CaseInsensitive) == 0) {
exportFormat = "&exportFormat=ods&format=ods";
......
......@@ -88,7 +88,7 @@ void DateVariable::saveOdf(KoShapeSavingContext & context)
bool DateVariable::loadOdf(const KoXmlElement & element, KoShapeLoadingContext & context)
{
const QString localName(element.localName());
QString dateFormat = "";
QString dateFormat;
QString dataStyle = element.attributeNS(KoXmlNS::style, "data-style-name");
if (!dataStyle.isEmpty()) {
if (context.odfLoadingContext().stylesReader().dataFormats().contains(dataStyle)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment