KDevelop API Documentation

contentsview.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 "contentsview.h"
00021 
00022 #include <qheader.h>
00023 #include <qlayout.h>
00024 
00025 #include <kdebug.h>
00026 #include <klistview.h>
00027 
00028 #include <kdevpartcontroller.h>
00029 #include <kdevdocumentationplugin.h>
00030 
00031 #include "documentation_widget.h"
00032 #include "documentation_part.h"
00033 #include "docutils.h"
00034 
00035 ContentsView::ContentsView(DocumentationWidget *parent, const char *name)
00036      :QWidget(parent, name), m_widget(parent)
00037 {
00038     QVBoxLayout *cl = new QVBoxLayout(this, 0, 0);
00039     m_view = new KListView(this);
00040     cl->addWidget(m_view);
00041     
00042     m_view->addColumn("Contents");
00043     m_view->header()->hide();
00044     m_view->setResizeMode(QListView::AllColumns);
00045     m_view->setRootIsDecorated(true);
00046     m_view->setSorting(-1);
00047     
00048     connect(m_view, SIGNAL(executed(QListViewItem*, const QPoint&, int )),
00049         this, SLOT(itemExecuted(QListViewItem*, const QPoint&, int )));
00050     connect(m_view, SIGNAL(mouseButtonPressed(int, QListViewItem*, const QPoint&, int )),
00051         this, SLOT(itemMouseButtonPressed(int, QListViewItem*, const QPoint&, int )));
00052 }
00053 
00054 ContentsView::~ContentsView()
00055 {
00056     if (m_widget && m_widget->index())
00057         m_widget->index()->clear();
00058 }
00059 
00060 void ContentsView::itemExecuted(QListViewItem *item, const QPoint &p, int col)
00061 {
00062     DocumentationItem *docItem = dynamic_cast<DocumentationItem*>(item);
00063     if (!docItem)
00064         return;
00065     KURL url = DocUtils::noEnvURL(docItem->url());
00066     if (url.isEmpty() || !url.isValid())
00067         return;
00068     m_widget->part()->partController()->showDocument(url);
00069 }
00070 
00071 void ContentsView::itemMouseButtonPressed(int button, QListViewItem *item, const QPoint &pos, int c)
00072 {
00073     if ((button != Qt::RightButton) || (!item))
00074         return;
00075     DocumentationItem *docItem = dynamic_cast<DocumentationItem*>(item);
00076     if (!docItem)
00077         return;
00078     
00079     DocUtils::docItemPopup(m_widget->part(), docItem, pos, true, true);
00080 }
00081 
00082 void ContentsView::focusInEvent(QFocusEvent */*e*/)
00083 {
00084     m_view->setFocus();
00085 }
00086 
00087 #include "contentsview.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 Tue Feb 22 09:22:39 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003