From 3fcde2612b6e0f00df629f6268a9869dadc4bb08 Mon Sep 17 00:00:00 2001 From: telwertowski Date: Mon, 2 Jan 2006 03:50:58 +0000 Subject: [PATCH] Port MessageViewer dialog to Qt4. (qgsmessageviewer.ui.h converted to qgsmessageviewer.cpp/h) Also remove some 'fixme' comments for other items which have recently been ported to Qt4. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4461 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/Makefile.am | 2 ++ src/qgisapp.cpp | 19 +++++++--------- src/qgsmessageviewer.cpp | 45 ++++++++++++++++++++++++++++++++++++++ src/qgsmessageviewer.h | 34 ++++++++++++++++++++++++++++ src/qgsrunprocess.cpp | 37 ++++++++++--------------------- src/ui/qgsmessageviewer.ui | 19 +++++++++++++++- 6 files changed, 119 insertions(+), 37 deletions(-) create mode 100644 src/qgsmessageviewer.cpp create mode 100644 src/qgsmessageviewer.h diff --git a/src/Makefile.am b/src/Makefile.am index b8882dd1316..f826da74cff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -134,6 +134,7 @@ libqgisHEADERS = \ qgsmarkerdialog.h \ qgsmarkersymbol.h \ qgsmeasure.h \ + qgsmessageviewer.h \ qgsnewhttpconnection.h \ qgsnumericsortlistviewitem.h \ qgsoptions.h \ @@ -294,6 +295,7 @@ libqgis_la_SOURCES = \ qgsmarkerdialog.cpp \ qgsmarkersymbol.cpp \ qgsmeasure.cpp \ + qgsmessageviewer.cpp \ qgsnewhttpconnection.cpp \ qgsnumericsortlistviewitem.cpp \ qgsoptions.cpp \ diff --git a/src/qgisapp.cpp b/src/qgisapp.cpp index 55d9bfd651c..815747d2b71 100644 --- a/src/qgisapp.cpp +++ b/src/qgisapp.cpp @@ -101,6 +101,7 @@ #include "qgsmaplayerregistry.h" #include "qgsmapoverviewcanvas.h" #include "qgsmapserverexport.h" +#include "qgsmessageviewer.h" #include "qgsoptions.h" #include "qgspastetransformations.h" #include "qgspluginitem.h" @@ -136,8 +137,6 @@ #include #include -//The next one needs to be sublassed! -//#include "qgsmessageviewer.ui" //#include "qgssisydialog.h" // XXX deprecated?? #include "qgslegenditem.h" @@ -450,17 +449,16 @@ void QgisApp::createActions() // // Settings Menu Related Items // - // FIXME - causes segfault when invoked mActionProjectProperties= new QAction(QIcon(iconPath+"/mActionProjectProperties.png"), tr("Project Properties"), this); mActionProjectProperties->setShortcut(tr("Alt+P")); mActionProjectProperties->setStatusTip(tr("Set project properties")); connect(mActionProjectProperties, SIGNAL(triggered()), this, SLOT(projectProperties())); - // FIXME - causes segfault when invoked + // mActionOptions= new QAction(QIcon(iconPath+"/mActionOptions.png"), tr("QGIS Options"), this); mActionOptions->setShortcut(tr("Alt+O")); mActionOptions->setStatusTip(tr("Change various QGIS options")); connect(mActionOptions, SIGNAL(triggered()), this, SLOT(options())); - // FIXME - causes segfault when invoked + // mActionCustomProjection= new QAction(QIcon(iconPath+"/mActionCustomProjection.png"), tr("Custom Projection"), this); mActionCustomProjection->setShortcut(tr("Alt+I")); mActionCustomProjection->setStatusTip(tr("Manage custom projections")); @@ -577,7 +575,7 @@ void QgisApp::createActions() connect(mActionInOverview, SIGNAL(triggered()), this, SLOT(inOverview())); // // Plugin Menu Related Items - // FIXME - segfalts when run... + // mActionShowPluginManager= new QAction(QIcon(iconPath+"/mActionShowPluginManager.png"), tr("Plugin Manager"), this); mActionShowPluginManager->setShortcut(tr("Ctrl+P")); mActionShowPluginManager->setStatusTip(tr("Open the plugin manager")); @@ -4440,12 +4438,11 @@ void QgisApp::socketConnectionClosed() int result = QMessageBox::information(this, tr("QGIS Version Information"), versionInfo, tr("Yes"), tr("No")); if (result == 0) { - //!NOTE Tim disabled for now (QT4 port) - this needs to be revisited // show more info - //QgsMessageViewer *mv = new QgsMessageViewer(this); - //mv->setCaption(tr("QGIS - Changes in CVS Since Last Release")); - //mv->setMessage(parts[2]); - //mv->exec(); + QgsMessageViewer *mv = new QgsMessageViewer(this); + mv->setCaption(tr("QGIS - Changes in CVS Since Last Release")); + mv->setMessage(parts[2]); + mv->exec(); } } else diff --git a/src/qgsmessageviewer.cpp b/src/qgsmessageviewer.cpp new file mode 100644 index 00000000000..8cc7f8489aa --- /dev/null +++ b/src/qgsmessageviewer.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + qgsmessageviewer.cpp - description + ------------------- + begin : Wed Jun 4 2003 + copyright : (C) 2002 by Gary E.Sherman + email : sherman at mrcc.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* $Id$ */ + +#include "qgsmessageviewer.h" + + +QgsMessageViewer::QgsMessageViewer(QWidget *parent, const char *name, bool modal, Qt::WFlags f) +: QDialog(parent, name, modal, f) +{ + setupUi(this); +} + +QgsMessageViewer::~QgsMessageViewer() +{ +} + +void QgsMessageViewer::setTextFormat(Qt::TextFormat f) +{ + txtMessage->setTextFormat(f); +} + +void QgsMessageViewer::setMessage(const QString& msg) +{ + txtMessage->setText(msg); +} + +void QgsMessageViewer::appendMessage(const QString& msg) +{ + txtMessage->append(msg); +} diff --git a/src/qgsmessageviewer.h b/src/qgsmessageviewer.h new file mode 100644 index 00000000000..b614b7de758 --- /dev/null +++ b/src/qgsmessageviewer.h @@ -0,0 +1,34 @@ +/*************************************************************************** + qgsmessageviewer.h - description + ------------------- + begin : Wed Jun 4 2003 + copyright : (C) 2002 by Gary E.Sherman + email : sherman at mrcc.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* $Id$ */ +#ifndef QGSMESSAGEVIEWER_H +#define QGSMESSAGEVIEWER_H + +#include "ui_qgsmessageviewer.h" +#include + +class QgsMessageViewer: public QDialog, private Ui::QgsMessageViewer +{ + public: + QgsMessageViewer(QWidget *parent, const char *name = 0, bool modal = false, Qt::WFlags f = 0); + ~QgsMessageViewer(); + void setTextFormat(Qt::TextFormat f); + void setMessage(const QString& msg); + void appendMessage(const QString& msg); +}; + +#endif diff --git a/src/qgsrunprocess.cpp b/src/qgsrunprocess.cpp index 9dfdf7004fb..da633b65599 100644 --- a/src/qgsrunprocess.cpp +++ b/src/qgsrunprocess.cpp @@ -21,11 +21,9 @@ #include "qgsrunprocess.h" -#include "ui_qgsmessageviewer.h" -#include -#include -#include -#include +#include "qgsmessageviewer.h" +#include +#include QgsRunProcess::QgsRunProcess(const QStringList& args, bool capture) : mProcess(NULL), mLogViewer(NULL) @@ -60,22 +58,17 @@ QgsRunProcess::QgsRunProcess(const QStringList& args, } else if (capture) { - // - // Temporarily disabled by Tim during qt4 ui porting FIXME!!! - // - /* // Create a dialog box to display the output. Use the // QgsMessageViewer dialog, but tweak its behaviour to suit our // needs. It will delete itself when the dialog box is closed. mLogViewer = new QgsMessageViewer(0, "", false, Qt::WDestructiveClose); - mLogViewer->txtMessage->setTextFormat(Qt::LogText); + mLogViewer->setTextFormat(Qt::LogText); mLogViewer->setCaption(whole_cmd); - mLogViewer->txtMessage->append( "" + tr("Starting") + " " + whole_cmd + "..." ); + mLogViewer->appendMessage( "" + tr("Starting") + " " + whole_cmd + "..." ); mLogViewer->show(); // Be told when the dialog box is closed (it gets destroyed when // closed because of the Qt flag used when it was created above). connect(mLogViewer, SIGNAL(destroyed()), this, SLOT(dialogGone())); - */ } else // We're not capturing the output from the process, so we don't @@ -101,9 +94,7 @@ void QgsRunProcess::stdoutAvailable() QString line; while ((line = mProcess->readLineStdout()) != QString::null) { - //Tim disabled log viewer during qt4 ui port - FIXME! - assert(1==0); - // mLogViewer->txtMessage->append(line); + mLogViewer->appendMessage(line); } } } @@ -114,14 +105,12 @@ void QgsRunProcess::stderrAvailable() if (mProcess->canReadLineStderr()) { QString line; - //mLogViewer->txtMessage->append(""); + mLogViewer->appendMessage(""); while ((line = mProcess->readLineStderr()) != QString::null) { - //Tim disabled log viewer during qt4 ui port - FIXME! - assert(1==0); - // mLogViewer->txtMessage->append(line); + mLogViewer->appendMessage(line); } - // mLogViewer->txtMessage->append(""); + mLogViewer->appendMessage(""); } } @@ -135,11 +124,9 @@ void QgsRunProcess::processExit() // test against 0 is for). if (mLogViewer != 0) - { - //Tim disabled log viewer during qt4 ui port - FIXME! - assert(1==0); - //mLogViewer->txtMessage->append( "" + tr("Done") + "" ); - } + { + mLogViewer->appendMessage( "" + tr("Done") + "" ); + } // Since the dialog box takes care of deleting itself, and the // process has gone, there's no need for this instance to stay diff --git a/src/ui/qgsmessageviewer.ui b/src/ui/qgsmessageviewer.ui index b2242040d36..6f82dcd1ed8 100644 --- a/src/ui/qgsmessageviewer.ui +++ b/src/ui/qgsmessageviewer.ui @@ -78,5 +78,22 @@ - + + + btnClose + clicked() + QgsMessageViewer + reject() + + + 249 + 256 + + + 249 + 141 + + + +