Re: bugfix for KBabel
Jens Herden <jens-W20+MoKGEJdEHWO/[email protected]> Wed, 31 Aug 2005 15:35:14 +0700
| Newsgroups | gmane.comp.kde.devel.kbabel |
|---|---|
| Message-ID | <[email protected]> |
> > here is a patch for http://bugs.kde.org/show_bug.cgi?id=110981 and > > another bug I found during test: > > if a po file is changed in memory but not saved yet the syntax check > > fails because the created temp file got a wrong filename that prevents > > the mime detection from selecting the correct plugin. > > The problem is that the file might not be PO - KBabel supports Qt Linguist > files and also XLIFF to some extent. I see, here is the next try. This should work independent of the file type. Jens _______________________________________________ kbabel mailing list [email protected] https://mail.kde.org/mailman/listinfo/kbabel
catalog.diff
(text/x-diff, 2.6 KB)
Index: kbabel/common/catalog.h
===================================================================
--- kbabel/common/catalog.h (revision 451647)
+++ kbabel/common/catalog.h (working copy)
@@ -604,7 +604,7 @@
void processCommand(EditCommand* cmd, CatalogView* view2exclude=0, bool undo=false);
/** do the actual file write using plugin */
- ConversionStatus writeFile(QString localfile, bool overwrite=false);
+ ConversionStatus writeFile(QString localfile, KURL url, bool overwrite=false);
/**
* generates lists that contain indexes of all fuzzy and untranslated entries
Index: kbabel/common/catalog.cpp
===================================================================
--- kbabel/common/catalog.cpp (revision 451647)
+++ kbabel/common/catalog.cpp (working copy)
@@ -52,6 +52,7 @@
#include <kio/netaccess.h>
#include <krfcdate.h>
#include <ktrader.h>
+#include <ktempfile.h>
#include <kurl.h>
#include "kbprojectmanager.h"
@@ -1852,19 +1853,17 @@
if(status==OK)
{
- status=writeFile(targetURL.path(0),overwrite);
+ status=writeFile(targetURL.path(0), targetURL, overwrite);
}
}
else
{
QString tempFile=kapp->tempSaveName(targetURL.path(0));
+ status = writeFile(tempFile, targetURL, overwrite);
- status = writeFile(tempFile,overwrite);
-
if(status == OK)
{
- KURL temp(tempFile);
- if( !KIO::NetAccess::upload( temp.url(), targetURL, NULL ) )
+ if( !KIO::NetAccess::upload( tempFile, targetURL, NULL ) )
{
status = OS_ERROR;
}
@@ -1893,8 +1892,11 @@
QString Catalog::saveTempFile()
{
- QString filename = kapp->tempSaveName("/temp/kbabel_temp.po");
- if( writeFile(filename) != OK )
+ KTempFile tempFile(QString::null, d->_url.fileName());
+ QString filename = tempFile.name();
+ tempFile.close();
+ tempFile.unlink();
+ if( writeFile(filename, KURL::fromPathOrURL( filename )) != OK )
{
filename = QString::null;
}
@@ -1903,7 +1905,7 @@
}
-ConversionStatus Catalog::writeFile(QString localFile , bool overwrite)
+ConversionStatus Catalog::writeFile(QString localFile, KURL url, bool overwrite)
{
QFileInfo info(localFile);
@@ -1930,7 +1932,7 @@
CatalogExportPlugin* filter=0;
// gimme plugin for this MIME type
- KMimeType::Ptr mime = KMimeType::findByURL( KURL::fromPathOrURL( localFile ) );
+ KMimeType::Ptr mime = KMimeType::findByURL(url);
KTrader::OfferList offers = KTrader::self()->query("KBabelFilter", "('"+mime->name()+"' in [X-KDE-Export])");
KService::Ptr ptr = offers.first();
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQBDFWvMkYmIVB8IV+ARAtyoAKC4y2Brz0bprI/GOK8U9eLOBOluoACgtS5k Z793OZ3fbjg3vVrhnx2sKxs= =ly8R -----END PGP SIGNATURE-----