src/tools/uic/cpp/cppwriteicondata.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
--- a/src/tools/uic/cpp/cppwriteicondata.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/tools/uic/cpp/cppwriteicondata.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -114,10 +114,12 @@
 
 void WriteIconData::acceptImage(DomImage *image)
 {
-    writeImage(output, option.indent, image);
+    // Limit line length when writing code.
+    writeImage(output, option.indent, true, image);
 }
 
-void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomImage *image)
+void WriteIconData::writeImage(QTextStream &output, const QString &indent,
+                               bool limitXPM_LineLength, const DomImage *image)
 {
     QString img = image->attributeName() + QLatin1String("_data");
     QString data = image->elementData()->text();
@@ -133,7 +135,8 @@
         int a = 0;
         int column = 0;
         bool inQuote = false;
-        output << indent << "static const char* const " << img << "[] = { \n";
+        output << indent << "/* XPM */\n"
+               << indent << "static const char* const " << img << "[] = { \n";
         while (baunzip[a] != '\"')
             a++;
         for (; a < (int) length; a++) {
@@ -144,7 +147,8 @@
                 inQuote = !inQuote;
             }
 
-            if (column++ >= 511 && inQuote) {
+            column++;
+            if (limitXPM_LineLength && column >= 512 && inQuote) {
                 output << "\"\n\""; // be nice with MSVC & Co.
                 column = 1;
             }