[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: freeze
From:       Waldo Bastian <bastian () kde ! org>
Date:       2000-08-14 4:36:43
[Download RAW message or body]

On Sat, 12 Aug 2000, Dima Rogozin wrote:
> This is what I found after 5 minutes of testing (and I did not try
> fancy time/date options):
[Snip]
> - Mime types are not sorted any more.
[Snip]

The following patch sorts the mimetypes.

I noticed that not all mimetypes have a comment set. I will add a line of 
code to KMimeType to let KMimeType::comment() default to name() if there is 
no comment available.

Cheers,
Waldo
- 
Make way, KDE/Linux is coming to a desktop near you!

["kfind.diff2" (text/x-c++)]

Index: kftabdlg.cpp
===================================================================
RCS file: /home/kde/kdeutils/kfind/kftabdlg.cpp,v
retrieving revision 1.14
diff -u -r1.14 kftabdlg.cpp
--- kftabdlg.cpp	2000/08/09 23:15:11	1.14
+++ kftabdlg.cpp	2000/08/14 04:37:27
@@ -34,6 +34,20 @@
 
 #define SPECIAL_TYPES 7
 
+class KSortedMimeTypeList : public QList<KMimeType>
+{
+public: 
+  KSortedMimeTypeList() { };
+  int compareItems(QCollection::Item s1, QCollection::Item s2)
+  {
+     KMimeType *item1 = (KMimeType *) s1;
+     KMimeType *item2 = (KMimeType *) s2;
+     if (item1->comment() > item2->comment()) return 1;
+     if (item1->comment() == item2->comment()) return 0;
+     return -1;
+  }
+};
+
 KfindTabWidget::KfindTabWidget(const KURL & url,
 			       QWidget *parent, const char *name)
   : QTabWidget( parent, name ),
@@ -186,7 +200,7 @@
     typeBox->insertItem(i18n("Executable files"));
     typeBox->insertItem(i18n("SUID executable files"));
 
-    m_types = KMimeType::allMimeTypes();
+    initMimeTypes();
 
     for ( KMimeType::List::ConstIterator it = m_types.begin(); 
           it != m_types.end(); ++it )
@@ -238,6 +252,25 @@
   delete pages[1];
   delete pages[2];
 }
+
+void
+KfindTabWidget::initMimeTypes()
+{
+    KMimeType::List tmp = KMimeType::allMimeTypes();
+    KSortedMimeTypeList sortedList;
+    for ( KMimeType::List::ConstIterator it = tmp.begin(); 
+          it != tmp.end(); ++it )
+    {
+      KMimeType * type = *it;
+      sortedList.append(type);
+    }
+    sortedList.sort();
+    for ( KMimeType *type = sortedList.first(); type; type = sortedList.next())
+    {
+       m_types.append(type);
+    }
+}   
+
 
 void KfindTabWidget::saveHistory()
 {
Index: kftabdlg.h
===================================================================
RCS file: /home/kde/kdeutils/kfind/kftabdlg.h,v
retrieving revision 1.5
diff -u -r1.5 kftabdlg.h
--- kftabdlg.h	2000/08/09 23:15:11	1.5
+++ kftabdlg.h	2000/08/14 04:37:28
@@ -32,6 +32,7 @@
 public:
   KfindTabWidget(const KURL & url, QWidget * parent = 0, const char *name=0);
   virtual ~KfindTabWidget();
+  void initMimeTypes();
   void setQuery(class KQuery * query);
   void setDefaults();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic