You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdevelop/parts/documentation/find_documentation_options.cpp

193 lines
6.5 KiB

/***************************************************************************
* Copyright (C) 2004 by Tobias Glaesser *
* tobi.web@gmx.de *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "find_documentation_options.h"
#include <tqheader.h>
#include <tqcheckbox.h>
#include <klistview.h>
#include <klocale.h>
#include <kconfig.h>
#include <kapplication.h>
FindDocumentationOptions::FindDocumentationOptions(TQWidget* tqparent, const char* name, bool modal)
:FindDocumentationOptionsBase(tqparent,name, modal),
m_man_item(0), m_info_item(0), m_index_item(0), m_google_item(0), m_contents_item(0)
{
readOptions();
source_list->header()->hide();
source_list->setSorting(-1);
}
FindDocumentationOptions::~FindDocumentationOptions()
{
}
/*$SPECIALIZATION$*/
bool FindDocumentationOptions::isContents( TQCheckListItem * item )
{
if ( item == m_contents_item && m_contents_item->isOn() )
return true;
else
return false;
}
bool FindDocumentationOptions::isGoogle( TQCheckListItem * item )
{
if ( item == m_google_item && m_google_item->isOn() )
return true;
else
return false;
}
bool FindDocumentationOptions::isIndex( TQCheckListItem * item )
{
if ( item == m_index_item && m_index_item->isOn() )
return true;
else
return false;
}
bool FindDocumentationOptions::isInfo( TQCheckListItem * item )
{
if ( item == m_info_item && m_info_item->isOn() )
return true;
else
return false;
}
bool FindDocumentationOptions::isMan( TQCheckListItem * item )
{
if ( item == m_man_item && m_man_item->isOn() )
return true;
else
return false;
}
void FindDocumentationOptions::sourceMoveDown()
{
if (!source_list->currentItem())
return;
if (source_list->currentItem()->nextSibling() == 0)
return;
source_list->currentItem()->moveItem(source_list->currentItem()->nextSibling());
}
void FindDocumentationOptions::sourceMoveUp()
{
if (!source_list->currentItem())
return;
if (source_list->currentItem() == source_list->firstChild())
return;
TQListViewItem *item = source_list->firstChild();
while (item->nextSibling() != source_list->currentItem())
item = item->nextSibling();
item->moveItem( source_list->currentItem());
}
void FindDocumentationOptions::writeOptions()
{
config = kapp->config();
config->setGroup("DocumentationFinder");
config->writeEntry("goto_first_match", goto_first_match->isChecked());
TQListViewItemIterator it( source_list );
int i = 0;
while ( it.current() )
{
if ( it.current() == m_man_item )
{
config->writeEntry("Manpage",i);
config->writeEntry("ManpageEnabled",m_man_item->isOn());
}
else if ( it.current() == m_info_item )
{
config->writeEntry("Info",i);
config->writeEntry("InfoEnabled",m_info_item->isOn());
}
else if ( it.current() == m_index_item )
{
config->writeEntry("Index",i);
config->writeEntry("IndexEnabled",m_index_item->isOn());
}
else if ( it.current() == m_google_item )
{
config->writeEntry("Google",i);
config->writeEntry("GoogleEnabled",m_google_item->isOn());
}
else if ( it.current() == m_contents_item )
{
config->writeEntry("Contents",i);
config->writeEntry("ContentsEnabled",m_contents_item->isOn());
}
++it;
++i;
}
config->sync();
}
void FindDocumentationOptions::readOptions()
{
config = kapp->config();
config->setGroup("DocumentationFinder");
source_list->clear();
for(int i = 4; i > -1; --i )
{
if( config->readPropertyEntry( "Manpage" , 0 ) == i)
{
m_man_item = new TQCheckListItem( source_list, i18n("Manual"), TQCheckListItem::CheckBox );
m_man_item->setOn(config->readBoolEntry( "ManpageEnabled" , true));
}
if( config->readPropertyEntry( "Info" , 1 ) == i)
{
m_info_item = new TQCheckListItem( source_list, i18n("Info"), TQCheckListItem::CheckBox );
m_info_item->setOn(config->readBoolEntry( "InfoEnabled" , true));
}
if( config->readPropertyEntry( "Index" , 2 ) == i)
{
m_index_item = new TQCheckListItem( source_list, i18n("Index"), TQCheckListItem::CheckBox );
m_index_item->setOn(config->readBoolEntry( "IndexEnabled" , true));
}
if( config->readPropertyEntry( "Google" , 3 ) == i)
{
m_google_item = new TQCheckListItem( source_list, i18n("Google"), TQCheckListItem::CheckBox );
m_google_item->setOn(config->readBoolEntry( "GoogleEnabled" , false));
}
if( config->readPropertyEntry( "Contents" , 4 ) == i)
{
m_contents_item = new TQCheckListItem( source_list, i18n("Contents"), TQCheckListItem::CheckBox );
m_contents_item->setOn(config->readBoolEntry( "ContentsEnabled" , false));
}
}
goto_first_match->setChecked(config->readBoolEntry( "goto_first_match" , false));
}
#include "find_documentation_options.moc"