Bug 93314

Summary: Display Document Name of Filename as a caption in the main window
Product: [Unmaintained] kvoctrain Reporter: Marc Heyvaert <marc_heyvaert>
Component: generalAssignee: Peter Hedlund <peter>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marc Heyvaert 2004-11-15 15:19:05 UTC
Version:           0.8.1 (using KDE KDE 3.2.1)
Installed from:    SuSE RPMs
OS:                Linux

Currently the caption in the main window contains the 'document title' followed by KVoctrain, the application name. If the document was not explicitely named, the caption contains 'untitled'.

I think it would be a good solution to display the 'document title' if there is one or the file name if the 'document title' was not defined. 'Untitled' should be reserved for new files that were no saved yet.

Marc
Comment 1 Peter Hedlund 2004-11-17 23:08:42 UTC
CVS commit by hedlund: 

Use the filename as window caption if no document title has been specified.
BUG:93314


  M +2 -4      kva_io.cpp   1.45
  M +2 -4      kvt-core/kvd_rh_kvtml.cpp   1.16
  M +11 -10    kvt-core/kvoctraindoc.cpp   1.32


--- kdeedu/kvoctrain/kvoctrain/kvt-core/kvd_rh_kvtml.cpp  #1.15:1.16
@@ -1,6 +1,4 @@
 /***************************************************************************
 
-    $Id$
-
                    read header parts of a kvtml document
 
@@ -69,5 +67,5 @@ bool kvoctrainDoc::loadFromKvtMl (QTextS
 
   list<XmlAttribute>::const_iterator first =  elem.attributes ().begin ();
-  doctitle = i18n("untitled");
+  doctitle = i18n("Untitled");
   while (first != elem.attributes ().end ()) {
 

--- kdeedu/kvoctrain/kvoctrain/kvt-core/kvoctraindoc.cpp  #1.31:1.32
@@ -1,5 +1,4 @@
 /***************************************************************************
 
-    $Id$
 
                    maintain a kvoctrain document
@@ -86,5 +85,5 @@ void kvoctrainDoc::Init ()
   queryorg = "";
   querytrans = "";
-  doc_url.setFileName("");
+  doc_url.setFileName(i18n("Untitled"));
   doctitle = "";
   author = "";
@@ -95,4 +94,5 @@ kvoctrainDoc::kvoctrainDoc(QObject *pare
 {
   Init();
+  if (!url.isEmpty())
   doc_url = url;
 
@@ -106,5 +106,4 @@ kvoctrainDoc::kvoctrainDoc(QObject *pare
     {
       KMessageBox::error(0, i18n("<qt>Cannot open file<br><b>%1</b></qt>").arg(url.path()));
-      doc_url.setFileName("unknown.kvtml");
       return;
     }
@@ -187,9 +186,8 @@ bool kvoctrainDoc::saveAs (QObject *pare
 
   KURL tmp (url);
-  if (tmp.isEmpty())
-    tmp = doc_url;
-
-  if (tmp.isEmpty())
-    tmp.setFileName("unknown.kvtml");
+  if (title == i18n("Untitled"))
+    title = QString::null;
+  if (title == doc_url.fileName())
+    title = QString::null;
 
   if (ft == automatic) 
@@ -776,4 +774,7 @@ void kvoctrainDoc::setLessonsInQuery(vec
 QString kvoctrainDoc::getTitle() const
 {
+  if (doctitle.isEmpty())
+    return doc_url.fileName();
+  else
   return doctitle;
 }

--- kdeedu/kvoctrain/kvoctrain/kva_io.cpp  #1.44:1.45
@@ -1,6 +1,4 @@
 /***************************************************************************
 
-    $Id$
-
                          i/o part of kvoctrain
 
@@ -188,5 +186,5 @@ void kvoctrainApp::slotFileNew()
     delete doc;
     QString name = "";
-    doc = new kvoctrainDoc (this, KURL(name), separator, &paste_order);
+    doc = new kvoctrainDoc (this, 0 /*KURL(name)*/, separator, &paste_order);
     loadDocProps(doc);
     if (doc->numLangs() == 0) {
@@ -513,5 +511,5 @@ void kvoctrainApp::slotFileSave()
     commitEntryDlg(false);
 
-  if (doc->URL().isEmpty() ) {
+  if (doc->URL().fileName() == i18n("Untitled") ) {
     slotFileSaveAs();
     return;