• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Generic Shell
 

KDevelop Generic Shell

  • src
pluginselectdialog.cpp
1/***************************************************************************
2 * Copyright (C) 2006 by Jens Dagerbo *
3 * jens.dagerbo@swipnet.se *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 ***************************************************************************/
11
12#include <tqlistview.h>
13#include <tqheader.h>
14#include <tqlabel.h>
15#include <tqregexp.h>
16
17#include <kdebug.h>
18#include <tdeapplication.h>
19#include <kurllabel.h>
20
21#include "kdevplugin.h"
22#include "projectmanager.h"
23#include "plugincontroller.h"
24#include "pluginselectdialog.h"
25
26class PluginItem : public TQCheckListItem
27{
28public:
29 // name - "Name", label - "GenericName", info - "Comment"
30 PluginItem( TQListView * parent, TQString const & name, TQString const & label,
31 TQString const & info, TQString const url = TQString() )
32 : TQCheckListItem( parent, label, TQCheckListItem::CheckBox),
33 _name( name ), _info( info ), _url( url )
34 {}
35
36 TQString info() { return _info; }
37 TQString name() { return _name; }
38 TQString url() { return _url; }
39
40private:
41 TQString _name;
42 TQString _info;
43 TQString _url;
44};
45
46
47PluginSelectDialog::PluginSelectDialog(TQWidget* parent, const char* name, bool modal, WFlags fl )
48 : PluginSelectDialogBase( parent,name, modal,fl )
49{
50 plugin_list->setResizeMode( TQListView::LastColumn );
51 plugin_list->addColumn("");
52 plugin_list->header()->hide();
53
54 connect( plugin_list, TQ_SIGNAL( selectionChanged( TQListViewItem * ) ), this, TQ_SLOT( itemSelected( TQListViewItem * ) ) );
55 connect( urllabel, TQ_SIGNAL( leftClickedURL( const TQString & ) ), this, TQ_SLOT( openURL( const TQString & ) ) );
56
57 init();
58}
59
60PluginSelectDialog::~PluginSelectDialog()
61{
62}
63
64void PluginSelectDialog::saveAsDefault()
65{
66 kdDebug(9000) << k_funcinfo << endl;
67
68 ProfileEngine & engine = PluginController::getInstance()->engine();
69 Profile * profile = engine.findProfile( PluginController::getInstance()->currentProfile() );
70
71 profile->clearList( Profile::ExplicitDisable );
72
73 TQListViewItemIterator it( plugin_list );
74 while ( it.current() )
75 {
76 PluginItem * item = static_cast<PluginItem*>( it.current() );
77 if ( !item->isOn() )
78 {
79 profile->addEntry( Profile::ExplicitDisable, item->name() );
80 }
81 ++it;
82 }
83
84 profile->save();
85}
86
87void PluginSelectDialog::openURL( const TQString & url )
88{
89 kapp->invokeBrowser( url );
90}
91
92void PluginSelectDialog::itemSelected( TQListViewItem * item )
93{
94 if ( ! item ) return;
95
96 PluginItem * pitem = static_cast<PluginItem*>( item );
97 plugin_description_label->setText( pitem->info() );
98
99 if ( pitem->url().isEmpty() )
100 {
101 urllabel->clear();
102 }
103 else
104 {
105 urllabel->setURL( pitem->url() );
106 urllabel->setText( pitem->url() );
107 }
108}
109
110void PluginSelectDialog::init( )
111{
112 const TQValueList<KDevPlugin*> loadedPlugins = PluginController::getInstance()->loadedPlugins();
113 TQStringList loadedPluginDesktopNames;
114 TQValueList<KDevPlugin*>::ConstIterator it = loadedPlugins.begin();
115 while( it != loadedPlugins.end() )
116 {
117 loadedPluginDesktopNames << (*it)->instance()->instanceName();
118 ++it;
119 }
120
121 kdDebug(9000) << " *** loadedPluginDesktopNames: " << loadedPluginDesktopNames << endl;
122
123 TDETrader::OfferList localOffers;
124 if ( ProjectManager::getInstance()->projectLoaded() )
125 {
126 localOffers = PluginController::getInstance()->engine().offers(
127 PluginController::getInstance()->currentProfile(), ProfileEngine::Project );
128 }
129
130 TDETrader::OfferList globalOffers = PluginController::getInstance()->engine().offers(
131 PluginController::getInstance()->currentProfile(), ProfileEngine::Global);
132
133 TDETrader::OfferList offers = localOffers + globalOffers;
134 for (TDETrader::OfferList::ConstIterator it = offers.begin(); it != offers.end(); ++it)
135 {
136 // parse out any existing url to make it clickable
137 TQString Comment = (*it)->comment();
138 TQRegExp re("\\bhttp://[\\S]*");
139 re.search( Comment );
140 Comment.replace( re, "" );
141
142 TQString url;
143 if ( re.pos() > -1 )
144 {
145 url = re.cap();
146 }
147
148 PluginItem *item = new PluginItem( plugin_list, (*it)->desktopEntryName(), (*it)->genericName(), Comment, url );
149 item->setOn( loadedPluginDesktopNames.contains( (*it)->desktopEntryName() ) );
150
151 kdDebug(9000) << (*it)->desktopEntryName() << " : " << (loadedPluginDesktopNames.contains( (*it)->desktopEntryName() ) ? "YES" : "NO" ) << endl;
152 }
153
154 TQListViewItem * first = plugin_list->firstChild();
155 if ( first )
156 {
157 plugin_list->setSelected( first, true );
158 }
159}
160
161TQStringList PluginSelectDialog::unselectedPluginNames( )
162{
163 TQStringList unselectedPlugins;
164 TQListViewItem * item = plugin_list->firstChild();
165 while ( item )
166 {
167 PluginItem * pluginItem = static_cast<PluginItem*>( item );
168 if ( !pluginItem->isOn() )
169 {
170 unselectedPlugins << pluginItem->name();
171 }
172 item = item->nextSibling();
173 }
174 return unselectedPlugins;
175}
176
177
178
179#include "pluginselectdialog.moc"

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Generic Shell

Skip menu "KDevelop Generic Shell"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Generic Shell by doxygen 1.9.8
This website is maintained by Timothy Pearson.