[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/lib/kofficecore
From: David Faure <faure () kde ! org>
Date: 2004-08-24 10:46:12
Message-ID: 20040824104612.A12D7905C () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Improvements for the "automatically create file given on command line if it doesn't \
exist" feature: update caption, correctly set output mimetype so that no file dialog \
appears when saving.
CCMAIL: Fredrik Edemar <f_edemar@linux.se>
M +12 -7 koDocument.cc 1.325
M +7 -2 koDocument.h 1.167
M +9 -7 koMainWindow.cc 1.334
--- koffice/lib/kofficecore/koDocument.cc #1.324:1.325
@@ -1539,14 +1539,19 @@ bool KoDocument::openFile()
if ( ok )
{
- d->mimeType = typeName.latin1 ();
+ setMimeTypeAfterLoading( typeName );
+ }
+ return ok;
+}
+
+// shared between openFile and komainwindow's "create new empty document" code
+void KoDocument::setMimeTypeAfterLoading( const QString& mimeType )
+{
+ d->mimeType = mimeType.latin1();
d->outputMimeType = d->mimeType;
const bool needConfirm = !isNativeFormat( d->mimeType );
- setConfirmNonNativeSave ( false, needConfirm );
- setConfirmNonNativeSave ( true, needConfirm );
- }
-
- return ok;
+ setConfirmNonNativeSave( false, needConfirm );
+ setConfirmNonNativeSave( true, needConfirm );
}
--- koffice/lib/kofficecore/koDocument.h #1.166:1.167
@@ -738,4 +738,9 @@ public:
void setFile( const QString &file ) { m_file = file; }
+ /**
+ * @internal (public for KoMainWindow)
+ */
+ void setMimeTypeAfterLoading( const QString& mimeType );
+
signals:
/**
--- koffice/lib/kofficecore/koMainWindow.cc #1.333:1.334
@@ -593,7 +593,9 @@ bool KoMainWindow::openDocument( KoDocum
setRootDocument( newdoc );
newdoc->setURL(url);
- QString const mime = KMimeType::findByURL(url)->name();
- if ( mime != KMimeType::defaultMimeType() )
- newdoc->setMimeType( mime.utf8() );
+ QString mime = KMimeType::findByURL(url)->name();
+ if ( mime.isEmpty() || mime == KMimeType::defaultMimeType() )
+ mime = newdoc->nativeFormatMimeType();
+ newdoc->setMimeTypeAfterLoading( mime );
+ updateCaption();
return true;
}
@@ -741,5 +743,5 @@ bool KoMainWindow::saveDocument( bool sa
bool reset_url;
- if (pDoc->url().isEmpty() )
+ if ( pDoc->url().isEmpty() )
{
emit saveDialogShown(false);
@@ -765,5 +767,5 @@ bool KoMainWindow::saveDocument( bool sa
if (mimeFilter.findIndex (oldOutputFormat) < 0 && !isExporting())
{
- kdDebug(30003) << "KoMainWindow::saveDocument no export filter for " << \
oldOutputFormat << endl; + kdDebug(30003) << "KoMainWindow::saveDocument no \
export filter for '" << oldOutputFormat << "'" << endl;
// --- don't setOutputMimeType in case the user cancels the Save As
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic