Bug 147838

Summary: Misleading behaviour of "Project | Clear Project"
Product: [Applications] k3b Reporter: trish
Component: generalAssignee: Sebastian Trueg <trueg>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:

Description trish 2007-07-13 11:55:35 UTC
Version:           0.12.17 (using KDE KDE 3.5.5)
Installed from:    Debian stable Packages
OS:                Linux

The "Project | Clear Project" action does not only delete the list of files but resets also the project's name to default. This behaviour is unexpected as people usually clear the project they're working on after having added wrong files and wish for a fresh restart on _this_ project (otherwise they would opt for the "New project" action). 

The "Volume Name" should not be cleared by this action. 
Please attach a "delete" button (the black one with the X marked arrow) to the "Volume Project" lineedit instead. Thank you!
Comment 1 Sebastian Trueg 2007-07-20 13:57:54 UTC
SVN commit 690220 by trueg:

"Clear project" now only removed the added data but leaves the settings of the project as they are.

BUG: 147838


 M  +1 -0      ChangeLog  
 M  +11 -0     libk3b/core/k3bglobals.cpp  
 M  +15 -10    libk3b/projects/audiocd/k3baudiodoc.cpp  
 M  +2 -0      libk3b/projects/audiocd/k3baudiodoc.h  
 M  +17 -13    libk3b/projects/datacd/k3bdatadoc.cpp  
 M  +2 -0      libk3b/projects/datacd/k3bdatadoc.h  
 M  +6 -0      libk3b/projects/k3bdoc.h  
 M  +7 -0      libk3b/projects/mixedcd/k3bmixeddoc.cpp  
 M  +1 -0      libk3b/projects/mixedcd/k3bmixeddoc.h  
 M  +11 -4     libk3b/projects/videocd/k3bvcddoc.cpp  
 M  +3 -0      libk3b/projects/videocd/k3bvcddoc.h  
 M  +1 -2      src/k3b.cpp  


--- branches/extragear/kde3/multimedia/k3b/ChangeLog #690219:690220
@@ -10,6 +10,7 @@
    (there is no need to do this if no mounting is involved.)
  * Allow importing of arbitrary sessions into a data project, thus continuing other than the
    last session.
+ * "Clear" project" now only clears the added data but leaves the settings as they were (bug 147838)
 
 1.0.1
 =====
--- branches/extragear/kde3/multimedia/k3b/libk3b/core/k3bglobals.cpp #690219:690220
@@ -642,6 +642,17 @@
     p.start( KProcess::Block );
     return !p.exitStatus();
   }
+
+  // and the most simple one
+  QString mountBin = K3b::findExe( "mount" );
+  if( !mountBin.isEmpty() ) {
+    KProcess p;
+    p << mountBin;
+    p << mntDev;
+    p.start( KProcess::Block );
+    return !p.exitStatus();
+  }
+
   return false;
 }
 
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/audiocd/k3baudiodoc.cpp #690219:690220
@@ -95,19 +95,24 @@
 
 bool K3bAudioDoc::newDocument()
 {
+    clear();
+    m_normalize = false;
+    m_hideFirstTrack = false;
+    m_cdText = false;
+    m_cdTextData.clear();
+    m_audioRippingParanoiaMode = 0;
+    m_audioRippingRetries = 5;
+    m_audioRippingIgnoreReadErrors = true;
+
+    return K3bDoc::newDocument();
+}
+
+
+void K3bAudioDoc::clear()
+{
   // delete all tracks
   while( m_firstTrack )
     delete m_firstTrack->take();
-
-  m_normalize = false;
-  m_hideFirstTrack = false;
-  m_cdText = false;
-  m_cdTextData.clear();
-  m_audioRippingParanoiaMode = 0;
-  m_audioRippingRetries = 5;
-  m_audioRippingIgnoreReadErrors = true;
-
-  return K3bDoc::newDocument();
 }
 
 
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/audiocd/k3baudiodoc.h #690219:690220
@@ -63,6 +63,8 @@
 	
   bool newDocument();
 
+  void clear();
+
   int supportedMediaTypes() const;
 
   bool hideFirstTrack() const { return m_hideFirstTrack; }
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/datacd/k3bdatadoc.cpp #690219:690220
@@ -86,22 +86,12 @@
 
 bool K3bDataDoc::newDocument()
 {
-  clearImportedSession();
+  clear();
+  if ( !m_root )
+      m_root = new K3bRootItem( this );
 
-  m_bootCataloge = 0;
-  m_oldSessionSize = 0;
   m_bExistingItemsReplaceAll = m_bExistingItemsIgnoreAll = false;
-  m_importedSession = -1;
 
-  if( m_root ) {
-    while( m_root->children().getFirst() )
-      removeItem( m_root->children().getFirst() );
-  }
-  else
-    m_root = new K3bRootItem( this );
-
-  m_sizeHandler->clear();
-
   m_multisessionMode = AUTO;
   m_dataMode = K3b::DATA_MODE_AUTO;
 
@@ -111,6 +101,20 @@
 }
 
 
+void K3bDataDoc::clear()
+{
+  clearImportedSession();
+  m_importedSession = -1;
+  m_oldSessionSize = 0;
+  m_bootCataloge = 0;
+  if( m_root ) {
+    while( m_root->children().getFirst() )
+      removeItem( m_root->children().getFirst() );
+  }
+  m_sizeHandler->clear();
+}
+
+
 QString K3bDataDoc::name() const
 {
   return m_isoOptions.volumeID();
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/datacd/k3bdatadoc.h #690219:690220
@@ -95,6 +95,8 @@
   K3bRootItem* root() const { return m_root; }
 
   virtual bool newDocument();
+  virtual void clear();
+
   virtual KIO::filesize_t size() const;
 
   /**
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/k3bdoc.h #690219:690220
@@ -114,10 +114,16 @@
   /**
    * Subclasses should call this when reimplementing.
    * Sets some defaults.
+   * FIXME: this method is completely useless. Just do it all in the constructor
    */
   virtual bool newDocument();
 
   /**
+   * Clear project, i.e. remove all data that has ben added
+   */
+  virtual void clear() = 0;
+
+  /**
    * Load a project from an xml stream.
    *
    * This is used to load/save k3b projects. 
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/mixedcd/k3bmixeddoc.cpp #690219:690220
@@ -58,6 +58,13 @@
 }
 
 
+void K3bMixedDoc::clear()
+{
+    m_dataDoc->clear();
+    m_audioDoc->clear();
+}
+
+
 QString K3bMixedDoc::name() const
 {
   return m_dataDoc->name();
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/mixedcd/k3bmixeddoc.h #690219:690220
@@ -43,6 +43,7 @@
   int supportedMediaTypes() const;
 
   bool newDocument();
+  void clear();
 
   void setModified( bool m = true );
   bool isModified() const;
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/videocd/k3bvcddoc.cpp #690219:690220
@@ -2,6 +2,7 @@
 *
 * $Id$
 * Copyright (C) 2003-2005 Christian Kvasny <chris@k3b.org>
+* Copyright (C) 2007 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
@@ -78,10 +79,8 @@
 
 bool K3bVcdDoc::newDocument()
 {
-    if ( m_tracks )
-        while ( m_tracks->first() )
-            removeTrack( m_tracks->first() );
-    else
+    clear();
+    if ( !m_tracks )
         m_tracks = new QPtrList<K3bVcdTrack>;
     m_tracks->setAutoDelete( false );
 
@@ -89,6 +88,14 @@
 }
 
 
+void K3bVcdDoc::clear()
+{
+    if ( m_tracks )
+        while ( m_tracks->first() )
+            removeTrack( m_tracks->first() );
+}
+
+
 QString K3bVcdDoc::name() const
 {
   return m_vcdOptions->volumeId();
--- branches/extragear/kde3/multimedia/k3b/libk3b/projects/videocd/k3bvcddoc.h #690219:690220
@@ -2,6 +2,7 @@
 *
 * $Id$
 * Copyright (C) 2003-2004 Christian Kvasny <chris@k3b.org>
+* Copyright (C) 2007 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
@@ -62,6 +63,8 @@
         enum vcdTypes { VCD11, VCD20, SVCD10, HQVCD, NONE};
 
         bool newDocument();
+	void clear();
+
         int numOfTracks() const
         {
             return m_tracks->count();
--- branches/extragear/kde3/multimedia/k3b/src/k3b.cpp #690219:690220
@@ -1456,8 +1456,7 @@
 				    i18n("Clear Project"),
 				    i18n("Clear"),
 				    "clear_current_project_dontAskAgain" ) == KMessageBox::Continue ) {
-      doc->newDocument();
-      k3bappcore->projectManager()->loadDefaults( doc );
+      doc->clear();
     }
   }
 }