SVN commit 771210 by amantia: List plugins in the Open With... menu. M +2 -1 ChangeLog M +5 -5 quanta.kdevelop M +1 -0 treeviews/Makefile.am M +42 -8 treeviews/basetreeview.cpp M +4 -0 treeviews/basetreeview.h --- branches/KDE/3.5/kdewebdev/quanta/ChangeLog #771209:771210 @@ -17,8 +17,9 @@ - make the parser as fast as it was in 3.5.6 and before - fix help button in the New Project wizard [#145324] - do not add the same entry over and over to the completion list +- improvements: + - list plugins in the Open With... menu. - Version 3.5.7 (Release date: xx-xx-2006; Started 06-02-2006) - bugfixes: - fix directory creation when certain ftp servers are used [#141232] --- branches/KDE/3.5/kdewebdev/quanta/quanta.kdevelop #771209:771210 @@ -32,7 +32,7 @@ true - 4 + 2 false @@ -41,7 +41,7 @@ 0 - false + true @@ -184,7 +184,7 @@ false - + true @@ -260,10 +260,10 @@ - + Quanta speicfic header - + A new empty C++ file. --- branches/KDE/3.5/kdewebdev/quanta/treeviews/Makefile.am #771209:771210 @@ -20,4 +20,5 @@ -I$(top_srcdir)/lib \ -I$(top_builddir)/quanta/dialogs/tagdialogs \ -I$(top_builddir)/quanta/components/csseditor \ + -I$(top_srcdir)/quanta/plugins \ $(KMDI_INCLUDES) $(CVSSERVICE_INCLUDE) $(LIBXML_CFLAGS) $(LIBXSLT_CFLAGS) $(all_includes) --- branches/KDE/3.5/kdewebdev/quanta/treeviews/basetreeview.cpp #771209:771210 @@ -62,6 +62,8 @@ #include "qextfileinfo.h" #include "viewmanager.h" #include "quantanetaccess.h" +#include "quantaplugininterface.h" +#include "quantaplugin.h" #include @@ -561,6 +563,21 @@ } } +void BaseTreeView::slotOpenWithActivated(int id) +{ + if (m_pluginIds.contains(id)) + { + QuantaPlugin *plugin = m_pluginIds[id]; + plugin->unload(true); + plugin->load(); + int input = plugin->input(); + plugin->setInput(-1); //disable input + plugin->run(); + plugin->part()->openURL(currentURL()); + plugin->setInput(input); + } +} + void BaseTreeView::insertOpenWithMenu(KPopupMenu *menu, int position) { if (m_openWithMenuId != -1) @@ -574,19 +591,36 @@ KURL urlToOpen = currentURL(); QString mimeType = KMimeType::findByURL(urlToOpen, 0, true, true)->name(); KTrader::OfferList offers = KTrader::self()->query(mimeType, "Type == 'Application'"); + QDict plugins = QuantaPluginInterface::ref()->plugins(); + m_pluginIds.clear(); - if (offers.count() > 0) + if (offers.count() > 0 || plugins.count() > 0) { m_openWithMenu = new KPopupMenu(this); - KTrader::OfferList::Iterator it; - for (it = offers.begin(); it != offers.end(); ++it) + if (offers.count() > 0) { - KAction *action = new KAction((*it)->name(), (*it)->icon(), 0, 0, QFile::encodeName((*it)->desktopEntryPath()).data()); - connect(action, SIGNAL(activated()), this, SLOT(slotOpenWithApplication())); - action->plug(m_openWithMenu); - m_openWithActions.append(action); + KTrader::OfferList::Iterator it; + for (it = offers.begin(); it != offers.end(); ++it) + { + KAction *action = new KAction((*it)->name(), (*it)->icon(), 0, 0, QFile::encodeName((*it)->desktopEntryPath()).data()); + connect(action, SIGNAL(activated()), this, SLOT(slotOpenWithApplication())); + action->plug(m_openWithMenu); + m_openWithActions.append(action); + } + m_openWithMenu->insertSeparator(); } - m_openWithMenu->insertSeparator(); + if (plugins.count() > 0) + { + m_openWithMenu->insertTitle(i18n("Plugins")); + QDictIterator it2(plugins); + for(;it2.current();++it2) + { + int id = m_openWithMenu->insertItem(KGlobal::iconLoader()->loadIconSet(it2.current()->icon(),KIcon::Small), it2.current()->name()); + m_pluginIds[id] = it2.current(); + } + connect(m_openWithMenu, SIGNAL(activated(int)), SLOT(slotOpenWithActivated(int))); + m_openWithMenu->insertSeparator(); + } m_openWithMenu->insertItem(i18n("&Other..."), this, SLOT(slotOpenWith())); m_openWithMenuId = menu->insertItem(i18n("Open &With"), m_openWithMenu, -1, position); } else --- branches/KDE/3.5/kdewebdev/quanta/treeviews/basetreeview.h #771209:771210 @@ -44,6 +44,7 @@ class KURL; class FileInfoDlg; class BaseTreeViewToolTip; +class QuantaPlugin; /** * @short a KFileTreeViewItem with some specials. @@ -259,6 +260,8 @@ */ virtual void slotCreateFile(); + virtual void slotOpenWithActivated(int id); + protected: /** implement this to create a branch and add this branch to the treeview @@ -353,6 +356,7 @@ KPopupMenu *m_openWithMenu; int m_openWithMenuId; QValueList m_openWithActions; + QMap m_pluginIds; }; #endif