Commit 8275318f authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add some more build defines

Global defines:

  -DQT_USE_QSTRINGBUILDER
  -DQT_STRICT_ITERATORS
  -DQT_NO_SIGNALS_SLOTS_KEYWORDS

For libs and krita:

  -DQT_NO_URL_CAST_FROM_STRING

I cannot manage to fix all the places where a string is cast to
a QUrl in all of Calligra, though I fixed one egregious oopsie
in braindump.

I also would like the QString and QByteArray ascii cast defines,
but that's a huge battle!
parent 8fab67e8
......@@ -261,6 +261,15 @@ else()
set(HAVE_X11 FALSE)
endif()
# use sane compile flags
add_definitions(
-DQT_USE_QSTRINGBUILDER
-DQT_STRICT_ITERATORS
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_USE_FAST_CONCATENATION
)
# only with this definition will all the FOO_TEST_EXPORT macro do something
# TODO: check if this can be moved to only those places which make use of it,
# to reduce global compiler definitions that would trigger a recompile of
......@@ -277,15 +286,6 @@ if(WIN32)
set(WIN32_PLATFORM_NET_LIBS ws2_32.lib netapi32.lib)
endif()
# would need more code changes before 4.8.0, e.g. with qPrintable()
if(NOT ${QTVERSION} VERSION_LESS 4.8.0)
# enable QStringBuilder enhancement
add_definitions(
-DQT_USE_FAST_CONCATENATION
-DQT_USE_FAST_OPERATOR_PLUS
)
endif()
# set custom calligra plugin installdir
set(CALLIGRA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/calligra)
......
project(krita)
add_definitions(-DTRANSLATION_DOMAIN=\"krita\")
add_definitions(
-DTRANSLATION_DOMAIN=\"krita\"
-DQT_USE_QSTRINGBUILDER
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_USE_FAST_CONCATENATION
)
kde_enable_exceptions()
......
......@@ -95,7 +95,7 @@ KisAslCallbackObjectCatcher::~KisAslCallbackObjectCatcher()
template <class HashType, typename T>
inline void passToCallback(const QString &path, const HashType &hash, const T &value)
{
typename HashType::const_iterator it = hash.find(path);
typename HashType::const_iterator it = hash.constFind(path);
if (it != hash.constEnd()) {
(*it)(value);
}
......@@ -113,7 +113,7 @@ void KisAslCallbackObjectCatcher::addInteger(const QString &path, int value)
void KisAslCallbackObjectCatcher::addEnum(const QString &path, const QString &typeId, const QString &value)
{
MapHashEnum::const_iterator it = m_d->mapEnum.find(path);
MapHashEnum::const_iterator it = m_d->mapEnum.constFind(path);
if (it != m_d->mapEnum.constEnd()) {
if (it->typeId == typeId) {
it->map(value);
......@@ -125,7 +125,7 @@ void KisAslCallbackObjectCatcher::addEnum(const QString &path, const QString &ty
void KisAslCallbackObjectCatcher::addUnitFloat(const QString &path, const QString &unit, double value)
{
MapHashUnitFloat::const_iterator it = m_d->mapUnitFloat.find(path);
MapHashUnitFloat::const_iterator it = m_d->mapUnitFloat.constFind(path);
if (it != m_d->mapUnitFloat.constEnd()) {
if (it->unit == unit) {
it->map(value);
......@@ -157,7 +157,7 @@ void KisAslCallbackObjectCatcher::addPoint(const QString &path, const QPointF &v
void KisAslCallbackObjectCatcher::addCurve(const QString &path, const QString &name, const QVector<QPointF> &points)
{
MapHashCurve::const_iterator it = m_d->mapCurve.find(path);
MapHashCurve::const_iterator it = m_d->mapCurve.constFind(path);
if (it != m_d->mapCurve.constEnd()) {
(*it)(name, points);
}
......@@ -170,7 +170,7 @@ void KisAslCallbackObjectCatcher::addPattern(const QString &path, const KoPatter
void KisAslCallbackObjectCatcher::addPatternRef(const QString &path, const QString &patternUuid, const QString &patternName)
{
MapHashPatternRef::const_iterator it = m_d->mapPatternRef.find(path);
MapHashPatternRef::const_iterator it = m_d->mapPatternRef.constFind(path);
if (it != m_d->mapPatternRef.constEnd()) {
(*it)(patternUuid, patternName);
}
......
......@@ -480,7 +480,7 @@ bool KisApplication::start(const KisApplicationArguments &args)
if (exportAs) {
KMimeType::Ptr outputMimetype;
outputMimetype = KMimeType::findByUrl(exportFileName, 0, false, true /* file doesn't exist */);
outputMimetype = KMimeType::findByUrl(QUrl::fromLocalFile(exportFileName), 0, false, true /* file doesn't exist */);
if (outputMimetype->name() == KMimeType::defaultMimeType()) {
dbgKrita << i18n("Mimetype not found, try using the -mimetype option") << endl;
return 1;
......
......@@ -61,7 +61,7 @@ public:
{
}
QList<QWidget*> createItemWidgets(const QModelIndex& index) const
QList<QWidget*> createItemWidgets(const QModelIndex& /*index*/) const
{
// a lump of coal and a piece of elastic will get you through the world
QModelIndex idx = property("goya:creatingWidgetForIndex").value<QModelIndex>();
......
......@@ -519,10 +519,7 @@ public:
}
else
{
KUrl dirUrl( m_url );
dirUrl.setPath( dirUrl.directory() );
::org::kde::KDirNotify::emitFilesAdded( dirUrl.url() );
::org::kde::KDirNotify::emitFilesAdded(QUrl::fromLocalFile(m_url.directory()));
m_uploadJob = 0;
document->setModified( false );
emit document->completed();
......
......@@ -275,7 +275,7 @@ void KisTemplateTree::writeTemplate(KisTemplate *t, KisTemplateGroup *group,
if (t->isHidden() && QFile::exists(fileName))
return;
QString fill;
while (KIO::NetAccess::exists(fileName, KIO::NetAccess::SourceSide, 0)) {
while (QFile(fileName).exists()) {
fill += '_';
fileName = path + fill + name + ".desktop";
}
......
......@@ -38,7 +38,7 @@ class EventEater : public QObject
public:
EventEater() : QObject(0), hungry(false) {}
bool eventFilter(QObject* object, QEvent* event )
bool eventFilter(QObject* /*object*/, QEvent* event )
{
if ((hungry && (event->type() == QEvent::MouseMove ||
event->type() == QEvent::MouseButtonPress ||
......
......@@ -888,7 +888,7 @@ void KisLayerManager::saveGroupLayers()
dlg.setMainWidget(page);
QBoxLayout *layout = new QVBoxLayout(page);
KFileWidget *fd = new KFileWidget(m_view->document()->url().path(), page);
KFileWidget *fd = new KFileWidget(QUrl::fromLocalFile(m_view->document()->url().path()), page);
fd->setUrl(m_view->document()->url());
fd->setMimeFilter(listMimeFilter);
fd->setOperationMode(KFileWidget::Saving);
......
......@@ -164,7 +164,7 @@ void writeRawProfile(png_struct *ping, png_info *ping_info, QString profile_type
text[0].text = (png_charp) png_malloc(ping, allocated_length);
QString key = "Raw profile type " + profile_type.toLatin1();
QString key = QLatin1Literal("Raw profile type ") + profile_type.toLatin1();
QByteArray keyData = key.toLatin1();
text[0].key = keyData.data();
......
add_definitions(-DTRANSLATION_DOMAIN=\"calligra\")
add_definitions(
-DTRANSLATION_DOMAIN=\"calligra\"
-DQT_USE_QSTRINGBUILDER
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_USE_FAST_CONCATENATION
)
if (SHOULD_BUILD_LIB_CALLIGRA)
add_subdirectory( version )
......
......@@ -99,7 +99,7 @@ void KoAnnotationLayoutManager::paintConnections(QPainter &painter)
painter.setPen(pen);
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.end() && !d->annotationShapePositions.isEmpty()) {
while (it != d->annotationShapePositions.constEnd() && !d->annotationShapePositions.isEmpty()) {
KoShape *shape = it->second;
// To make it more beautiful start line from shape a little downer of top-left of annotation shape (shape->position().y() + 20.0).
......@@ -161,7 +161,7 @@ void KoAnnotationLayoutManager::registerAnnotationRefPosition(KoShape *annotatio
void KoAnnotationLayoutManager::removeAnnotationShape(KoShape *annotationShape)
{
QList< QPair < QPointF, KoShape * > >::iterator it = d->annotationShapePositions.begin();
while (it != d->annotationShapePositions.constEnd()) {
while (it != d->annotationShapePositions.end()) {
if (it->second == annotationShape) {
d->annotationShapePositions.erase(it);
break;
......@@ -179,7 +179,7 @@ void KoAnnotationLayoutManager::removeAnnotationShape(KoShape *annotationShape)
void KoAnnotationLayoutManager::updateLayout(KoShape *shape)
{
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.end() && !d->annotationShapePositions.isEmpty()) {
while (it != d->annotationShapePositions.constEnd() && !d->annotationShapePositions.isEmpty()) {
if (it->second == shape) {
layoutAnnotationShapes();
break;
......@@ -194,7 +194,7 @@ void KoAnnotationLayoutManager::layoutAnnotationShapes()
qStableSort(d->annotationShapePositions.begin(), d->annotationShapePositions.end(), compare);
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.end()) {
while (it != d->annotationShapePositions.constEnd()) {
KoShape *shape = it->second;
qreal refPosition = it->first.y();
if (refPosition > currentY) {
......
......@@ -574,7 +574,8 @@ void KoUnavailShape::Private::storeXmlRecursive(const KoXmlElement &el, KoXmlWri
nsShort = QString("ns%1").arg(unknownNamespaces.size() + 1);
unknownNamespaces.insert(attrPair.first, nsShort);
}
writer.addAttribute("xmlns:" + nsShort.toLatin1(), attrPair.first);
QString name = QString("xmlns:") + nsShort;
writer.addAttribute(name.toLatin1(), attrPair.first.toLatin1());
}
QString attr(nsShort + ':' + attrPair.second);
writer.addAttribute(attr.toLatin1(), el.attributeNS(attrPair.first,
......
......@@ -116,12 +116,12 @@ void TestImageCollection::testGetImageStore()
// Opening a KoStore based file we only have the content, and we always have to
// read the full content anyway due to the store being deleted soon after.
// So the key is based on the image data.
KoImageData *id3 = collection.createExternalImageData(image);
KoImageData *id3 = collection.createExternalImageData(QUrl::fromLocalFile(image));
QCOMPARE(collection.count(), 2);
QVERIFY(id1->key() != id3->key());
QVERIFY(id1->priv() != id3->priv());
QString image2("logo-kpresenter.png");
KoImageData *id4 = collection.createExternalImageData(image2);
KoImageData *id4 = collection.createExternalImageData(QUrl::fromLocalFile(image2));
QCOMPARE(id4->hasCachedImage(), false);
QVERIFY(id1->key() != id4->key());
QCOMPARE(collection.count(), 3);
......
......@@ -419,9 +419,7 @@ public:
}
else
{
KUrl dirUrl( m_url );
dirUrl.setPath( dirUrl.directory() );
::org::kde::KDirNotify::emitFilesAdded( dirUrl.url() );
::org::kde::KDirNotify::emitFilesAdded(QUrl::fromLocalFile(m_url.directory()));
m_uploadJob = 0;
document->setModified( false );
......
......@@ -288,7 +288,7 @@ void KoTemplateTree::writeTemplate(KoTemplate *t, KoTemplateGroup *group,
if (t->isHidden() && QFile::exists(fileName))
return;
QString fill;
while (KIO::NetAccess::exists(fileName, KIO::NetAccess::SourceSide, 0)) {
while (QFile(fileName).exists()) {
fill += '_';
fileName = path + fill + name + ".desktop";
}
......
......@@ -275,12 +275,12 @@ bool KoDocumentInfo::saveOasisAboutInfo(KoXmlWriter &xmlWriter)
} else if (tag == "title" || tag == "description" || tag == "subject" ||
tag == "date" || tag == "language") {
QByteArray elementName(QString("dc:" + tag).toLatin1());
xmlWriter.startElement(elementName);
xmlWriter.startElement(elementName.constData());
xmlWriter.addTextNode(aboutInfo(tag));
xmlWriter.endElement();
} else {
QByteArray elementName(QString("meta:" + tag).toLatin1());
xmlWriter.startElement(elementName);
xmlWriter.startElement(elementName.constData());
xmlWriter.addTextNode(aboutInfo(tag));
xmlWriter.endElement();
}
......
......@@ -126,7 +126,9 @@ void TestKoLZF::testArrayRoundtripDifferentSizes_data()
data[b] = b % 256;
}
}
QTest::newRow(QByteArray::number(i)+'-'+QByteArray(1, canary[c]).toHex()+'-'+fillMethodName[f])
QByteArray ba = QByteArray::number(i)+'-'+QByteArray(1, canary[c]).toHex()+'-'+QByteArray(fillMethodName[f]);
QTest::newRow(ba.constData())
<< data << i << canary[c];
}
}
......@@ -224,8 +226,8 @@ void TestKoLZF::testByteArrayRoundtripDifferentSizes_data()
data[b] = b % 256;
}
}
QTest::newRow(QByteArray::number(i)+'-'+fillMethodName[f]) << data;
QByteArray ba = QByteArray::number(i)+'-'+fillMethodName[f];
QTest::newRow(ba.constData()) << data;
}
}
}
......
......@@ -11,7 +11,7 @@ class TestOdfSettings : public QObject
public:
TestOdfSettings() { }
private slots:
private Q_SLOTS:
void initTestCase();
void testParseConfigItemString();
void testSelectItemSet();
......
......@@ -33,7 +33,7 @@
class TestStorage : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void storage_data();
void storage();
void storage2_data();
......@@ -87,7 +87,8 @@ void TestStorage::storage()
QDir dirTest(testFile);
if (dirTest.exists()) {
#ifdef Q_OS_UNIX
system(QByteArray("rm -rf ") + QFile::encodeName(testFile)); // QDir::rmdir isn't recursive!
QByteArray ba = QByteArray("rm -rf ") + QFile::encodeName(testFile);
system(ba.constData()); // QDir::rmdir isn't recursive!
#else
QFAIL("build dir not empty");
#endif
......@@ -220,7 +221,8 @@ void TestStorage::storage2()
QDir dirTest(testFile);
if (dirTest.exists()) {
#ifdef Q_OS_UNIX
system(QByteArray("rm -rf ") + QFile::encodeName(testFile)); // QDir::rmdir isn't recursive!
QByteArray ba = QByteArray("rm -rf ") + QFile::encodeName(testFile);
system(ba.constData()); // QDir::rmdir isn't recursive!
#else
QFAIL("build dir not empty");
#endif
......
......@@ -15,7 +15,7 @@
class TestXmlReader : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void testNode();
void testElement();
void testAttributes();
......
......@@ -15,7 +15,7 @@
class TestXmlReaderWithoutSpaces : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void testNode();
void testElement();
void testAttributes();
......
......@@ -26,7 +26,7 @@
class TestXmlWriter : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void testDocytype();
void testEmtpyElement();
void testAttributes();
......
......@@ -50,9 +50,9 @@ void KoCompositeColorTransformation::appendTransform(KoColorTransformation *tran
void KoCompositeColorTransformation::transform(const quint8 *src, quint8 *dst, qint32 nPixels) const
{
QVector<KoColorTransformation*>::const_iterator begin = m_d->transformations.begin();
QVector<KoColorTransformation*>::const_iterator begin = m_d->transformations.constBegin();
QVector<KoColorTransformation*>::const_iterator it = begin;
QVector<KoColorTransformation*>::const_iterator end = m_d->transformations.end();
QVector<KoColorTransformation*>::const_iterator end = m_d->transformations.constEnd();
for (; it != end; ++it) {
if (it == begin) {
......
......@@ -136,7 +136,7 @@ void KoFileDialog::setImageFilters()
QStringList imageFilters;
// add filters for all formats supported by QImage
foreach(const QByteArray &format, QImageReader::supportedImageFormats()) {
imageFilters << "image/" + format;
imageFilters << QLatin1String("image/") + format;
}
setMimeTypeFilters(imageFilters);
}
......@@ -450,7 +450,7 @@ const QStringList KoFileDialog::getFilterStringListFromMime(const QStringList &m
QString oneFilter;
QStringList patterns = mimeType->patterns();
QStringList::ConstIterator jt;
for (jt = patterns.begin(); jt != patterns.end(); ++jt) {
for (jt = patterns.constBegin(); jt != patterns.constEnd(); ++jt) {
if (d->swapExtensionOrder) {
oneFilter.prepend(*jt + " ");
if (withAllSupportedEntry) {
......
......@@ -105,7 +105,7 @@ void KoProperties::save(QDomElement &root) const
QByteArray bytes;
QDataStream out(&bytes, QIODevice::WriteOnly);
out << v;
QDomText text = doc.createCDATASection(QString::fromLatin1(bytes, bytes.size()));
QDomText text = doc.createCDATASection(QString::fromLatin1(bytes));
e.appendChild(text);
root.appendChild(e);
}
......
......@@ -310,19 +310,22 @@ void MultiscriptElement::writeMathMLContent( KoXmlWriter* writer, const QString&
tmp->writeMathML( writer, ns );
else {
//We need to use a none element for missing elements in the super/sub scripts
writer->startElement( ns.isEmpty() ? "none" : ns.toLatin1() + ":none" );
QString s = ns.isEmpty() ? QString::fromLatin1("none") : ns.toLatin1() + QString::fromLatin1(":none");
writer->startElement(s.toLatin1());
writer->endElement();
}
}
if( m_preScripts.isEmpty() ) return;
writer->startElement( ns.isEmpty() ? "mprescripts" : ns.toLatin1() + ":mprescripts" );
QString s = ns.isEmpty() ? QString::fromLatin1("mprescripts") : ns.toLatin1() + QString::fromLatin1(":mprescripts");
writer->startElement(s.toLatin1());
writer->endElement();
foreach( BasicElement* tmp, m_preScripts ) {
if(tmp)
tmp->writeMathML( writer, ns );
else {
//We need to use a none element for missing elements in the super/sub scripts
writer->startElement( ns.isEmpty() ? "none" : ns.toLatin1() + ":none" );
QString n = ns.isEmpty() ? QString::fromLatin1("none") : ns.toLatin1() + QString::fromLatin1(":none");
writer->startElement(n.toLatin1());
writer->endElement();
}
}
......
......@@ -38,7 +38,7 @@ bool validateOutput(MusicCore::Sheet* sheet, const char* fname);
class MusicXmlWriterTest : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void init()
{
}
......
......@@ -31,7 +31,7 @@ class SheetTest : public QObject
Q_OBJECT
private:
Sheet* sheet;
private slots:
private Q_SLOTS:
void init()
{
sheet = new Sheet();
......
......@@ -33,7 +33,7 @@ class VoiceBarTest : public QObject
Q_OBJECT
private:
MusicCore::VoiceBar* voiceBar;
private slots:
private Q_SLOTS:
void init()
{
Sheet* sheet = new Sheet();
......
......@@ -77,7 +77,7 @@ void PictureShapeConfigWidget::open(KoShape *shape)
m_fileWidget->setOperationMode(KFileWidget::Opening);
QStringList imageFilters;
foreach(const QByteArray &format, QImageReader::supportedImageFormats()) {
imageFilters << "image/" + format;
imageFilters << QString("image/") + format;
}
m_fileWidget->setMimeFilter(imageFilters);
//m_fileWidget->setFilter("image/png image/jpeg image/gif");
......
......@@ -11,11 +11,11 @@
class TestStylesModel : public QObject
{
Q_OBJECT
public slots:
public Q_SLOTS:
void init();
void cleanup();
private slots:
private Q_SLOTS:
void testPrecalcCache();
void testSetManager();
......
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