Bug 89498

Summary: If n vectors are not found, kst should only display one error dialog, not n error dialogs
Product: [Applications] kst Reporter: Matthew Truch <matt>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Matthew Truch 2004-09-14 17:06:25 UTC
Version:           1.0.0_devel (using KDE KDE 3.2.2)
Installed from:    RedHat RPMs
OS:                Linux

If you open a .kst file that contains references to invalid vector names, kst pops up an error dialog for each invalid vector, which can be alot of error dialogs.  It would be much nicer if kst only poped up one error dialog listing all incorrect vectors, so one wouldn't have to click the ok button so many times in this case.
Comment 1 Andrew Walker 2004-09-14 18:21:04 UTC
The message I receive (just once) when invalid vector names are used is the following:

"The Kst file could not be loaded in its entirety due to missing objects or data."

Could you give the message that you see, as presumably its not what I am seeing.
Comment 2 Matthew Truch 2004-09-14 18:35:30 UTC
> ------- Additional Comments From arwalker sumusltd com  2004-09-14 18:21 -------
> The message I receive (just once) when invalid vector names are used is the following:
> 
> "The Kst file could not be loaded in its entirety due to missing objects or data."
> 
> Could you give the message that you see, as presumably its not what I am seeing.

Sorry, I didn't give decent steps to reproduce:

Make a .kst file that has some vectors which exist, and some that don't.
You can do this by editing the kst file by hand (if you don' want to
modify your datasource to have different named vectors).  Start kst with
that .kst file.  At this point kst will not complain about the bad
vectors (and probably should, but that's another bug report); it will
just display them as zero.  Now change the data file for all your
vectors to another valid data file.  kst will complain about each
invalid vector with an individual error dialog.  

Comment 3 Andrew Walker 2004-09-14 20:03:06 UTC
CVS commit by arwalker: 

Display only a single error message for all the invalid vector sources.

CCMAIL: 89498-done@bugs.kde.org


  M +16 -3     kstchangefiledialog_i.cpp   1.22


--- kdeextragear-2/kst/kst/kstchangefiledialog_i.cpp  #1.21:1.22
@@ -71,6 +71,7 @@ void KstChangeFileDialogI::applyFileChan
   KstDataSourcePtr file;
   KstWriteLocker ml(&KST::dataSourceList.lock());
-
   KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(_dataFile->url());
+  QString invalidSources;
+  int invalid = 0;
 
   if (it == KST::dataSourceList.end()) {
@@ -97,5 +98,9 @@ void KstChangeFileDialogI::applyFileChan
       vector->writeLock();
       if (!file->isValidField(vector->field())) {
-        KMessageBox::sorry(this, i18n("%1: Field is not defined for the requested file.").arg(vector->field()));
+        if (invalid > 0) {
+          invalidSources += ", ";
+        }
+        invalidSources += vector->field();
+        invalid++;
       } else {
         vector->changeFile(file);
@@ -105,4 +110,12 @@ void KstChangeFileDialogI::applyFileChan
   }
 
+  if (!invalidSources.isEmpty()) {
+    if (invalid == 1) {
+      KMessageBox::sorry(this, i18n("The following field is not defined for the requested file:\n%1").arg(invalidSources));
+    } else {
+      KMessageBox::sorry(this, i18n("The following fields are not defined for the requested file:\n%1").arg(invalidSources));
+    }
+  }
+  
   file->writeUnlock();
   file = 0L;