[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Fri Jan 7 07:09:23 UTC 2005


CVS commit by okellogg: 

BUG:61945 - formatDoc(): Only wrap when a line's length exceeds lineWidth


  M +26 -19    codegenerator.cpp   1.63


--- kdesdk/umbrello/umbrello/codegenerator.cpp  #1.62:1.63
@@ -13,11 +13,17 @@
  */
 
+// own header
+#include "codegenerator.h"
+
+// system includes
 #include <cstdlib> //to get the user name
-#include <kdebug.h>
 
+// qt includes
 #include <qdatetime.h>
 #include <qregexp.h>
 #include <qdir.h>
 
+// kde includes
+#include <kdebug.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -25,9 +31,8 @@
 #include <kapplication.h>
 
+// app includes
 #include "dialogs/overwritedialogue.h"
-
-#include "codegenerator.h"
+#include "dialogs/codeviewerdialog.h"
 #include "codegenerators/simplecodegenerator.h"
-
 #include "attribute.h"
 #include "associationwidget.h"
@@ -43,5 +48,4 @@
 #include "umloperationlist.h"
 
-#include "dialogs/codeviewerdialog.h"
 
 // Constructors/Destructors
@@ -663,19 +667,22 @@ void CodeGenerator::findObjectsRelated(U
  */
 QString CodeGenerator::formatDoc(const QString &text, const QString &linePrefix, int lineWidth) {
-        QString output,
-        comment(text);
-
-        QString endLine = getNewLineEndingChars();
-        comment.replace(QRegExp(endLine)," ");
-        comment.simplifyWhiteSpace();
+        QString output, comment(text);
 
-        int index;
+        const QString endLine = getNewLineEndingChars();
+        QStringList lines = QStringList::split(endLine, comment);
+        for (QStringList::ConstIterator lit = lines.begin(); lit != lines.end(); ++lit) {
+                QString input = *lit;
+                input.remove( QRegExp("\\s+$") );
+                if (input.length() < (uint)lineWidth) {
+                        output += linePrefix + input + endLine;
+                        continue;
+                }
         do {
-                index = comment.findRev(" ",lineWidth + 1);
-                output += linePrefix + comment.left(index) + endLine; // add line
-                comment.remove(0, index + 1);                 //and remove processed string, including
+                        const int index = comment.findRev(" ", lineWidth + 1);
+                        output += linePrefix + input.left(index) + endLine; // add line
+                        input.remove(0, index + 1);     //and remove processed string, including
                 // white space
         } while(index > 0 );
-
+        }
         return output;
 }






More information about the umbrello-devel mailing list