From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/ctags2/ctags2_settingswidget.cpp | 173 +++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 parts/ctags2/ctags2_settingswidget.cpp (limited to 'parts/ctags2/ctags2_settingswidget.cpp') diff --git a/parts/ctags2/ctags2_settingswidget.cpp b/parts/ctags2/ctags2_settingswidget.cpp new file mode 100644 index 00000000..4bcdb122 --- /dev/null +++ b/parts/ctags2/ctags2_settingswidget.cpp @@ -0,0 +1,173 @@ +/*************************************************************************** + * Copyright (C) 2005 by Jens Dagerbo * + * jens.dagerbo@swipnet.se * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ctags2_settingswidget.h" +#include "ctags2_part.h" +#include "ctags2_selecttagfile.h" +#include "ctags2_createtagfile.h" + + +CTags2SettingsWidget::CTags2SettingsWidget( CTags2Part * part, QWidget* parent, const char* name, WFlags fl ) + : CTags2SettingsWidgetBase( parent, name, fl ), m_part( part ) +{ + binaryPath->completionObject()->setMode( KURLCompletion::FileCompletion ); + binaryPath->setMode( KFile::File | KFile::LocalOnly ); + binaryPath->setShowLocalProtocol( false ); + + tagfilePath->completionObject()->setMode( KURLCompletion::FileCompletion ); + tagfilePath->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); + tagfilePath->setShowLocalProtocol( false ); + + otherTagFiles->setSorting( -1 ); +// otherTagFiles->addColumn( "" ); +// otherTagFiles->header()->hide(); + otherTagFiles->setFullWidth( true ); + + loadSettings(); +} + +CTags2SettingsWidget::~CTags2SettingsWidget() +{ +} + +void CTags2SettingsWidget::loadSettings() +{ + QDomDocument & dom = *m_part->projectDom(); + + QString customArgs = DomUtil::readEntry( dom, "/ctagspart/customArguments" ); + if ( !customArgs.isEmpty() ) + { + tagfileCustomBox->setChecked( true ); + tagfileCustomEdit->setText( customArgs ); + } + + QString customTagfile = DomUtil::readEntry( dom, "/ctagspart/customTagfilePath" ); + if (customTagfile.isEmpty()) + { + customTagfile = m_part->project()->projectDirectory() + "/tags"; + } + tagfilePath->setURL(customTagfile); + + QStringList activeTagsFiles = DomUtil::readListEntry(dom, "/ctagspart/activeTagsFiles", "file"); + + KConfig * config = kapp->config(); + config->setGroup( "CTAGS" ); + showDeclarationBox->setChecked( config->readBoolEntry( "ShowDeclaration", true ) ); + showDefinitionBox->setChecked( config->readBoolEntry( "ShowDefinition", true ) ); + showLookupBox->setChecked( config->readBoolEntry( "ShowLookup", true ) ); + jumpToFirstBox->setChecked( config->readBoolEntry( "JumpToFirst", false ) ); + QString ctagsBinary = config->readEntry( "ctags binary" ).stripWhiteSpace(); + if ( !ctagsBinary.isEmpty() ) + { + binaryPath->setURL( ctagsBinary ); + } + + config->setGroup( "CTAGS-tagsfiles" ); + QMap entryMap = config->entryMap( "CTAGS-tagsfiles" ); + QMap::const_iterator it = entryMap.begin(); + while ( it != entryMap.end() ) + { + QString file = config->readPathEntry( it.key() ); + new TagsItem( otherTagFiles, it.key(), file, activeTagsFiles.contains( file ) ); + ++it; + } +} + +void CTags2SettingsWidget::storeSettings() +{ + QDomDocument & dom = *m_part->projectDom(); + DomUtil::writeEntry( dom, "/ctagspart/customArguments", tagfileCustomEdit->text() ); + DomUtil::writeEntry( dom, "/ctagspart/customTagfilePath", tagfilePath->url() ); + + KConfig * config = kapp->config(); + config->setGroup( "CTAGS" ); + config->writeEntry( "ShowDeclaration", showDeclarationBox->isChecked() ); + config->writeEntry( "ShowDefinition", showDefinitionBox->isChecked() ); + config->writeEntry( "ShowLookup", showLookupBox->isChecked() ); + config->writeEntry( "JumpToFirst", jumpToFirstBox->isChecked() ); + config->writeEntry( "ctags binary", binaryPath->url() ); + + config->deleteGroup( "CTAGS-tagsfiles" ); + config->setGroup( "CTAGS-tagsfiles" ); + + QStringList activeTagsFiles; + TagsItem * item = static_cast( otherTagFiles->firstChild() ); + while ( item ) + { + config->writePathEntry( item->name(), item->tagsfilePath() ); + if ( item->isOn() ) + { + activeTagsFiles.append( item->tagsfilePath() ); + } + item = static_cast( item->nextSibling() ); + } + DomUtil::writeListEntry( dom, "/ctagspart/activeTagsFiles", "file", activeTagsFiles ); + + activeTagsFiles.push_front( tagfilePath->url() ); + Tags::setTagFiles( activeTagsFiles ); + + config->sync(); + + emit newTagsfileName( tagfilePath->url() ); +} + +void CTags2SettingsWidget::slotAccept( ) +{ + storeSettings(); +} + +void CTags2SettingsWidget::createNewTagSlot() +{ + CreateTagFile* dlg = new CreateTagFile; + if ( dlg->exec() == QDialog::Accepted ) + { + m_part->createTagsFile( dlg->tagsfilePath(), dlg->directory() ); + new TagsItem( otherTagFiles, dlg->name(), dlg->tagsfilePath(), true ); + } +} + +void CTags2SettingsWidget::addNewTagFile() +{ + SelectTagFile* dlg = new SelectTagFile; + + if ( dlg->exec() == QDialog::Accepted ) + { + new TagsItem( otherTagFiles, dlg->name(), dlg->tagsfilePath(), true ); + } +} + +void CTags2SettingsWidget::removeTagFile() +{ + if (!otherTagFiles->selectedItem()) + return; + + delete otherTagFiles->selectedItem(); +} + + +#include "ctags2_settingswidget.moc" + +// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off; -- cgit v1.2.1