KDevelop API Documentation

find_documentation_options.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Tobias Glaesser                                 *
00003  *   tobi.web@gmx.de                                                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "find_documentation_options.h"
00021 
00022 #include <qheader.h>
00023 #include <qcheckbox.h>
00024 
00025 #include <klistview.h>
00026 #include <klocale.h>
00027 
00028 #include <kconfig.h>
00029 #include <kapplication.h>
00030 
00031 FindDocumentationOptions::FindDocumentationOptions(QWidget* parent, const char* name, bool modal)
00032     :FindDocumentationOptionsBase(parent,name, modal),
00033     m_man_item(0), m_info_item(0), m_index_item(0), m_google_item(0), m_contents_item(0)
00034 {        
00035     readOptions();
00036     
00037     source_list->header()->hide();
00038     source_list->setSorting(-1);
00039 }
00040 
00041 FindDocumentationOptions::~FindDocumentationOptions()
00042 {
00043 }
00044 
00045 /*$SPECIALIZATION$*/
00046 bool FindDocumentationOptions::isContents( QCheckListItem * item )
00047 {
00048     if ( item == m_contents_item && m_contents_item->isOn()  )
00049         return true;
00050     else 
00051         return false;
00052 }
00053 
00054 bool FindDocumentationOptions::isGoogle( QCheckListItem * item )
00055 {
00056     if ( item == m_google_item && m_google_item->isOn()  )
00057         return true;
00058     else 
00059         return false;
00060 }
00061 
00062 bool FindDocumentationOptions::isIndex( QCheckListItem * item )
00063 {
00064     if ( item == m_index_item  && m_index_item->isOn() )
00065         return true;
00066     else 
00067         return false;
00068 }
00069 
00070 bool FindDocumentationOptions::isInfo( QCheckListItem * item )
00071 {
00072     if ( item == m_info_item  && m_info_item->isOn() )
00073         return true;
00074     else 
00075         return false;
00076 }
00077 
00078 bool FindDocumentationOptions::isMan( QCheckListItem * item )
00079 {
00080     if ( item == m_man_item && m_man_item->isOn() )
00081         return true;
00082     else 
00083         return false;
00084 }
00085 
00086 void FindDocumentationOptions::sourceMoveDown()
00087 {
00088     if (!source_list->currentItem())
00089         return;
00090     if (source_list->currentItem()->nextSibling() == 0)
00091         return;
00092 
00093     source_list->currentItem()->moveItem(source_list->currentItem()->nextSibling()); 
00094 }
00095 
00096 void FindDocumentationOptions::sourceMoveUp()
00097 {
00098     if (!source_list->currentItem())
00099         return;
00100     if (source_list->currentItem() == source_list->firstChild()) 
00101         return;
00102     
00103     QListViewItem *item = source_list->firstChild();
00104     while (item->nextSibling() != source_list->currentItem())
00105         item = item->nextSibling();
00106     item->moveItem( source_list->currentItem()); 
00107 }
00108 
00109 void FindDocumentationOptions::writeOptions()
00110 {
00111     config = kapp->config();
00112     config->setGroup("DocumentationFinder");
00113     
00114     config->writeEntry("goto_first_match", goto_first_match->isChecked());
00115     
00116     QListViewItemIterator it( source_list );
00117     int i = 0;
00118     while ( it.current() ) 
00119     {
00120         if ( it.current() == m_man_item )
00121         {
00122             config->writeEntry("Manpage",i);
00123             config->writeEntry("ManpageEnabled",m_man_item->isOn());
00124         }
00125         else if ( it.current() == m_info_item )
00126         {
00127             config->writeEntry("Info",i);
00128             config->writeEntry("InfoEnabled",m_info_item->isOn());
00129         }
00130         else if ( it.current() == m_index_item )
00131         {
00132             config->writeEntry("Index",i);
00133             config->writeEntry("IndexEnabled",m_index_item->isOn());
00134         }
00135         else if ( it.current() == m_google_item )
00136         {
00137             config->writeEntry("Google",i);
00138             config->writeEntry("GoogleEnabled",m_google_item->isOn());
00139         }
00140         else if ( it.current() == m_contents_item )
00141         {
00142             config->writeEntry("Contents",i);
00143             config->writeEntry("ContentsEnabled",m_contents_item->isOn());
00144         }
00145         ++it;
00146         ++i;
00147     }  
00148     
00149     config->sync();
00150 }
00151 
00152 void FindDocumentationOptions::readOptions()
00153 {
00154     config = kapp->config();
00155     config->setGroup("DocumentationFinder");
00156     
00157     source_list->clear();
00158     
00159     for(int i = 4; i > -1; --i  )
00160     {
00161         if( config->readPropertyEntry( "Manpage" , 0 ) == i)
00162         {
00163             m_man_item  = new QCheckListItem( source_list, i18n("Manual"), QCheckListItem::CheckBox );
00164             m_man_item->setOn(config->readBoolEntry( "ManpageEnabled" , true));
00165         }
00166         if( config->readPropertyEntry( "Info" , 1 ) == i)
00167         {
00168             m_info_item = new QCheckListItem( source_list, i18n("Info"), QCheckListItem::CheckBox );
00169             m_info_item->setOn(config->readBoolEntry( "InfoEnabled" , true));
00170         }
00171         if( config->readPropertyEntry( "Index" , 2 ) == i)
00172         {
00173             m_index_item = new QCheckListItem( source_list, i18n("Index"), QCheckListItem::CheckBox );
00174             m_index_item->setOn(config->readBoolEntry( "IndexEnabled" , true));
00175         }
00176         if( config->readPropertyEntry( "Google" , 3 ) == i)
00177         {
00178             m_google_item = new QCheckListItem( source_list, i18n("Google"), QCheckListItem::CheckBox );
00179             m_google_item->setOn(config->readBoolEntry( "GoogleEnabled" , false)); 
00180         }
00181         if( config->readPropertyEntry( "Contents" , 4 ) == i)
00182         {
00183             m_contents_item = new QCheckListItem( source_list, i18n("Contents"), QCheckListItem::CheckBox );
00184             m_contents_item->setOn(config->readBoolEntry( "ContentsEnabled" , false)); 
00185         }      
00186     }
00187     
00188     goto_first_match->setChecked(config->readBoolEntry( "goto_first_match" , false));
00189 }
00190 
00191 #include "find_documentation_options.moc"
00192 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:55 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003