13 #include <tqvariant.h> 17 #include <tqlistview.h> 18 #include <tqgroupbox.h> 22 #include <tdeconfig.h> 24 #include <tdeglobal.h> 25 #include <tdelocale.h> 28 #include <tdeapplication.h> 29 #include <kdevplugin.h> 32 #include "languageselectwidget.h" 33 #include "plugincontroller.h" 35 class LangPluginItem :
public TQCheckListItem
39 LangPluginItem( TQListView * parent, TQString
const & name, TQString
const & label,
40 TQString
const & info )
41 : TQCheckListItem( parent, label, TQCheckListItem::CheckBox),
42 _name( name ), _info( info )
45 TQString info() {
return _info; }
46 TQString name() {
return _name; }
54 LanguageSelectWidget::LanguageSelectWidget(TQDomDocument &projectDom,
55 TQWidget *parent,
const char *name)
56 : TQWidget(parent, name), m_projectDom(projectDom)
61 void LanguageSelectWidget::init()
63 TQVBoxLayout *layout =
new TQVBoxLayout(
this);
65 TQGroupBox * groupBox1 =
new TQGroupBox( i18n(
"Additional Language Support"),
this );
66 groupBox1->setColumnLayout(0, Qt::Vertical );
67 groupBox1->layout()->setSpacing( 6 );
68 groupBox1->layout()->setMargin( 11 );
69 TQVBoxLayout * groupBox1Layout =
new TQVBoxLayout( groupBox1->layout() );
70 groupBox1Layout->setAlignment( TQt::AlignTop );
72 _currentLanguage =
new TQLabel(
"", groupBox1 );
74 _pluginList =
new TQListView( groupBox1 );
75 _pluginList->setResizeMode( TQListView::LastColumn );
76 _pluginList->addColumn(
"");
77 _pluginList->header()->hide();
79 groupBox1Layout->addWidget(_currentLanguage);
80 groupBox1Layout->addWidget( _pluginList );
81 layout->addWidget( groupBox1 );
83 TQGroupBox * groupBox2 =
new TQGroupBox( i18n(
"Description"),
this );
84 groupBox2->setColumnLayout(0, Qt::Vertical );
85 groupBox2->layout()->setSpacing( 6 );
86 groupBox2->layout()->setMargin( 11 );
87 TQVBoxLayout * groupBox2Layout =
new TQVBoxLayout( groupBox2->layout() );
88 groupBox2Layout->setAlignment( TQt::AlignTop );
90 _pluginDescription =
new TQLabel( groupBox2 );
91 _pluginDescription->setAlignment(
int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );
93 groupBox2Layout->addWidget( _pluginDescription );
95 layout->addWidget( groupBox2 );
97 connect( _pluginList, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ),
this, TQT_SLOT( itemSelected( TQListViewItem * ) ) );
103 LanguageSelectWidget::~LanguageSelectWidget()
106 void LanguageSelectWidget::readProjectConfig()
108 TDETrader::OfferList languageSupportOffers =
109 TDETrader::self()->query(TQString::fromLatin1(
"TDevelop/LanguageSupport"),
110 TQString::fromLatin1(
"[X-TDevelop-Version] == %1" 111 ).arg( TDEVELOP_PLUGIN_VERSION ));
113 TQStringList languages = DomUtil::readListEntry(m_projectDom,
"/general/secondaryLanguages",
"language");
114 TQString language = DomUtil::readEntry(m_projectDom,
"/general/primarylanguage");
115 _currentLanguage->setText(i18n(
"Primary language is '%1'. Please select additional languages the project might contain.").arg(language));
117 for (TDETrader::OfferList::ConstIterator it = languageSupportOffers.begin(); it != languageSupportOffers.end(); ++it)
119 TQString la = (*it)->property(
"X-TDevelop-Language").toString();
122 LangPluginItem *item =
new LangPluginItem( _pluginList, (*it)->property(
"X-TDevelop-Language").toString(), (*it)->genericName(), (*it)->comment() );
123 item->setOn(languages.contains(la));
126 TQListViewItem * first = _pluginList->firstChild();
128 _pluginList->setSelected( first,
true );
132 void LanguageSelectWidget::itemSelected( TQListViewItem * item )
136 LangPluginItem * pitem =
static_cast<LangPluginItem*
>( item );
137 _pluginDescription->setText( pitem->info() );
140 void LanguageSelectWidget::saveProjectConfig()
142 TQStringList languages;
144 TQListViewItemIterator it( _pluginList );
145 while ( it.current() )
147 LangPluginItem * item =
static_cast<LangPluginItem*
>( it.current() );
150 languages.append( item->name() );
155 DomUtil::writeListEntry(m_projectDom,
"/general/secondaryLanguages",
"language", languages);
159 void LanguageSelectWidget::accept()
165 #include "languageselectwidget.moc"