KDevelop API Documentation

docutils.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 "docutils.h"
00021 
00022 #include <kurlrequester.h>
00023 #include <kurlcompletion.h>
00024 #include <klineedit.h>
00025 #include <kcombobox.h>
00026 #include <kpopupmenu.h>
00027 #include <klocale.h>
00028 #include <kstringhandler.h>
00029 
00030 #include <kdevpartcontroller.h>
00031 
00032 #include "kdevdocumentationplugin.h"
00033 #include "documentation_part.h"
00034 
00035 QString DocUtils::noEnvURL(const QString &url)
00036 {
00037     return KURLCompletion::replacedPath(url, true, true);
00038 }
00039 
00040 KURL DocUtils::noEnvURL(const KURL &url)
00041 {
00042     QString replaced = KURLCompletion::replacedPath(url.url(), true, true);
00043     KURL kurl(replaced);
00044     kurl.setQuery(url.query());
00045     kurl.setRef(url.ref());
00046     return kurl;
00047 }
00048 
00049 QString DocUtils::envURL(KURLRequester *req)
00050 {
00051     if (req->lineEdit())
00052         return req->lineEdit()->text();
00053     else if (req->comboBox())
00054         return req->comboBox()->currentText();
00055     else
00056         return req->url();
00057 }
00058 
00059 void DocUtils::docItemPopup(DocumentationPart *part, DocumentationItem *docItem,
00060     const QPoint &pos, bool showBookmark, bool showSearch, int titleCol)
00061 {
00062     docItemPopup(part, docItem->text(titleCol), docItem->url(), pos, showBookmark, showSearch);
00063 }
00064 
00065 void DocUtils::docItemPopup(DocumentationPart *part, IndexItem *docItem, const QPoint &pos,
00066     bool showBookmark, bool showSearch)
00067 {
00068     //FIXME: index item can have more than one url, what to do?
00069     KURL url;
00070     if (docItem->urls().count() > 0)
00071         url = docItem->urls().first().second;
00072     docItemPopup(part, docItem->text(), url, pos, showBookmark, showSearch);
00073 }
00074 
00075 void DocUtils::docItemPopup(DocumentationPart *part, const QString &title, const KURL &url,
00076     const QPoint &pos, bool showBookmark, bool showSearch)
00077 {
00078     KPopupMenu menu;
00079     menu.setTitle(i18n("Documentation"));
00080     menu.insertItem(i18n("Open in Current Tab"), 1);
00081     menu.insertItem(i18n("Open in New Tab"), 2);
00082     if (showBookmark)
00083     {
00084         menu.insertSeparator();   
00085         menu.insertItem(i18n("Bookmark This Location"), 3);
00086     }
00087     if (showSearch)
00088     {
00089         menu.insertSeparator();
00090         menu.insertItem(QString("%1: %2").arg(i18n("Search")).arg(KStringHandler::csqueeze(title,20)), 4);
00091     }
00092     
00093     switch (menu.exec(pos))
00094     {
00095         case 1: part->partController()->showDocument(url); break;
00096         case 2: part->partController()->showDocument(url, true); break;
00097         case 3: part->emitBookmarkLocation(title, url); break;
00098         case 4: part->searchInDocumentation(title); break;
00099     }
00100 }
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