[X2Go-Commits] [x2goclient] 01/02: {{onmainwindow, help}.cpp}, helph}: fix misc. build errors.

git-admin at x2go.org git-admin at x2go.org
Wed Apr 22 12:00:21 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/help-cmd
in repository x2goclient.

commit bbddcc4d55ee701ce02d091777df19458d903876
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Apr 22 11:51:00 2015 +0200

    {{onmainwindow,help}.cpp},helph}: fix misc. build errors.
---
 debian/changelog     |    1 +
 src/help.cpp         |   52 ++++++++++++++++++++++++++++++--------------------
 src/help.h           |    6 +++---
 src/onmainwindow.cpp |    4 ++--
 4 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 45dbf41..c8062f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -271,6 +271,7 @@ x2goclient (4.0.4.0-0x2go1) UNRELEASED; urgency=low
       mode.)
     - x2goclient.pro{,.maemo}: add new help.{cpp,h} files.
     - onmainwindow.cpp: replace old help system with new one.
+    - {{onmainwindow,help}.cpp},helph}: fix misc. build errors.
 
   [ Fernando Pedemonte ]
   * New upstream release (4.0.4.0):
diff --git a/src/help.cpp b/src/help.cpp
index d528698..4855a3a 100644
--- a/src/help.cpp
+++ b/src/help.cpp
@@ -19,7 +19,12 @@
 
 #include <QCoreApplication>
 #include <QtDebug>
+#include <QTextStream>
+#include <QString>
+#include <QFile>
+#include <QObject>
 #include <cstddef>
+#include <algorithm>
 
 /* For terminal size. */
 #ifdef Q_OS_WIN
@@ -41,20 +46,20 @@ help::prelude_t help::cleanup_prelude (help::prelude_t prelude) {
 }
 
 help::params_t help::cleanup_params (help::params_t params) {
-  for (help::params_t::const_iterator params_it = params.constBegin (); params_it != params.constEnd (); ++params_it) {
-    (*params_it).first = (*params_it).first.trimmed ();
-    (*params_it).second = (*params_it).second.trimmed ();
+  for (help::params_t::iterator it = params.begin (); it != params.end (); ++it) {
+    (*it).first = (*it).first.trimmed ();
+    (*it).second = (*it).second.trimmed ();
   }
 
   return (params);
 }
 
-help::prelude_t build_prelude () {
-  help::prelude_t ret ();
+help::prelude_t help::build_prelude () {
+  help::prelude_t ret;
 
   QStringList args = QCoreApplication::arguments ();
 
-  QString ver ("X2Go Client " << VERSION);
+  QString ver ("X2Go Client " + QString (VERSION));
 
   if (QFile::exists (":/txt/git-info")) {
     QFile file (":/txt/git-info");
@@ -65,13 +70,13 @@ help::prelude_t build_prelude () {
       QString git_info (stream.readAll ().trimmed ());
 
       if (!(git_info.isEmpty ())) {
-        ver << " (Git information: " << git_info << ")";
+        ver.append (" (Git information: " + git_info + ")");
       }
     }
   }
 
   ret.append (ver);
-  ret.append ("Usage: " << args.at (0) << " [OPTION]...");
+  ret.append ("Usage: " + QString (args.at (0)) + " [OPTION]...");
   ret.append ("Options:");
   ret.append ("");
 
@@ -79,9 +84,9 @@ help::prelude_t build_prelude () {
 }
 
 help::params_t help::build_params () {
-  params_t ret ();
+  params_t ret;
 
-# define ADD_OPT(param, desc) do { ret.append (params_elem_t (params, tr (desc))) } while (0)
+# define ADD_OPT(param, desc) do { ret.append (params_elem_t (param, QObject::tr (desc))); } while (0)
   ADD_OPT ("--help", "Shows this message.");
   ADD_OPT ("--version", "Prints version information.");
 
@@ -101,7 +106,7 @@ help::params_t help::build_params () {
   ADD_OPT ("--hide", "Starts hidden (minimized to system tray where available.)");
   ADD_OPT ("--portable", "Starts in \"portable\" mode.");
   ADD_OPT ("--pgp-card", "Forces OpenPGP smart card authentication.");
-  ADD_OPT ("--xinerama", "Enables Xinerama by default.")
+  ADD_OPT ("--xinerama", "Enables Xinerama by default.");
   ADD_OPT ("--ldap-printing", "Allows client side printing in LDAP mode.");
   ADD_OPT ("--thinclient", "Enables thinclient mode. Starts without a window manager.");
   ADD_OPT ("--haltbt", "Enables shutdown button.");
@@ -142,16 +147,19 @@ help::data_t help::build_data () {
   return (help::data_t (help::cleanup_prelude (help::build_prelude ()), help::cleanup_params (help::build_params ())));
 }
 
-QTextStream help::pretty_print (help::data_t data) {
-  help::data_t data = help::build_data ();
+QString help::pretty_print () {
+  return (help::pretty_print (help::build_data ()));
+}
 
-  QTextStream out << data.first.join ("\n") << "\n";
+QString help::pretty_print (help::data_t data) {
+  QTextStream out;
+  out << data.first.join ("\n") << "\n";
 
   std::size_t max_len = 0;
 
   /* Iterate over all parameter options and get max width. */
   for (help::params_t::const_iterator it = data.second.constBegin (); it != data.second.constEnd (); ++it) {
-    max_len = std::max (max_len, (*it).first.size ());
+    max_len = std::max (max_len, static_cast<std::size_t> ((*it).first.size ()));
   }
 
   std::size_t terminal_cols = 0;
@@ -195,7 +203,7 @@ QTextStream help::pretty_print (help::data_t data) {
         cur_len = working_copy.size ();
 
         /* Fits onto the current line. Great! */
-        if (remaining > cur_len) {
+        if (remaining > static_cast<std::ptrdiff_t> (cur_len)) {
           out << working_copy;
         }
         else {
@@ -214,15 +222,15 @@ QTextStream help::pretty_print (help::data_t data) {
             out << working_copy.left (split_point);
 
             /* If we split at a hyphen, don't lose it. */
-            if (working_copy.at (split_point).compare ("-") == 0) {
-              out << "-"
+            if (working_copy.at (split_point) == '-') {
+              out << "-";
             }
 
             working_copy = working_copy.mid (split_point);
 
             /* Do the next chunk, if there are remaining characters. */
             if (!working_copy.isEmpty ()) {
-              out << "\n"
+              out << "\n";
               out << QString (" ").repeated (indent);
             }
           }
@@ -237,7 +245,9 @@ QTextStream help::pretty_print (help::data_t data) {
     out << "\n";
   }
 
-  qCritical << out;
+  QString ret  = out.readAll ();
+
+  qCritical () << ret;
 
-  return (out);
+  return (ret);
 }
diff --git a/src/help.h b/src/help.h
index 01a2f10..69852b3 100644
--- a/src/help.h
+++ b/src/help.h
@@ -22,8 +22,7 @@
 
 #include <QPair>
 #include <QStringList>
-#include <vector>
-#include <algorithm>
+#include <QTextStream>
 
 namespace help {
   typedef QStringList prelude_t;
@@ -45,7 +44,8 @@ namespace help {
   params_t cleanup_params (params_t params);
 
   /* Prints a help_data_t structure. */
-  QTextStream pretty_print (data_t data);
+  QString pretty_print ();
+  QString pretty_print (data_t data);
 }
 
 #endif /* !defined (HELP_H) */
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index f1170c5..2230cd6 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -7180,11 +7180,11 @@ void ONMainWindow::printError ( QString param )
 
 void ONMainWindow::showHelp ()
 {
-    QTextStream out = help::pretty_print ();
+    QString out = help::pretty_print ();
     if (!startHidden && !haveTerminal) {
         HelpDialog dlg (this);
         dlg.setWindowTitle (tr ("Help"));
-        dlg.setText (out.readAll ());
+        dlg.setText (out);
         dlg.exec ();
     }
 }

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list