[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: [PATCH] fixing file submission
From: George Staikos <staikos () kde ! org>
Date: 2004-10-29 4:43:07
Message-ID: 200410290043.07578.staikos () kde ! org
[Download RAW message or body]
There are all kinds of weird quirks with KURLRequester in apps, and KHTML
experiences these problems in multiple ways. I think this patch fixes it.
It does the following:
1) make the completion in KURLRequester relative to $PWD, which I think makes
sense
2) work with relative filenames, absolute filenames, and URLs
Presently, if you type a relative path (it's almost forced on you due to
copmletion), it silently doesn't submit the file. [*] This patch fixes it.
It also makes relative paths work no-matter where KHTML is running ($PWD).
* We should also warn if the file doesn't exist and is non-null I think, but
I'll leave that for another fix.
Comments? Ok to commit?
--
George Staikos
KDE Developer http://www.kde.org/
Staikos Computing Services Inc. http://www.staikos.net/
["fixfilefinding.patch" (text/x-diff)]
Index: html/html_formimpl.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/html/html_formimpl.cpp,v
retrieving revision 1.394
diff -u -3 -p -r1.394 html_formimpl.cpp
--- html/html_formimpl.cpp 27 Oct 2004 20:22:22 -0000 1.394
+++ html/html_formimpl.cpp 29 Oct 2004 04:42:19 -0000
@@ -292,7 +292,13 @@ QByteArray HTMLFormElementImpl::formData
static_cast<HTMLInputElementImpl*>(current)->inputType() == \
HTMLInputElementImpl::FILE && current->renderer())
{
- const KURL path ( \
static_cast<HTMLInputElementImpl*>(current)->value().string()); + \
KURL path; + QString val = \
static_cast<HTMLInputElementImpl*>(current)->value().string(); + \
if (QFile::exists(val) && QFileInfo(val).isRelative()) { + \
path = KURL::fromPathOrURL(QFileInfo(val).absFilePath()); + } \
else { + path = KURL::fromPathOrURL(val);
+ }
hstr += fixUpfromUnicode(codec, "; filename=\"" + \
path.fileName() + "\""); if(path.isValid()) {
@@ -1396,14 +1402,20 @@ bool HTMLInputElementImpl::encoding(cons
}
break;
- case FILE:
+ case FILE: // hmm, we have the type FILE also. bad choice here...
{
// don't submit if display: none or display: hidden
if(!renderer() || renderer()->style()->visibility() != khtml::VISIBLE)
return false;
QString local;
- const KURL fileurl(value().string());
+ KURL fileurl;
+ QString val = value().string();
+ if (QFile::exists(val) && QFileInfo(val).isRelative()) {
+ fileurl = KURL::fromPathOrURL(QFileInfo(val).absFilePath());
+ } else {
+ fileurl = KURL::fromPathOrURL(val);
+ }
KIO::UDSEntry filestat;
// can't submit file in www-url-form encoded
@@ -1413,7 +1425,7 @@ bool HTMLInputElementImpl::encoding(cons
if ( KIO::NetAccess::stat(fileurl, filestat, toplevel)) {
const KFileItem fileitem(filestat, fileurl, true, false);
if ( fileitem.isFile() &&
- KIO::NetAccess::download(KURL(value().string()), local, \
toplevel) ) { + KIO::NetAccess::download(fileurl, local, \
toplevel) ) { QFile file(local);
filearray.resize(file.size()+1);
if ( file.open( IO_ReadOnly ) ) {
Index: rendering/render_form.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.cpp,v
retrieving revision 1.279
diff -u -3 -p -r1.279 render_form.cpp
--- rendering/render_form.cpp 15 Oct 2004 15:19:00 -0000 1.279
+++ rendering/render_form.cpp 29 Oct 2004 04:42:20 -0000
@@ -35,6 +35,7 @@
#include <kreplace.h>
#include <kreplacedialog.h>
#include <kspell.h>
+#include <kurlcompletion.h>
#include <kwin.h>
#include <qstyle.h>
@@ -720,6 +721,7 @@ RenderFileButton::RenderFileButton(HTMLI
KURLRequester* w = new KURLRequester( view()->viewport(), "__khtml" );
w->setMode(KFile::File | KFile::ExistingOnly);
+ w->completionObject()->setDir(QDir::currentDirPath());
connect(w->lineEdit(), SIGNAL(returnPressed()), this, \
SLOT(slotReturnPressed()));
connect(w->lineEdit(), SIGNAL(textChanged(const QString \
&)),this,SLOT(slotTextChanged(const QString &)));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic