[rkward-cvs] rkward/rkward/misc rkerrordialog.cpp,1.3,1.4 rkerrordialog.h,1.2,1.3
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Wed Apr 5 10:11:56 UTC 2006
Update of /cvsroot/rkward/rkward/rkward/misc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3278
Modified Files:
rkerrordialog.cpp rkerrordialog.h
Log Message:
Show R errors generated by plugins
Index: rkerrordialog.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/misc/rkerrordialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** rkerrordialog.h 18 Oct 2005 15:54:04 -0000 1.2
--- rkerrordialog.h 5 Apr 2006 10:11:54 -0000 1.3
***************
*** 33,39 ****
Q_OBJECT
public:
! RKErrorDialog (const QString &text, const QString &caption, bool modal=false);
! ~RKErrorDialog ();
void newError (const QString &error);
--- 33,39 ----
Q_OBJECT
public:
! RKErrorDialog (const QString &text, const QString &caption, bool modal=false);
! virtual ~RKErrorDialog ();
void newError (const QString &error);
***************
*** 59,61 ****
--- 59,76 ----
};
+ #include "../rbackend/rcommandreceiver.h"
+ /** A subclass of RKErrorDialog, that has special helper functions to deal with RCommands. It can be set as the receiver of RCommands, or can be fed RCommands, and will extract any errors associated with those commands. If you use the RKRErrorDialog as a command receiver, be sure to always call deleteThis () instead of delete, so pending commands don't go to a destroyed object. */
+ class RKRErrorDialog : public RKErrorDialog, public RCommandReceiver {
+ public:
+ /** constructor. See RKErrorDialog::RKErrorDialog () for details */
+ RKRErrorDialog (const QString &text, const QString &caption, bool modal=false);
+ /** constructor. See RKErrorDialog::~RKErrorDialog () for details */
+ ~RKRErrorDialog ();
+
+ /** Use this mechanism to feed RCommands to the RKRErrorDialog manually. The alternative is to simply specify the error-dialog as the receiver of your RCommands (but then you'll never see tehm first). Errors contained in the command will be extracted. */
+ void addRCommand (RCommand *command);
+ protected:
+ void rCommandDone (RCommand *command);
+ };
+
#endif
Index: rkerrordialog.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/misc/rkerrordialog.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rkerrordialog.cpp 18 Oct 2005 15:54:04 -0000 1.3
--- rkerrordialog.cpp 5 Apr 2006 10:11:54 -0000 1.4
***************
*** 21,26 ****
--- 21,31 ----
#include <qlayout.h>
#include <qlabel.h>
+ #include <klocale.h>
+
+ #include "../debug.h"
RKErrorDialog::RKErrorDialog (const QString &text, const QString &caption, bool modal) : QObject () {
+ RK_TRACE (MISC);
+
RKErrorDialog::text = text;
RKErrorDialog::caption = caption;
***************
*** 30,33 ****
--- 35,40 ----
RKErrorDialog::~RKErrorDialog () {
+ RK_TRACE (MISC);
+
// dialog deletes itself via Qt::WDestructiveClose!
//delete dialog;
***************
*** 35,38 ****
--- 42,47 ----
void RKErrorDialog::newError (const QString &error) {
+ RK_TRACE (MISC);
+
if (!dialog) createDialog ();
error_log->append (error);
***************
*** 40,43 ****
--- 49,53 ----
void RKErrorDialog::newOutput (const QString &output) {
+ RK_TRACE (MISC);
if (dialog) {
error_log->append (output);
***************
*** 48,59 ****
--- 58,73 ----
void RKErrorDialog::resetOutput () {
+ RK_TRACE (MISC);
stored_output = QString::null;
}
void RKErrorDialog::dialogDestroyed () {
+ RK_TRACE (MISC);
dialog = 0;
}
void RKErrorDialog::createDialog () {
+ RK_TRACE (MISC);
+
dialog = new QDialog (0, 0, show_modal, Qt::WDestructiveClose);
dialog->setCaption (caption);
***************
*** 76,78 ****
--- 90,128 ----
}
+ ////////////////////////////////////// RKRErrorDialog /////////////////////////////////////
+
+ #include "../rbackend/rcommand.h"
+
+ RKRErrorDialog::RKRErrorDialog (const QString &text, const QString &caption, bool modal) : RKErrorDialog (text, caption, modal) {
+ RK_TRACE (MISC);
+ }
+
+ RKRErrorDialog::~RKRErrorDialog () {
+ RK_TRACE (MISC);
+ }
+
+ void RKRErrorDialog::addRCommand (RCommand *command) {
+ RK_TRACE (MISC);
+
+ if (command->hasOutput ()) {
+ RKErrorDialog::newOutput (command->output ());
+ }
+
+ if (command->hasError ()) {
+ newError (command->error ());
+ }
+
+ if (command->errorSyntax ()) {
+ newError (i18n ("Syntax error"));
+ } else if (command->errorIncomplete ()) {
+ newError (i18n ("command incomplete"));
+ }
+ }
+
+ void RKRErrorDialog::rCommandDone (RCommand *command) {
+ RK_TRACE (MISC);
+
+ addRCommand (command);
+ }
+
#include "rkerrordialog.moc"
More information about the rkward-tracker
mailing list