[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Add errorList() and errorListWId() to KMessageBox
From:       Michael Pyne <pynm0001 () comcast ! net>
Date:       2004-10-02 2:10:05
Message-ID: 200410012210.05176.pynm0001 () comcast ! net
[Download RAW message or body]

Hi all,

Attached is a patch to kdelibs/kdeui/kmessagebox.{h,cpp} that adds support for 
the errorList() and errorListWId() convienience functions to KMessageBox.  I 
would like this support for JuK, as there are a few code paths that process a 
bunch of files sequentially, and each file may have an error.

This is currently handled by either reporting the errors in separate message 
boxes (which is what I'm fixing right now, imagine 50 error message boxes in 
a row!), coercing a QStringList into a QString joined by newlines (this can 
make the end dialog needlessly tall), or by using a different dialog that 
does provide a list (which loses the "Error" property).

The functions are all static, so there should be no problem with binary 
compatibility.

Please let me know if it is alright for me to commit this.

Regards,
 - Michael Pyne

["kmessagebox-error-list.patch" (text/x-diff)]

Index: kmessagebox.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmessagebox.h,v
retrieving revision 1.61
diff -u -3 -p -r1.61 kmessagebox.h
--- kmessagebox.h	8 Sep 2004 19:30:57 -0000	1.61
+++ kmessagebox.h	2 Oct 2004 01:59:19 -0000
@@ -612,6 +612,52 @@ public:
                     int options = Notify);
 
  /**
+  * Display an "Error" dialog with a listbox.
+  *
+  * @param parent  If @p parent is 0, then the message box becomes an
+  *                application-global modal dialog box. If @p parent is a
+  *                widget, the message box becomes modal relative to parent.
+  * @param text    Message string.
+  * @param strlist List of strings to be written in the listbox. If the
+  *                list is empty, it doesn't show any listbox, working
+  *                as error().
+  * @param caption Message box title. The application name is added to
+  *                the title. The default title is i18n("Error").
+  * @param options  see OptionsType
+  *
+  * Your program messed up and now it's time to inform the user.
+  * To be used for important things like "Sorry, I deleted your hard disk."
+  *
+  * If your program detects the action specified by the user is somehow
+  * not allowed, this should never be reported with error(). Use sorry()
+  * instead to explain to the user that this action is not allowed.
+  *
+  * The default button is "&OK". Pressing "Esc" selects the OK-button.
+  *
+  * NOTE: The OK button will always have the i18n'ed text '&OK'.
+  *
+  * @since 3.4
+  */
+
+  static void errorList(QWidget *parent,
+                    const QString &text,
+                    const QStringList &strlist,
+                    const QString &caption = QString::null,
+                    int options = Notify);
+
+ /**
+  * This function accepts the window id of the parent window, instead
+  * of QWidget*. It should be used only when necessary.
+  *
+  * @since 3.4
+  */
+
+  static void errorListWId(WId parent_id,
+                    const QString &text,
+                    const QStringList &strlist,
+                    const QString &caption = QString::null,
+                    int options = Notify);
+
+ /**
   * Displays an "Error" dialog with a "Details >>" button.
   *
   * @param parent  If @p parent is 0, then the message box becomes an
Index: kmessagebox.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmessagebox.cpp,v
retrieving revision 1.97
diff -u -3 -p -r1.97 kmessagebox.cpp
--- kmessagebox.cpp	7 Sep 2004 12:29:50 -0000	1.97
+++ kmessagebox.cpp	2 Oct 2004 01:59:19 -0000
@@ -731,11 +731,25 @@ void
 KMessageBox::error(QWidget *parent,  const QString &text,
                    const QString &caption, int options)
 {
-    return errorWId( parent ? parent->winId() : 0, text, caption, options );
+    return errorListWId( parent ? parent->winId() : 0, text, QStringList(), caption, options );
 }
 
 void
-KMessageBox::errorWId(WId parent_id,  const QString &text,
+KMessageBox::errorWId(WId parent_id, const QString &text,
+                      const QString &caption, int options)
+{
+    errorListWId( parent_id, text, QStringList(), caption, options );
+}
+
+void
+KMessageBox::errorList(QWidget *parent, const QString &text, const QStringList &strlist,
+                       const QString &caption, int options)
+{
+    return errorListWId( parent ? parent->winId() : 0, text, strlist, caption, options );
+}
+
+void
+KMessageBox::errorListWId(WId parent_id,  const QString &text, const QStringList &strlist,
                    const QString &caption, int options)
 {
     QWidget* parent = QWidget::find( parent_id );
@@ -752,7 +766,7 @@ KMessageBox::errorWId(WId parent_id,  co
         XSetTransientForHint( qt_xdisplay(), dialog->winId(), parent_id );
 #endif
 
-    createKMessageBox(dialog, QMessageBox::Critical, text, QStringList(), QString::null, 0, options);
+    createKMessageBox(dialog, QMessageBox::Critical, text, strlist, QString::null, 0, options);
 }
 
 void


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic