|
发表于 2004-4-23 18:00:03
|
显示全部楼层
你做的这个补丁有点小毛病:无法正确处理chm文件名是中文的情况
我改了一下,主要就是那个“(const char *)(url.path().local8Bit())”,我也想不出来好看一点的写法了,还请大虾指正:
[PHP]
--- kdevelop.old/parts/doctreeview/chm/chm.cpp 2004-04-23 17:45:30.000000000 +0800
+++ kdevelop/parts/doctreeview/chm/chm.cpp 2004-04-23 17:43:44.000000000 +0800
@@ -29,6 +29,7 @@
#include <kglobal.h>
#include <kurl.h>
#include <kmimemagic.h>
+#include <ktempfile.h>
#include "chm.h"
@@ -85,9 +86,15 @@
error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
return;
}
-
+
QByteArray theData;
+ //init..
+ //add by lucida lucida@users.sf.net
+ QString fname = QString();
+ KTempFile f("",".html");
+ fname = f.name();
+ QTextStream *t = f.textStream();
if (path == "/") {
int offset = m_dirMap["/@contents"].offset;
int length = m_dirMap["/@contents"].length;
@@ -118,7 +125,9 @@
name = nameParam.cap(1);
if (obj.find(localParam) != -1) {
local = localParam.cap(1);
- output += "<a href=\"" + local + "\">" + name + "</a>";
+ //add by lucida lucida@users.sf.net
+ output += "<a target=\"browse\" href=\"ms-its:";
+ output += (const char *)(url.path().local8Bit()) + local + "\">" + name + "</a>";
} else {
output += name;
}
@@ -127,7 +136,8 @@
QString link = mergeParam.cap(1);
QString href = link.left(link.find("::"));
QString path = m_chmFile.left(m_chmFile.findRev("/") + 1);
- output += " (<a href=\"" + path + href + "\">link</a>)";
+ //add by lucida lucida@users.sf.net
+ output += " (<a target=\"browse\" href=\"ms-its:" + url.path() + path + href + "\">link</a>)";
}
}
output += s.mid(old);
@@ -135,8 +145,21 @@
//KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType( output, path );
//kdDebug() << "Emitting mimetype " << result->mimeType() << endl;
//mimeType( result->mimeType() );
- data(output.local8Bit());
- processedSize(output.length());
+
+ //construct the frame
+ //add by lucida lucida@users.sf.net
+ QString framestr = QString("<HEAD>\n");
+ framestr += "</HEAD><FRAMESET COLS=\"25%, *\">\n";
+ framestr += "<FRAME NAME=\"index\" src=\"file:"+ fname+"\"" + "marginwidth=\"2\"></FRAME>\n";
+ framestr += "<FRAME NAME=\"browse\">\n";
+ framestr += "</FRAME>\n";
+ framestr += "</FRAMESET></HTML>";
+ //write index file
+ //add by lucida lucida@user.sf.net
+ *t << QString::fromLocal8Bit(output.latin1()) << endl;
+
+ data(framestr.local8Bit());
+ processedSize(framestr.length());
} else {
int offset = m_dirMap[path].offset;
int length = m_dirMap[path].length;
@@ -150,7 +173,7 @@
theData.resetRawData(&m_contents[offset], length);
processedSize(length);
}
-
+ f.close();
finished();
}
[/PHP] |
|