From 5aa561f14ebb34866d6cbac2657338d70ae192fd Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 16 Dec 2009 01:41:53 +0100 Subject: File protocol handling! Yeah! --- src/data/notfound.html | 14 ++++++-------- src/protocolhandler.cpp | 30 +++++++++++++++++++----------- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/data/notfound.html b/src/data/notfound.html index e34bfc6d..e347f53a 100644 --- a/src/data/notfound.html +++ b/src/data/notfound.html @@ -11,7 +11,7 @@ padding:0; } body{ -background: url(%2/tile.gif) repeat-x #fff; +background: #AAA; margin:0; padding:0; font-family: sans-serif; @@ -19,15 +19,13 @@ font-size: 100%; } #block { -/* background: url(%2/bot.gif) bottom center #f3f3f3; */ +background: #fff; border: 2px solid #d9d9d9; -padding: 10px; -width: 600px; -margin: 150px auto; +padding: 40px; +width: 800px; +margin: 60px auto; color: #444; - -/*font-weight: bold; -clear: right;*/ +-webkit-border-radius: 15px } h1{ diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 677618dc..c9b34945 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -100,7 +100,6 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) if(url.protocol() == QLatin1String("file")) { QString html = fileHandling(url); - kDebug() << html; frame->setHtml( html ); // KUrl::List list; // list.append(url); @@ -139,14 +138,21 @@ QString ProtocolHandler::fileHandling(const KUrl &url) } QString title = url.path(); - QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); - QString msg = "

" + url.path() + "

"; + QString msg = "

" + i18n("Index of ") + "file://" + url.path() + "

"; dir.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); QFileInfoList entries = dir.entryInfoList(); - msg += ""; - msg += ""; + if(!dir.isRoot()) + { + QString path = "file://" + dir.absoluteFilePath(".."); + QString uparrow = KIconLoader::global()->iconPath( "arrow-up", KIconLoader::Small ); + msg += "\"up-arrow\""; + msg += "" + i18n("Up to higher level directory") + "

"; + } + + msg += "
" + i18n("Name") + "" + i18n("Size") + "" + i18n("Last Modified") + "
"; + msg += ""; foreach(const QFileInfo &item, entries) { @@ -154,19 +160,21 @@ QString ProtocolHandler::fileHandling(const KUrl &url) QString fullPath = QString("file://") + item.absoluteFilePath(); QString iconName = KMimeType::defaultMimeTypePtr()->iconNameForUrl(fullPath); - kDebug() << "***************************************" << iconName << "********************************"; QString icon = QString("file://") + KIconLoader::global()->iconPath( iconName, KIconLoader::Small ); - msg += ""; - msg += ""; - msg += ""; @@ -177,7 +185,7 @@ QString ProtocolHandler::fileHandling(const KUrl &url) QString html = QString(QLatin1String(file.readAll())) .arg(title) - .arg(imagesPath) +// .arg(imagesPath) .arg(msg) ; -- cgit v1.2.1
" + i18n("Name") + "" + i18n("Size") + "" + i18n("Last Modified") + "
"; + msg += ""; msg += "\"" "; msg += "" + item.fileName() + ""; msg += ""; - msg += QString::number( item.size()/1024 ) + "KB"; + msg += ""; + if(item.isFile()) + { + msg += QString::number( item.size()/1024 ) + "KB"; + } msg += ""; + msg += ""; msg += item.lastModified().toString("dd/MM/yyyy hh:mm:ss"); msg += "