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

List:       kde-commits
Subject:    kdebase/kcontrol/filetypes
From:       Waldo Bastian <bastian () kde ! org>
Date:       2003-11-18 12:58:11
[Download RAW message or body]

CVS commit by waba: 

Explain that services associated with text/plain can't be removed from e.g.
text/x-pascal although they do show up there.


  M +20 -6     kservicelistwidget.cpp   1.22
  M +23 -0     typeslistitem.cpp   1.41
  M +3 -0      typeslistitem.h   1.16


--- kdebase/kcontrol/filetypes/typeslistitem.cpp  #1.40:1.41
@@ -370,4 +370,27 @@ static bool inheritsMimetype(KMimeType::
 }
 
+KMimeType::Ptr TypesListItem::findImplicitAssociation(const QString &desktop)
+{
+    KService::Ptr s = KService::serviceByDesktopPath(desktop);
+
+    if( s_changedServices == NULL )
+       deleter.setObject( s_changedServices, new QMap< QString, QStringList > );
+    QStringList mimeTypeList = s_changedServices->contains( s->desktopEntryPath())
+       ? (*s_changedServices)[ s->desktopEntryPath() ] : s->serviceTypes();
+
+    if (mimeTypeList.contains(name()))
+       return 0;
+       
+    for(QStringList::ConstIterator it = mimeTypeList.begin();
+       it != mimeTypeList.end(); ++it)
+    {
+       if (m_mimetype->is(*it))
+       {
+          return KMimeType::mimeType(*it);
+       }
+    }
+    return 0;
+}
+
 void TypesListItem::saveServices( KConfig & profile, QStringList services, const \
QString & genericServiceType )  {

--- kdebase/kcontrol/filetypes/typeslistitem.h  #1.15:1.16
@@ -54,4 +54,7 @@ public:
   const KMimeType::Ptr& mimeType() const { return m_mimetype; }
 
+  // Whether the service s lists this mimetype explicitly
+  KMimeType::Ptr findImplicitAssociation(const QString &desktop);
+
   bool isMimeTypeDirty() const; // whether the mimetype .desktop file needs saving
   bool isDirty() const;

--- kdebase/kcontrol/filetypes/kservicelistwidget.cpp  #1.21:1.22
@@ -5,6 +5,7 @@
 #include <kdebug.h>
 #include <klocale.h>
-#include <kopenwith.h>
+#include <kmessagebox.h>
 #include <knotifyclient.h>
+#include <kopenwith.h>
 
 #include "kservicelistwidget.h"
@@ -310,6 +311,5 @@ void KServiceListWidget::editService()
 void KServiceListWidget::removeService()
 {
-  // TODO check if service is associated with this mimetype or with one
-  // of its parents
+  if (!m_item) return;
   // Here are some strings already so that we don't have to break translations
   // later on.
@@ -328,8 +328,22 @@ void KServiceListWidget::removeService()
 
   if ( selected >= 0 ) {
+    // Check if service is associated with this mimetype or with one of its parents
+    KServiceListItem *serviceItem = static_cast<KServiceListItem \
*>(servicesLB->item(selected)); +    KMimeType::Ptr mimetype = \
m_item->findImplicitAssociation(serviceItem->desktopPath); +    if (mimetype)
+    {
+       KMessageBox::sorry(this, "<qt>"+msg1.arg(serviceItem->text())+"<p>"+
+                                msg2.arg(mimetype->name()).arg(mimetype->comment()).
+                                arg(m_item->name()).arg(m_item->comment()).
+                                arg(mimetype->name())+"<p>"+
+                                msg3.arg(mimetype->name()));
+    }
+    else
+    {
     servicesLB->removeItem( selected );
     updatePreferredServices();
 
     emit changed(true);
+    }
   }
 


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

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