]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QAbout.C
Get rid of the static_casts.
[lyx.git] / src / frontends / qt2 / QAbout.C
index 859c3cb5633fbfba88d0983c63218e43d4bd046e..0bf9ab2b8dd538cf311c6ab77162a66744c9c044 100644 (file)
@@ -1,21 +1,24 @@
 /**
  * \file QAbout.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Kalle Dalheimer <kalle@klaralvdalens-datakonsult.se>
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
+
 #include "support/lstrings.h"
 #include "Lsstream.h"
 #include "debug.h"
-#include "gettext.h"
+#include "qt_helpers.h"
 #include "LyXView.h"
-#include "ButtonControllerBase.h"
+#include "ButtonController.h"
 #include "ControlAboutlyx.h"
+
 #include <qlabel.h>
 #include <qpushbutton.h>
 #include <qtextview.h>
 
 using std::getline;
 
-typedef Qt2CB<ControlAboutlyx, Qt2DB<QAboutDialog> > base_class;
+typedef QController<ControlAboutlyx, QView<QAboutDialog> > base_class;
+
 
-QAbout::QAbout()
-       : base_class(_("About LyX"))
+QAbout::QAbout(Dialog & parent)
+       : base_class(parent, _("About LyX"))
 {
 }
 
 
 void QAbout::build_dialog()
 {
-       dialog_.reset(new QAboutDialog());
+       dialog_.reset(new QAboutDialog);
        connect(dialog_.get()->closePB, SIGNAL(clicked()),
                this, SLOT(slotClose()));
 
-       dialog_->copyright->setText(controller().getCopyright().c_str());
+       dialog_->copyright->setText(toqstr(controller().getCopyright()));
        dialog_->copyright->append("\n");
-       dialog_->copyright->append(controller().getLicense().c_str());
+       dialog_->copyright->append(toqstr(controller().getLicense()));
        dialog_->copyright->append("\n");
-       dialog_->copyright->append(controller().getDisclaimer().c_str());
+       dialog_->copyright->append(toqstr(controller().getDisclaimer()));
 
-       dialog_->versionLA->setText(controller().getVersion().c_str());
+       dialog_->versionLA->setText(toqstr(controller().getVersion()));
 
-       stringstream in;
+       // The code below should depend on a autoconf test. (Lgb)
+#if 1
+       // There are a lot of buggy stringstream implementations..., but the
+       // code below will work on all of them (I hope). The drawback with
+       // this solutions os the extra copying. (Lgb)
+
+       ostringstream in;
        controller().getCredits(in);
 
-       istringstream ss(in.str().c_str());
+       istringstream ss(in.str());
 
        string s;
-       string out;
+       ostringstream out;
 
        while (getline(ss, s)) {
                if (prefixIs(s, "@b"))
-                       out += "<b>" + s.substr(2) + "</b>";
+                       out << "<b>" << s.substr(2) << "</b>";
                else if (prefixIs(s, "@i"))
-                       out += "<i>" + s.substr(2) + "</i>";
+                       out << "<i>" << s.substr(2) << "</i>";
                else
-                       out += s;
-               out += "<br>";
+                       out << s;
+               out << "<br>";
        }
+#else
+       // Good stringstream implementations can handle this. It avoids
+       // some copying, and should thus be faster and use less memory. (Lgb)
+       // I'll make this the default for a short while to see if anyone
+       // see the error...
+       stringstream in;
+       controller().getCredits(in);
+       in.seekg(0);
+       string s;
+       ostringstream out;
+
+       while (getline(in, s)) {
+               if (prefixIs(s, "@b"))
+                       out << "<b>" << s.substr(2) << "</b>";
+               else if (prefixIs(s, "@i"))
+                       out << "<i>" << s.substr(2) << "</i>";
+               else
+                       out << s;
+               out << "<br>";
+       }
+#endif
+
+       dialog_->creditsTV->setText(toqstr(out.str()));
 
-       dialog_->creditsTV->setText(out.c_str());
+       // try to resize to a good size
+       dialog_->copyright->hide();
+       dialog_->setMinimumSize(dialog_->copyright->sizeHint());
+       dialog_->copyright->show();
+       dialog_->setMinimumSize(dialog_->sizeHint());
 
        // Manage the cancel/close button
-       bc().setCancel(dialog_->closePB);
+       bcview().setCancel(dialog_->closePB);
        bc().refresh();
 }