KDevelop API Documentation

documentation_widget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Alexander Dymo                                  *
00003  *   cloudtemple@mksat.net                                                 *
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 "documentation_widget.h"
00021 
00022 #include <qlayout.h>
00023 #include <qtoolbox.h>
00024 #include <qlineedit.h>
00025 
00026 #include <kparts/part.h>
00027 #include <klibloader.h>
00028 #include <kurl.h>
00029 #include <klocale.h>
00030 #include <kdebug.h>
00031 #include <kapplication.h>
00032 #include <kconfig.h>
00033 
00034 #include <kdevcore.h>
00035 #include <kdevdocumentationplugin.h>
00036 
00037 #include "documentation_part.h"
00038 #include "contentsview.h"
00039 #include "indexview.h"
00040 #include "searchview.h"
00041 #include "bookmarkview.h"
00042 #include "find_documentation.h"
00043 
00044 DocumentationWidget::DocumentationWidget(DocumentationPart *part)
00045     :QWidget(0, "documentation widget"), m_part(part)
00046 {
00047     QVBoxLayout *l = new QVBoxLayout(this, 0, 0);
00048     
00049     m_tab = new QToolBox(this);
00050     l->addWidget(m_tab);
00051     
00052     m_contents = new ContentsView(this);
00053     m_tab->addItem(m_contents, i18n("Contents"));
00054     
00055     m_index = new IndexView(this);
00056     m_tab->addItem(m_index, i18n("Index"));
00057     
00058     m_finder = new FindDocumentation(this);
00059     m_tab->addItem(m_finder,i18n("Finder"));
00060     
00061     m_search = new SearchView(m_part, this);
00062     m_tab->addItem(m_search, i18n("Search"));
00063     
00064     m_bookmarks = new BookmarkView(this);
00065     m_tab->addItem(m_bookmarks, i18n("Bookmarks"));
00066     
00067     connect(m_tab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
00068 }
00069 
00070 DocumentationWidget::~DocumentationWidget()
00071 {
00072     KConfig *config = kapp->config();
00073     config->setGroup("Documentation");
00074     config->writeEntry("LastPage", m_tab->currentIndex());
00075 }
00076 
00077 void DocumentationWidget::tabChanged(int t)
00078 {
00079     if (!m_tab->item(t))
00080         return;
00081     m_tab->item(t)->setFocus();
00082     if (m_tab->item(t) == m_index)
00083         m_part->emitIndexSelected(m_index->indexBox());
00084 }
00085 
00086 IndexBox *DocumentationWidget::index() const
00087 {
00088     return m_index->indexBox();
00089 }
00090 
00091 void DocumentationWidget::searchInDocumentation()
00092 {
00093     m_tab->setCurrentItem(m_search);
00094     m_search->askSearchTerm();
00095 }
00096 
00097 void DocumentationWidget::searchInDocumentation(const QString &term)
00098 {
00099     m_tab->setCurrentItem(m_search);
00100     m_search->setSearchTerm(term);
00101     m_search->search();
00102 }
00103 
00104 void DocumentationWidget::lookInDocumentationIndex()
00105 {
00106     m_tab->setCurrentItem(m_index);
00107     m_index->askSearchTerm();
00108 }
00109 
00110 void DocumentationWidget::lookInDocumentationIndex(const QString &term)
00111 {
00112     m_tab->setCurrentItem(m_index);
00113     m_index->setSearchTerm(term);
00114     //adymo: let's allow the user to press enter here ;)
00115 //    m_index->searchInIndex();
00116 }
00117 
00118 void DocumentationWidget::findInDocumentation(const QString &term)
00119 {
00120    m_tab->setCurrentItem(m_finder);
00121    m_finder->setSearchTerm(term);
00122    m_finder->startSearch();
00123 }
00124 
00125 void DocumentationWidget::findInDocumentation()
00126 {
00127    m_tab->setCurrentItem(m_finder);
00128    m_finder->search_term->setFocus();
00129 }
00130 
00131 void DocumentationWidget::focusInEvent(QFocusEvent */*e*/)
00132 {
00133     if (m_tab->currentItem())
00134         m_tab->currentItem()->setFocus();
00135 }
00136 
00137 KListView * DocumentationWidget::contents( ) const
00138 {
00139     return m_contents->view();
00140 }
00141 
00142 #include "documentation_widget.moc"
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