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

List:       kde-commits
Subject:    kdelibs/khtml
From:       David Faure <faure () kde ! org>
Date:       2005-04-04 17:35:06
Message-ID: 20050404173506.A642463E () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Use .html, .xml or .xhtml as extension depending on the type of document,
for "View Source" actions and "Save" actions (when no filename exists).
BUG: 40496


  M +15 -4     khtml_part.cpp   1.1097
  M +3 -0      khtml_part.h   1.281


--- kdelibs/khtml/khtml_part.cpp  #1.1096:1.1097
@@ -3793,5 +3793,5 @@ void KHTMLPart::slotViewDocumentSource()
   if (!(url.isLocalFile()) && KHTMLPageCache::self()->isComplete(d->m_cacheId))
   {
-     KTempFile sourceFile(QString::null, QString::fromLatin1(".html"));
+     KTempFile sourceFile(QString::null, defaultExtension());
      if (sourceFile.status() == 0)
      {
@@ -3873,5 +3873,5 @@ void KHTMLPart::slotViewFrameSource()
        if (KHTMLPageCache::self()->isComplete(cacheId))
        {
-           KTempFile sourceFile(QString::null, QString::fromLatin1(".html"));
+           KTempFile sourceFile(QString::null, defaultExtension());
            if (sourceFile.status() == 0)
            {
@@ -3910,5 +3910,5 @@ void KHTMLPart::slotSaveDocument()
 
   if ( srcURL.fileName(false).isEmpty() )
-    srcURL.setFileName( "index.html" );
+    srcURL.setFileName( "index" + defaultExtension() );
 
   KIO::MetaData metaData;
@@ -3985,5 +3985,5 @@ void KHTMLPart::slotSaveFrame()
 
     if ( srcURL.fileName(false).isEmpty() )
-        srcURL.setFileName( "index.html" );
+        srcURL.setFileName( "index" + defaultExtension() );
 
     KIO::MetaData metaData;
@@ -7089,4 +7089,15 @@ void KHTMLPart::setSuppressedPopupIndica
 }
 
+// Extension to use for "view document source", "save as" etc.
+// Using the right extension can help the viewer get into the right mode (#40496)
+QString KHTMLPart::defaultExtension() const
+{
+    if ( !d->m_doc )
+        return ".html";
+    if ( !d->m_doc->isHTMLDocument() )
+        return ".xml";
+    return d->m_doc->htmlMode() == DOM::DocumentImpl::XHtml ? ".xhtml" : ".html";
+}
+
 using namespace KParts;
 #include "khtml_part.moc"

--- kdelibs/khtml/khtml_part.h  #1.280:1.281
@@ -1599,4 +1599,7 @@ private:
   QString defaultEncoding() const;
 
+  /** .html, .xhtml or .xml */
+  QString defaultExtension() const;
+
   /** @internal
    * generic zoom in


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

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