patch for preview of read-only files
Jens Herden <[email protected]>
| Newsgroups | gmane.comp.kde.devel.quanta |
|---|---|
| Organization | http://www.kdewebdev.org |
| Message-ID | <[email protected]> |
Hi Andras, here another patch for the problem we discussed already: the preview if a file is read-only. I simply open the original if the copy fails to create the preview-* file. No elegant but works. I also removed some useless lines. Please review and if it is OK please commit. Because I do not know if I will have time during the next days and I want this in the next release. Thanks Jens _______________________________________________ quanta-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/quanta-devel
preview.patch
(text/x-diff, 2.6 KB)
Index: quanta/src/quanta.cpp
===================================================================
--- quanta/src/quanta.cpp (revision 518528)
+++ quanta/src/quanta.cpp (working copy)
@@ -750,7 +750,7 @@
else
{
url = Project::ref()->urlWithPrefix(w->url());
- m_htmlPart->setPreviewedURL(url, noFramesText);
+ m_htmlPart->setPreviewedURL(url);
m_htmlPart->begin(url, xOffset, yOffset);
}
m_htmlPart->write(noFramesText);
@@ -775,7 +775,7 @@
{
m_previewedDocument = w;
url = Project::ref()->urlWithPrefix(w->url());
- m_htmlPart->setPreviewedURL(url, text);
+ m_htmlPart->setPreviewedURL(url);
KURL previewURL = w->url();
previewURL.setFileName("preview-" + previewURL.fileName());
//save the content to disk, so preview with prefix works
@@ -791,7 +791,9 @@
tmpFile->textStream()->setCodec(QTextCodec::codecForName(encoding));
*(tmpFile->textStream()) << w->editIf->text();
tmpFile->close();
- QExtFileInfo::copy(KURL::fromPathOrURL(tempFileName), previewURL, -1, true);
+ if (!QExtFileInfo::copy(KURL::fromPathOrURL(tempFileName), previewURL, -1, true)) {
+ m_htmlPart->setPreviewedURL(KURL()); // copy failed, force the preview of the original
+ };
delete tmpFile;
m_htmlPart->openURL(url);
m_htmlPart->addToHistory(url.url());
Index: quanta/parts/preview/whtmlpart.cpp
===================================================================
--- quanta/parts/preview/whtmlpart.cpp (revision 518528)
+++ quanta/parts/preview/whtmlpart.cpp (working copy)
@@ -68,9 +68,8 @@
{
}
-void WHTMLPart::setPreviewedURL(const KURL &url, const QString& text)
+void WHTMLPart::setPreviewedURL(const KURL &url)
{
- m_previewedText = text;
m_previewedURL = url;
}
Index: quanta/parts/preview/whtmlpart.h
===================================================================
--- quanta/parts/preview/whtmlpart.h (revision 518528)
+++ quanta/parts/preview/whtmlpart.h (working copy)
@@ -34,9 +34,8 @@
QObject *parent = 0, const char *name = 0, GUIProfile prof = DefaultGUI );
virtual ~WHTMLPart();
- /** Specify the URL where the preview was started and the
- content of this url as well.*/
- void setPreviewedURL(const KURL &url, const QString &text);
+ /** Specify the URL where the preview was started */
+ void setPreviewedURL(const KURL &url);
bool backEnable();
bool forwardEnable();
virtual bool openURL(const KURL &url);
@@ -69,7 +68,6 @@
private:
KURL m_previewedURL;
KPopupMenu *m_contextMenu;
- QString m_previewedText;
QStrList history;
unsigned int hpos;
bool m_enableViewSource;
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBEFtQ3kYmIVB8IV+ARAsHTAKCiMQen40tVm/da2CeQ/XAJapk3xgCfUbuK GyjyrUh/SX9v3xAjdYUi68o= =g3h6 -----END PGP SIGNATURE-----