diff options
| author | Andrea Diamantini <adjam7@gmail.com> | 2010-11-01 23:23:24 +0100 | 
|---|---|---|
| committer | Andrea Diamantini <adjam7@gmail.com> | 2010-11-07 23:03:36 +0100 | 
| commit | 8084f4ffe2bfe48359009cb2c475a13328429c34 (patch) | |
| tree | 9e20d2c5acc6fc60b938918e57984d746dccfe5c | |
| parent | Merge branch 'master' of git.kde.org:rekonq (diff) | |
| download | rekonq-8084f4ffe2bfe48359009cb2c475a13328429c34.tar.xz | |
Ordering files in file: and ftp: embedded protocols
| -rw-r--r-- | src/protocolhandler.cpp | 34 | ||||
| -rw-r--r-- | src/protocolhandler.h | 2 | 
2 files changed, 34 insertions, 2 deletions
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index a595394a..a29ff366 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -57,6 +57,37 @@  #include <QtWebKit/QWebFrame> +static bool fileItemListLessThan(const KFileItem &s1, const KFileItem &s2) +{ +    return s1.name().toLower() < s2.name().toLower(); +} + + +static KFileItemList sortFileList(const KFileItemList &list) +{ +    KFileItemList orderedList, dirList, fileList; +     +    // order dirs before files.. +    Q_FOREACH(const KFileItem &item, list) +    { +        if(item.isDir()) +            dirList << item; +        else +            fileList << item; +    } +    qStableSort(dirList.begin(), dirList.end(), fileItemListLessThan); +    qStableSort(fileList.begin(), fileList.end(), fileItemListLessThan); + +    orderedList << dirList; +    orderedList << fileList; +     +    return orderedList; +} + + +// ------------------------------------------------------------------------------------------- + +  ProtocolHandler::ProtocolHandler(QObject *parent)          : QObject(parent)          , _lister( new KDirLister(this) ) @@ -282,7 +313,8 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list)      msg += "<table width=\"100%\">";      msg += "<tr><th align=\"left\">" + i18n("Name") + "</th><th>" + i18n("Size") + "</th><th>" + i18n("Last Modified") + "</th></tr>"; -    foreach(const KFileItem &item, list) +    KFileItemList orderedList = sortFileList(list); +    Q_FOREACH(const KFileItem &item, orderedList)      {          msg += "<tr>";          QString fullPath = item.url().prettyUrl(); diff --git a/src/protocolhandler.h b/src/protocolhandler.h index 4211e4ef..a80c160d 100644 --- a/src/protocolhandler.h +++ b/src/protocolhandler.h @@ -76,7 +76,7 @@ private slots:  private:      QString dirHandling(const KFileItemList &list);      void abpHandling(); - +          KDirLister *_lister;      QWebFrame *_frame;      KUrl _url;  | 
