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/protocolhandler.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/protocolhandler.cpp') 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 += "