diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /kate/kpybrowser | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/kpybrowser')
-rw-r--r-- | kate/kpybrowser/Makefile.am | 18 | ||||
-rw-r--r-- | kate/kpybrowser/katepybrowse.desktop | 128 | ||||
-rw-r--r-- | kate/kpybrowser/kpybrowser.cpp | 397 | ||||
-rw-r--r-- | kate/kpybrowser/kpybrowser.desktop | 18 | ||||
-rw-r--r-- | kate/kpybrowser/kpybrowser.h | 69 | ||||
-rw-r--r-- | kate/kpybrowser/pybrowse.xpm | 495 | ||||
-rw-r--r-- | kate/kpybrowser/pybrowse_part.cpp | 157 | ||||
-rw-r--r-- | kate/kpybrowser/pybrowse_part.h | 72 | ||||
-rw-r--r-- | kate/kpybrowser/pybrowsenode.cpp | 209 | ||||
-rw-r--r-- | kate/kpybrowser/pybrowsenode.h | 68 | ||||
-rw-r--r-- | kate/kpybrowser/ui.rc | 8 |
11 files changed, 1639 insertions, 0 deletions
diff --git a/kate/kpybrowser/Makefile.am b/kate/kpybrowser/Makefile.am new file mode 100644 index 0000000..654dacc --- /dev/null +++ b/kate/kpybrowser/Makefile.am @@ -0,0 +1,18 @@ +# set the include path for X, qt and KDE +INCLUDES= $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = katepybrowseplugin.la + +katepybrowseplugin_la_SOURCES = kpybrowser.cpp pybrowsenode.cpp pybrowse_part.cpp +katepybrowseplugin_la_LIBADD = -lkateinterfaces +katepybrowseplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +pluginsdir = $(kde_datadir)/kate/plugins/katepybrowse +plugins_DATA = ui.rc + +kde_services_DATA = katepybrowse.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/katepybrowse.pot + diff --git a/kate/kpybrowser/katepybrowse.desktop b/kate/kpybrowser/katepybrowse.desktop new file mode 100644 index 0000000..8b33b1c --- /dev/null +++ b/kate/kpybrowser/katepybrowse.desktop @@ -0,0 +1,128 @@ +# KDE Config File +[Desktop Entry] +Type=Service +ServiceTypes=Kate/Plugin +X-KDE-Library=katepybrowseplugin +X-Kate-Version=2.5 +Name=Kate Python Browser Plugin +Name[af]=Kate Python Blaaier Inplak +Name[ar]=ملحق متصفح Python لـKate +Name[az]=Kate Python Səyyah Əlavəsi +Name[ca]=Connector del navegador Python per a Kate +Name[cs]=Modul Python prohlížeče pro Kate +Name[cy]=Ategyn porydd Python am Kate +Name[da]=Kate Pythonlæser-plugin +Name[de]=Browser-Modul für Python +Name[el]=Πρόσθετο περιηγητή Python του Kate +Name[eo]=Pitona foliumila kromaĵo por Kodredaktilo +Name[es]=Complemento del navegador Python de Kate +Name[et]=Kate Pythoni brauseri plugin +Name[eu]=Kateren Python arakatzailearen plugina +Name[fa]=وصلۀ مرورگر Kate Python +Name[fi]=Kate Python selain -sovelma +Name[fo]=Kate Python-kagari-ístingur +Name[fr]=Module de navigation en Python pour Kate +Name[fy]=Kate Pyton Blêder Plugin +Name[gl]=Plugin de Navegación por Python para Kate +Name[he]=תוסף דפדפן Python ל־Kate +Name[hi]=के-एटीई पायथन ब्राउज़र प्लगइन +Name[hr]=Python dodatak za Kate +Name[hu]=Kate Python-böngésző bővítőmodul +Name[is]=Kate Python flakk viðbætur +Name[it]=Plugin visualizzatore Python di Kate +Name[ja]=Kate Python ブラウザプラグイン +Name[ka]=Kate-ის პითონის ბროუზერის მოდული +Name[kk]=Kate Python шолғышының плагин модулі +Name[km]=កម្មវិធីជំនួយរបស់កម្មវិធីរុករក Kate Python +Name[lt]=Kate Python naršyklės priedas +Name[mk]=Приклучок за пребарувач на Python во Кате +Name[ms]=Plug masuk Pelungsur Python Kate +Name[nb]=Pythonleser-programtillegg til Kate +Name[nds]=Python-Kiekermoduul för Kate +Name[ne]=केट पाइथन ब्राउजर प्लगइन +Name[nn]=Kate-programtillegg for Python-oversikt +Name[pa]=ਕੇਟ ਪਾਈਥਨ ਝਲਕਾਰਾ ਪਲੱਗਇਨ +Name[pl]=Wtyczka przeglądarki do Pythona do Kate +Name[pt]='Plugin' de Navegação no Python do Kate +Name[pt_BR]=Plug-in de Navegação Python do Kate +Name[ro]=Modul Kate de navigare Python +Name[ru]=Модуль просмотра программ на Python для Kate +Name[sk]=Modul Kate Python prehliadača +Name[sl]=Vstavek za brskanje po Pythonu v Kate +Name[sr]=Прикључак прегледача Python-а за Kate +Name[sr@Latn]=Priključak pregledača Python-a za Kate +Name[sv]=Kates Python-bläddrarinsticksprogram +Name[ta]=கேட் பைதான் உலாவி சொருகுப்பொருள் +Name[tg]=Модули аз назар гузаронидани барнома ба Python барои Kate +Name[th]=ปลั๊กอินบราวเซอร์ไพธอนของ Kate +Name[tr]=Kate Python Tarayıcı Eklentisi +Name[uk]=Втулок навігації Python для Kate +Name[uz]=Kate Python brauzer plagini +Name[uz@cyrillic]=Kate Python браузер плагини +Name[vi]=Bổ sung duyệt Python Kate +Name[xh]=IPython ye Kate yokukhangela iplagi yangaphakathi +Name[zh_CN]=Kate Python 浏览器插件 +Name[zh_TW]=Kate Python 瀏覽外掛程式 +Comment=A Python browser plugin for Kate +Comment[af]='n Python blaaier inplak vir Kate +Comment[ar]=ملحق متصفح Python لـKate +Comment[az]=Kate üçün Python səyyah əlavəsi +Comment[bg]=Приставка за разглеждане на класовете и методите на програми на Питон +Comment[bs]=Python browser plugin za Kate +Comment[ca]=Un connector per a Kate per a navegar dins del codi Python +Comment[cs]=Modul Python prohlížeče pro Kate +Comment[cy]=Ategyn porydd Python am Kate +Comment[da]=Et Pythonlæser-plugin for Kate +Comment[de]=Ein Browser-Modul für Python +Comment[el]=Ένα πρόσθετο περιηγητή Python για το Kate +Comment[eo]=Pitona foliumila kromaĵo por Kodredaktilo +Comment[es]=Un complemento de un navegador Python para Kate +Comment[et]=Pythoni brauseri plugin Kate jaoks +Comment[eu]=Python-en arakatzaile plugina Katerentzat +Comment[fa]=وصلۀ مرورگر Python برای Kate +Comment[fi]=Python selainsovelma Katelle +Comment[fo]=Ein Python-kagari-ístingur til Kate. +Comment[fr]=Un module externe de navigateur en Python pour Kate +Comment[fy]=In Pyton-blêderplugin foar Kate +Comment[ga]=Breiseán brabhsála Python le haghaidh Kate +Comment[gl]=Un plugin de navegación por Python para Kate +Comment[he]=תוסף דפדפן Python ל־Kate +Comment[hi]=के-एटीई के लिए पायथन ब्राउज़र प्लगइन +Comment[hr]=Python preglednički dodatak za Kate +Comment[hu]=Python-böngésző bővítőmodul a Kate-hez +Comment[is]=Python flakk viðbætur fyrir Kate +Comment[it]=Un plugin di visualizzazione di Python per Kate +Comment[ja]=Kate の Python ブラウザプラグイン +Comment[ka]=პითონის ბრაუზერის მოდული Kate-სთვის +Comment[kk]=Python бағдарламаларды көрсету Kate-тің плагин модулі +Comment[km]=កម្មវិធីជំនួយរបស់កម្មវិធីរុករក Python សម្រាប់ Kate +Comment[lt]=Python naršyklės priedas, skirtas Kate +Comment[mk]=Приклучок за пребарувач на Python во Кате +Comment[ms]=Plug masuk Pelungsur Python Kate +Comment[nb]=Et programtillegg for Pythonleseren til Kate +Comment[nds]=En Python-Kiekermoduul för Kate +Comment[ne]=केटका लागि एउटा पाइथन ब्राउजर प्लगइन +Comment[nl]=Een Python-browserplugin voor Kate +Comment[nn]=Ei Python-oversikt til Kate +Comment[pa]=ਕੇਟ ਲਈ ਪਾਈਥਨ ਝਲਕਾਰਾ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka przeglądarki Pythona do Kate +Comment[pt]=Um 'plugin' de navegação no Python para o Kate +Comment[pt_BR]=Um Plugin de navegação Python para o Kate +Comment[ro]=Un modul de navigare Python pentru Kate +Comment[ru]=Модуль просмотра программ на Python для Kate +Comment[sk]=Python modul prehliadača pre Kate +Comment[sl]=Vstavek za brskanje po Pythonu v Kate +Comment[sr]=Прикључак прегледача Python-а за Kate +Comment[sr@Latn]=Priključak pregledača Python-a za Kate +Comment[sv]=Python-bläddrarinsticksprogram för Kate +Comment[ta]=கேட்-டுக்கான பைதான் உலாவி சொருகுப்பொருள் +Comment[tg]=Модули аз назар гузаронидани барнома ба Python барои Kate +Comment[th]=ปลั๊กอินบราวเซอร์ไพธอนสำหรับ Kate +Comment[tr]=Kate için Python tarayıcı programı +Comment[uk]=Втулок навігації Python для Kate +Comment[uz]=Kate uchun Python brauzer vositasi +Comment[uz@cyrillic]=Kate учун Python браузер воситаси +Comment[vi]=Bổ sung duyệt Python cho Kate +Comment[xh]=Isijongi se Python yeplagi yangaphakathi se Kate +Comment[zh_CN]=为 Kate 提供的 Python 浏览器插件 +Comment[zh_TW]=Kate 的 Python 瀏覽外掛程式 diff --git a/kate/kpybrowser/kpybrowser.cpp b/kate/kpybrowser/kpybrowser.cpp new file mode 100644 index 0000000..9023e65 --- /dev/null +++ b/kate/kpybrowser/kpybrowser.cpp @@ -0,0 +1,397 @@ +/*************************************************************************** + kpybrowser.cpp - description + ------------------- + begin : Fri Aug 24 15:11:58 MST 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "kpybrowser.h" +#include <qheader.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <qregexp.h> + +#include "kpybrowser.moc" + +#include <iostream> + +static const char *container_xpm[] = { + "16 16 119 2", + " c None", + ". c #020202", + "+ c #484848", + "@ c #141414", + "# c #CBCBCB", + "$ c #E9E9E9", + "% c #2F2F2F", + "& c #3E3E3E", + "* c #006B9E", + "= c #003D5A", + "- c #757575", + "; c #A4A4A4", + "> c #727272", + ", c #282828", + "' c #C1E1ED", + ") c #D3EDF6", + "! c #79BFD6", + "~ c #E4E4E4", + "{ c #202121", + "] c #3CB9ED", + "^ c #3AA3C5", + "/ c #77BCD6", + "( c #82C3D9", + "_ c #0873A5", + ": c #003C5B", + "< c #464646", + "[ c #1E1E1E", + "} c #19AFEE", + "| c #0787B6", + "1 c #38A2C5", + "2 c #5DB1D0", + "3 c #76BBD5", + "4 c #81C2D8", + "5 c #85C4D9", + "6 c #0770A1", + "7 c #4F4F4F", + "8 c #169ACB", + "9 c #106CA1", + "0 c #127CAD", + "a c #0784B2", + "b c #56B0CD", + "c c #72B9D4", + "d c #91C9DB", + "e c #3F3F3F", + "f c #2B2B2B", + "g c #1380B2", + "h c #0B5482", + "i c #0E5E91", + "j c #0E6597", + "k c #116FA0", + "l c #127FB1", + "m c #58AECD", + "n c #70B8D3", + "o c #454545", + "p c #FCFCFC", + "q c #E9E4E4", + "r c #8AA9B9", + "s c #296C8E", + "t c #0E5C8D", + "u c #0F6698", + "v c #1175A4", + "w c #404040", + "x c #444444", + "y c #F6F6F6", + "z c #F1F1F1", + "A c #EBEBEB", + "B c #EAEAEA", + "C c #DBD7D6", + "D c #81A0B0", + "E c #286C8F", + "F c #0F6596", + "G c #1172A4", + "H c #57A1C0", + "I c #424242", + "J c #EEEEEE", + "K c #E6E6E6", + "L c #E1E1E1", + "M c #DCDCDC", + "N c #D5D5D5", + "O c #D7D7D7", + "P c #CBC9C8", + "Q c #88A6B5", + "R c #276C8C", + "S c #276892", + "T c #363636", + "U c #C4C4C4", + "V c #DFDFDF", + "W c #DEDEDE", + "X c #DBDBDB", + "Y c #D6D6D6", + "Z c #D1D1D1", + "` c #CCCCCC", + " . c #C5C5C5", + ".. c #BFBFBF", + "+. c #C1BEBE", + "@. c #6E6D6D", + "#. c #686868", + "$. c #C0C0C0", + "%. c #CECECE", + "&. c #CACACA", + "*. c #C6C6C6", + "=. c #BBBBBB", + "-. c #B6B6B6", + ";. c #AEAEAE", + ">. c #323232", + ",. c #606060", + "'. c #AFAFAF", + "). c #B5B5B5", + "!. c #B0B0B0", + "~. c #AAAAAA", + "{. c #6C6B6B", + "]. c #2E2E2E", + "^. c #585858", + "/. c #9D9D9D", + "(. c #A7A7A7", + "_. c #6A6969", + ":. c #393939", + "<. c #292929", + "[. c #3A3835", + " . + ", + " @ # $ + + % ", + " & * = - ; # $ + . + > . ", + " , ' ) ! * = - ; # ~ $ $ . ", + " { ] ^ / ' ) ( _ : - ; # $ < ", + " [ } | 1 2 3 4 ' ) 5 6 = - 7 ", + " [ 8 9 0 a | 1 b c d ' ) ! e ", + " f g h i j k l | | 1 m n ' e ", + " o p q r s h t u v 0 | | n w ", + " x y z A B C D E h i F G H w ", + " I J B K L M N O P Q R h S w ", + " T U V W X Y Z ` ... .+.@.o ", + " . T #.$.%.&.*.$.=.-.;.@.< ", + " . >.,.'.=.).!.~.{.o ", + " . ].^./.(._.:.", + " . <.[. " +}; + +void +getOpenNodes (QValueList < QString > *open_nodes, PyBrowseNode * node) +{ + if (node == NULL) + return; + if (node->isOpen ()) + { + open_nodes->append (node->getQualifiedName ()); + } + + getOpenNodes (open_nodes, + dynamic_cast < PyBrowseNode * >(node->firstChild ())); + getOpenNodes (open_nodes, + dynamic_cast < PyBrowseNode * >(node->nextSibling ())); +} + + +KPyBrowser::KPyBrowser (QWidget * parent, const char *name): +KListView (parent, name) +{ + + addColumn(i18n("Name")); + header ()->hide (); + class_root = + new PyBrowseNode (this, QString ("Classes"), i18n("Classes"), + PYOTHER); + class_root->setPixmap (0, QPixmap (container_xpm)); + function_root = + new PyBrowseNode (this, QString ("Globals"), i18n("Globals"), + PYOTHER); + function_root->setPixmap (0, QPixmap (container_xpm)); + setRootIsDecorated (1); + connect (this, SIGNAL (executed (QListViewItem *)), this, + SLOT (nodeSelected (QListViewItem *))); + setTooltipColumn (1); + setShowToolTips (1); + tooltip = new KPBToolTip (this); +} + +KPyBrowser::~KPyBrowser () +{ +} + +void +KPyBrowser::nodeSelected (QListViewItem * node) +{ + PyBrowseNode *browse_node = dynamic_cast < PyBrowseNode * >(node); + + if (!browse_node) + { + return; + } + + QString method_name; + int line_no; + + line_no = browse_node->getLine(); + method_name = browse_node->getName(); + if (browse_node->getType () == PYCLASS) + { + method_name = QString ("class ") + browse_node->getName (); + } + else if (browse_node->getType () == PYMETHOD + || browse_node->getType () == PYFUNCTION) + { + method_name = QString ("def ") + browse_node->getName (); + } + emit selected(method_name, line_no); +} + +void +KPyBrowser::parseText (QString & pytext) +{ + QRegExp class_rx (QString ("^class [a-zA-Z0-9_,\\s\\(\\).]+:")); + QRegExp function_rx (QString ("^def [a-zA-Z_]+[^#]*:")); + QRegExp method_rx (QString ("[\\s]+def [a-zA-Z_]+[^#]*:")); + + int paren_i; + QStringList lines = QStringList::split ("\n", pytext, TRUE); + QStringList::Iterator iter; + QString *line; + QString class_name, method_name, function_name, class_sig, method_sig, + function_sig; + PyBrowseNode *last_class_node = NULL; + PyBrowseNode *last_method_node = NULL; + PyBrowseNode *last_function_node = NULL; + + QValueList < QString > open_nodes; + getOpenNodes (&open_nodes, class_root); + getOpenNodes (&open_nodes, function_root); + + + int line_no, state = 0; + + if (class_root != NULL) + { + delete class_root; + } + if (function_root != NULL) + { + delete function_root; + } + class_root = + new PyBrowseNode (this, QString ("Classes"), i18n("Classes"), + PYOTHER); + class_root->setPixmap (0, QPixmap (container_xpm)); + function_root = + new PyBrowseNode (this, QString ("Globals"), i18n("Globals"), + PYOTHER); + function_root->setPixmap (0, QPixmap (container_xpm)); + node_dict.insert (class_root->getQualifiedName (), class_root); + node_dict.insert (function_root->getQualifiedName (), function_root); + + + line_no = 0; + + for (iter = lines.begin(); iter != lines.end(); ++iter) + { + line_no++; + line = &(*iter); + if (class_rx.search(*line) >= 0) + { + //KMessageBox::information(this, *line, QString("Found class on line %1").arg(line_no)); + //strip out the beginning class and ending colon + class_sig = line->stripWhiteSpace ().mid (6); + class_sig = class_sig.left (class_sig.length () - 1); + paren_i = class_sig.find ("("); + class_name = class_sig.left (paren_i); + + last_class_node = + new PyBrowseNode (class_root, class_name, class_sig, PYCLASS); + last_class_node->setLine (line_no); + last_class_node->setClass (class_name); + node_dict.insert (last_class_node->getQualifiedName (), + last_class_node); + state = 1; + } + if ((method_rx.search(*line) >= 0) && (state == 1)) + { + //strip off the leading def and the ending colon + method_sig = line->stripWhiteSpace ().mid (4); + method_sig = method_sig.left (method_sig.find (":")); + paren_i = method_sig.find ("("); + method_name = method_sig.left (paren_i); + last_method_node = + new PyBrowseNode (last_class_node, method_name, method_sig, + PYMETHOD); + last_method_node->setLine (line_no); + last_method_node->setClass (last_class_node->getClass ()); + node_dict.insert (last_method_node->getQualifiedName (), + last_method_node); + } + if ((function_rx.search(*line) >= 0)) + { + //KMessageBox::information(this, *line, QString("Found function on line %1").arg(line_no)); + function_sig = line->stripWhiteSpace ().mid (4); + function_sig = function_sig.left (function_sig.find (":")); + paren_i = function_sig.find ("("); + function_name = function_sig.left (paren_i); + last_function_node = + new PyBrowseNode (function_root, function_name, function_sig, + PYFUNCTION); + last_function_node->setLine (line_no); + node_dict.insert (last_function_node->getQualifiedName (), + last_function_node); + state = 0; + } + } + + //now go through the list of old open nodes and open them in the new + //tree. For each node name in the open_nodes list, attempt to find that + //node and in the new dict and open it. + QValueList<QString>::iterator it; + PyBrowseNode *tmp_node; + for (it=open_nodes.begin(); it != open_nodes.end(); ++it) + { + tmp_node = node_dict[(*it)]; + if (tmp_node) + { + tmp_node->setOpen(1); + } + } + +} + + +void +KPyBrowser::tip (const QPoint & p, QRect & r, QString & str) +{ + QListViewItem *item = (QListViewItem *) itemAt (p); + if (item == NULL) + { + str = ""; + return; + } + r = itemRect (item); + //r.setY(r.y() + 10); + + PyBrowseNode *browse_node = dynamic_cast < PyBrowseNode * >(item); + + if (browse_node) + { + if (r.isValid ()) + str = browse_node->getSig (); + else + str = ""; + } + else + { + str = item->text (0); + } +} + +///////////////////////////////////////////////////////////////////// +// KateFileList::KFLToolTip implementation + +KPyBrowser::KPBToolTip::KPBToolTip (QWidget * parent):QToolTip (parent) +{ +} + +void +KPyBrowser::KPBToolTip::maybeTip (const QPoint & p) +{ + QString str; + QRect r; + + ((KPyBrowser *) parentWidget ())->tip (p, r, str); + + if (!str.isEmpty () && r.isValid ()) + tip (r, str); +} diff --git a/kate/kpybrowser/kpybrowser.desktop b/kate/kpybrowser/kpybrowser.desktop new file mode 100644 index 0000000..c045dfc --- /dev/null +++ b/kate/kpybrowser/kpybrowser.desktop @@ -0,0 +1,18 @@ +# KDE Config File +[Desktop Entry] +Type=Application +Exec=kpybrowser -caption "%c" %i %m +Icon=kpybrowser +Comment= +Terminal=false +Name=KPyBrowser +Name[cy]=KPyPorydd +Name[eo]=KPyFoliumilo +Name[fo]=KPyKagari +Name[fy]=KPyBlêder +Name[hi]=के-पीवाय-ब्राउज़र +Name[ne]=केपीवाई ब्राउजर +Name[sv]=Python-bläddrare +Name[ta]=KPyஉலாவி +Name[th]=บราวเซอร์ไพธอน +Name[tr]=KPy Tarayıcı diff --git a/kate/kpybrowser/kpybrowser.h b/kate/kpybrowser/kpybrowser.h new file mode 100644 index 0000000..ae49d3c --- /dev/null +++ b/kate/kpybrowser/kpybrowser.h @@ -0,0 +1,69 @@ +/*************************************************************************** + kpybrowser.h - description + ------------------- + begin : Fri Aug 24 15:11:58 MST 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef KPYBROWSER_H +#define KPYBROWSER_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <klistview.h> +#include <qstring.h> +#include <qvaluelist.h> +#include <qtooltip.h> +#include <qdict.h> +#include "pybrowsenode.h" + + +/** KPyBrowser is the base class of the project */ +class KPyBrowser : public KListView +{ + Q_OBJECT + public: + /** construtor */ + KPyBrowser(QWidget* parent=0, const char *name=0); + /** destructor */ + ~KPyBrowser(); + void parseText(QString &pytext); + + //used by KPBToolTip to dynamically create the needed tooltip + void tip (const QPoint &p, QRect &r, QString &str); + + private: + PyBrowseNode *class_root, *function_root; + + //create a mapping of names to nodes + QDict<PyBrowseNode> node_dict; + + public slots: + void nodeSelected(QListViewItem *node); + signals: + void selected(QString, int); + private: + class KPBToolTip : public QToolTip + { + public: + KPBToolTip(QWidget *parent); + protected: + void maybeTip( const QPoint & ); + }; + KPBToolTip* tooltip; +}; + +#endif diff --git a/kate/kpybrowser/pybrowse.xpm b/kate/kpybrowser/pybrowse.xpm new file mode 100644 index 0000000..dc0b4c5 --- /dev/null +++ b/kate/kpybrowser/pybrowse.xpm @@ -0,0 +1,495 @@ +#ifndef PYBROWSE_XPM + +static const char * pybrowse_xpm[] = { +"34 34 454 2", +" c None", +". c #90826F", +"+ c #8D7F6C", +"@ c #897C6A", +"# c #857968", +"$ c #817666", +"% c #7D7364", +"& c #7A7062", +"* c #766D60", +"= c #726A5D", +"- c #6E675B", +"; c #6B6459", +"> c #676157", +", c #635E55", +"' c #5F5B53", +") c #5B5851", +"! c #848484", +"~ c #8E816D", +"{ c #C9C9C9", +"] c #C1C1C1", +"^ c #BABABA", +"/ c #ABAAAA", +"( c #8F8F8E", +"_ c #7B7B7A", +": c #616161", +"< c #8C7F6C", +"[ c #FFFFFF", +"} c #FEFEFE", +"| c #F8F8F8", +"1 c #EAEAE9", +"2 c #D1D1D1", +"3 c #A6A6A6", +"4 c #929292", +"5 c #000000", +"6 c #8A7D6B", +"7 c #FDFDFD", +"8 c #F5F5F5", +"9 c #E9E9E9", +"0 c #C3C2C2", +"a c #757575", +"b c #878787", +"c c #887B69", +"d c #DCDBD9", +"e c #FAFAFA", +"f c #ECECEC", +"g c #666666", +"h c #867968", +"i c #9D9D9D", +"j c #FBFBFB", +"k c #575757", +"l c #847867", +"m c #4E4E4E", +"n c #E0E0E0", +"o c #817665", +"p c #C6C6C6", +"q c #7F7464", +"r c #FCFCFC", +"s c #4D4D4D", +"t c #1A1A1A", +"u c #2B2B2B", +"v c #474747", +"w c #737373", +"x c #6A6A6A", +"y c #7D7263", +"z c #C8C8C8", +"A c #D9D8D6", +"B c #4D641F", +"C c #EEEEEE", +"D c #D6D5D3", +"E c #C0C0BB", +"F c #B5B3AC", +"G c #9D9A90", +"H c #837F7A", +"I c #726F6D", +"J c #5C5957", +"K c #656565", +"L c #7A6F60", +"M c #587421", +"N c #5E7D22", +"O c #5F7E22", +"P c #8EAA36", +"Q c #9AB646", +"R c #8AAE26", +"S c #728A2A", +"T c #96AE46", +"U c #869E52", +"V c #E8E8E8", +"W c #DEDEDE", +"X c #CECDCB", +"Y c #BCBCBA", +"Z c #AFAAA3", +"` c #8C8B81", +" . c #706C69", +".. c #494743", +"+. c #5E6A42", +"@. c #74902E", +"#. c #B2D252", +"$. c #729222", +"%. c #C6DE6A", +"&. c #F6FACE", +"*. c #BADA4E", +"=. c #6A8A26", +"-. c #E7EFB3", +";. c #A2C646", +">. c #CADE82", +",. c #9ABE42", +"'. c #F3F3F3", +"). c #E9E9E8", +"!. c #DBD9D6", +"~. c #CDCBC8", +"{. c #C5C0B3", +"]. c #ACA79F", +"^. c #89827B", +"/. c #312F2B", +"(. c #5D7C21", +"_. c #79952F", +":. c #AEC272", +"<. c #F2F5C6", +"[. c #5A761E", +"}. c #769626", +"|. c #96B24A", +"1. c #86AE22", +"2. c #B6D656", +"3. c #BEDA56", +"4. c #667E1A", +"5. c #8AAE36", +"6. c #86A632", +"7. c #E2EDA6", +"8. c #96B646", +"9. c #E2E0DD", +"0. c #EDEAE6", +"a. c #E8E5E1", +"b. c #E7E3DC", +"c. c #D3CFC9", +"d. c #C6C3BB", +"e. c #BBB6AD", +"f. c #928C81", +"g. c #5C7A21", +"h. c #718D28", +"i. c #A6C256", +"j. c #A2BA66", +"k. c #96BE26", +"l. c #72921E", +"m. c #565A32", +"n. c #B19549", +"o. c #926616", +"p. c #524616", +"q. c #D6E696", +"r. c #7EA226", +"s. c #769232", +"t. c #9ABE2A", +"u. c #7AA226", +"v. c #DBD6D1", +"w. c #E7E2DC", +"x. c #E8E2DA", +"y. c #E0DAD2", +"z. c #CFC9C1", +"A. c #CBC6BC", +"B. c #A1998D", +"C. c #5B7921", +"D. c #B2CE62", +"E. c #9ABE36", +"F. c #A6BE62", +"G. c #AECA56", +"H. c #4A4E16", +"I. c #E1DEB0", +"J. c #7A6E2A", +"K. c #966E16", +"L. c #4E6A1E", +"M. c #6A862E", +"N. c #8AA636", +"O. c #7A9A1E", +"P. c #C2D676", +"Q. c #CEE672", +"R. c #C2D286", +"S. c #A2C63A", +"T. c #729A2A", +"U. c #627A1E", +"V. c #525B40", +"W. c #D9D4CB", +"X. c #DED6CB", +"Y. c #CAC3B5", +"Z. c #A99F8D", +"`. c #96BA3E", +" + c #26320E", +".+ c #3E4E1A", +"++ c #D2E68A", +"@+ c #9EBE46", +"#+ c #96AE56", +"$+ c #CEE282", +"%+ c #423E0E", +"&+ c #96C226", +"*+ c #C6E262", +"=+ c #829652", +"-+ c #AEBA82", +";+ c #8EBA2A", +">+ c #AAD226", +",+ c #628222", +"'+ c #A2CE26", +")+ c #5A6A42", +"!+ c #C8C1B8", +"~+ c #D1C8BA", +"{+ c #AEA18E", +"]+ c #AECA62", +"^+ c #A6C646", +"/+ c #9AAA66", +"(+ c #BEDA62", +"_+ c #6A862A", +":+ c #9AB64E", +"<+ c #628622", +"[+ c #628626", +"}+ c #CEE284", +"|+ c #EEF2BA", +"1+ c #9EC62A", +"2+ c #7A9E22", +"3+ c #8AB22A", +"4+ c #7A9A22", +"5+ c #4B621A", +"6+ c #D2CABD", +"7+ c #989898", +"8+ c #E6DBCC", +"9+ c #DBD1C0", +"0+ c #B4A791", +"a+ c #597622", +"b+ c #82A23A", +"c+ c #AAC65A", +"d+ c #CAE27A", +"e+ c #9EB65A", +"f+ c #86A23A", +"g+ c #F1F4C5", +"h+ c #EAF2B6", +"i+ c #9EBE52", +"j+ c #AABE6E", +"k+ c #96B63A", +"l+ c #AAD22E", +"m+ c #A2B652", +"n+ c #8EAE2E", +"o+ c #6A8E26", +"p+ c #6A8E22", +"q+ c #92B626", +"r+ c #769A26", +"s+ c #627E1E", +"t+ c #9ECA2A", +"u+ c #7A924A", +"v+ c #C2B9AC", +"w+ c #DDD2C3", +"x+ c #E4D8C6", +"y+ c #DCD1BC", +"z+ c #B5A58E", +"A+ c #4D651B", +"B+ c #A6C642", +"C+ c #82A222", +"D+ c #F2F6C2", +"E+ c #526222", +"F+ c #BEDA5A", +"G+ c #42561A", +"H+ c #A6CE26", +"I+ c #5E8226", +"J+ c #668E26", +"K+ c #4A611A", +"L+ c #BDB2A3", +"M+ c #D6CBB8", +"N+ c #E3D7C2", +"O+ c #DED0BB", +"P+ c #B4A48B", +"Q+ c #4B631A", +"R+ c #4A621A", +"S+ c #4E661E", +"T+ c #66821E", +"U+ c #5E7226", +"V+ c #586826", +"W+ c #576923", +"X+ c #92BA26", +"Y+ c #729A26", +"Z+ c #5E761A", +"`+ c #92BA2A", +" @ c #6E9626", +".@ c #465E1A", +"+@ c #7EA222", +"@@ c #7A9E26", +"#@ c #82AA26", +"$@ c #4A601A", +"%@ c #E1D4BD", +"&@ c #E6D6BD", +"*@ c #B8A58B", +"=@ c #526921", +"-@ c #6A8636", +";@ c #56721E", +">@ c #627A1A", +",@ c #425216", +"'@ c #9EC626", +")@ c #6E962A", +"!@ c #AAD22A", +"~@ c #627E22", +"{@ c #8AB62A", +"]@ c #7EA626", +"^@ c #52662A", +"/@ c #939393", +"(@ c #E4D4B9", +"_@ c #B8A387", +":@ c #525E3A", +"<@ c #5A7622", +"[@ c #4A621E", +"}@ c #6E922A", +"|@ c #526A22", +"1@ c #465A26", +"2@ c #5E7E22", +"3@ c #9ABE26", +"4@ c #7B7B7B", +"5@ c #D2C2A7", +"6@ c #E2D1B3", +"7@ c #BEA989", +"8@ c #555047", +"9@ c #A5A5A5", +"0@ c #CACACA", +"a@ c #C5C5C4", +"b@ c #C4C3C0", +"c@ c #C4C1BE", +"d@ c #C3C0BA", +"e@ c #C2BDB6", +"f@ c #465A1A", +"g@ c #729622", +"h@ c #AED626", +"i@ c #5A6E32", +"j@ c #CCBB9F", +"k@ c #DECBAC", +"l@ c #BCA683", +"m@ c #5C564D", +"n@ c #BCBCBC", +"o@ c #EBEBEB", +"p@ c #E6E4E1", +"q@ c #E5E1DD", +"r@ c #E4DFDA", +"s@ c #E3DED5", +"t@ c #E0DBD3", +"u@ c #D8D1C7", +"v@ c #C8C1B6", +"w@ c #BEB6AB", +"x@ c #769A22", +"y@ c #82A62A", +"z@ c #BEAC92", +"A@ c #D7C4A6", +"B@ c #BAA27F", +"C@ c #5C564E", +"D@ c #C7C7C7", +"E@ c #FAF8F7", +"F@ c #F7F3EE", +"G@ c #F6F1EB", +"H@ c #F5EEE6", +"I@ c #F2EDE3", +"J@ c #F1EADE", +"K@ c #ECE3D7", +"L@ c #E2D9CB", +"M@ c #DDD3C4", +"N@ c #D2C7B7", +"O@ c #516822", +"P@ c #D4E398", +"Q@ c #526A1A", +"R@ c #7A9622", +"S@ c #5A7A22", +"T@ c #A2CA26", +"U@ c #6E8E1E", +"V@ c #B6A389", +"W@ c #D3BD9C", +"X@ c #BBA27F", +"Y@ c #5A554D", +"Z@ c #FBF8F6", +"`@ c #F8F4ED", +" # c #F7F1E8", +".# c #F5EFE6", +"+# c #F4EDE1", +"@# c #F3EADE", +"## c #F1E7D8", +"$# c #EFE4D2", +"%# c #EDE2CE", +"&# c #E5D8C4", +"*# c #506722", +"=# c #567222", +"-# c #B3A083", +";# c #CFB998", +"># c #BCA17A", +",# c #58544C", +"'# c #F9F5F0", +")# c #F3EBDC", +"!# c #F2E8D9", +"~# c #F1E6D4", +"{# c #F0E5D1", +"]# c #EFE1CC", +"^# c #EBDBC4", +"/# c #D5E29D", +"(# c #668A22", +"_# c #B29D7F", +":# c #CFB590", +"<# c #BBA077", +"[# c #56524B", +"}# c #F8F3EB", +"|# c #F5EEE4", +"1# c #F0E2CF", +"2# c #EFE2CC", +"3# c #EEDEC7", +"4# c #EAD9C1", +"5# c #769E26", +"6# c #B29C7F", +"7# c #BB9C73", +"8# c #545049", +"9# c #F3EADC", +"0# c #F2E8D7", +"a# c #ECDAC1", +"b# c #596E2D", +"c# c #C0DC62", +"d# c #6A8242", +"e# c #B39E80", +"f# c #D0B691", +"g# c #B99D6F", +"h# c #524E48", +"i# c #F2EEE6", +"j# c #F2EADE", +"k# c #EEEADE", +"l# c #EEE6DA", +"m# c #F2E2CE", +"n# c #EEE2CE", +"o# c #EAE2D2", +"p# c #EEDECA", +"q# c #E8D8C0", +"r# c #6A8A22", +"s# c #96C222", +"t# c #A79275", +"u# c #BBA382", +"v# c #D3B994", +"w# c #BA9A6C", +"x# c #504C47", +"y# c #C6C2B6", +"z# c #C8C1B7", +"A# c #C7BFB4", +"B# c #C6BBAB", +"C# c #C6B9A9", +"D# c #C6B8A3", +"E# c #C5B7A0", +"F# c #C4B49D", +"G# c #C4B299", +"H# c #C3B296", +"I# c #C3AE92", +"J# c #C4AD8F", +"K# c #C2AB8B", +"L# c #C1AA86", +"M# c #C0A583", +"N# c #BEA481", +"O# c #BFA37C", +"P# c #BEA279", +"Q# c #BE9E75", +"R# c #BC9F71", +"S# c #BC9C6D", +"T# c #9C7F55", +"U# c #4E4B46", +" . + @ # $ % & * = - ; > , ' ) ! ", +" ~ { { { { { { { { { ] ^ / ( _ ! : ", +" < { [ [ [ [ [ [ [ [ } | 1 2 3 ! 4 5 ", +" 6 { [ [ [ [ [ [ [ [ } 7 8 9 0 a { b 5 ", +" c { [ d 5 [ [ [ d 5 } [ [ e f g [ { b 5 ", +" h { [ 5 i [ [ 5 i [ [ [ j k [ [ { b 5 ", +" l { [ [ i [ [ [ [ i } [ [ [ [ m n [ [ { b 5 ", +" o { [ [ [ [ [ [ [ [ } [ [ [ [ m p n [ [ { 4 : ", +" q { [ [ } 7 7 r r 7 r } [ [ [ s t t u v : w x ! ", +" y z 7 A B B B B B B C | 7 } [ C D E F G H I J K ", +" L M N O P Q R S T U O O C | 7 7 V W X Y Z ` ... ", +" +.@.#.$.%.&.*.=.-.;.>.,.O O C '.f ).!.~.{.].^./. ", +" (.N (._.:.<.[.}.|.1.2.3.4.5.6.7.8.O 9.0.a.b.c.d.e.f./. ", +" (.(.g.h.i.j.k.l.m.n.o.p.}.q.<.r.2.2.s.t.u.O v.w.x.y.z.A.B./. ", +"C.(.D.D.;.<.E.F.<.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.D 5 X.Y.Z./. ", +"(.`. +.+P ++@+#+$+2.H.%+ +H.O.&+*+R =+-+;+>+,+'+)+!+5 i ~+{+/. ", +"B ]+i.`.^+/+<.(+_+:+s.H.H.<+[+}+<.(+#+|+1+2+3+,+4+5+6+7+8+9+0+/. ", +" a+b+c+d+e+>.f+g+h+i+j+k+%.g+l+m+n+o+p+q+$.r+s+t+u+v+w+x+y+z+/. ", +" A+k.<.B+4+C+f+d+$+]+D+>.E+F+1+G+H+q+I+H+H+J+q+t+K+L+M+N+O+P+/. ", +" Q+O.[.R+R+S+T+E+U+V+W+O.l.X+Y+Z+Y+L.`+ @.@+@@@#@$@5 %@&@*@/. ", +" 5+=@&+-@&+;@&+r+>@;@,@'@Y+4+1.)@!@~@{@]@.+u.^@ /@(@_@/. ", +" 5+>@>@:@<@[@}@~@|@1@2@2@S+[.3@k.s+'@B 4@5@6@7@/. ", +" 8@9@0@a@b@c@d@e@f@f@f@R g@h@I+I+s+#@i@5+j@k@l@/. ", +" m@n@o@p@q@r@s@t@u@v@w@i@f@g@Z+h@x@y@2@f@z@A@B@/. ", +" C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@f@V@W@X@/. ", +" Y@{ Z@`@ #.#+#@###$#%#&#*#o+R h@u.@@=#f@-#;#>#/. ", +" ,#{ '# #.#+#)#!#~#{#]#^#*#/#(#2+C+h@ @f@_#:#<#/. ", +" [#{ }#|#+#)#!#~#1#2#3#4#*#}@<@r+J+5#=+f@6#:#7#/. ", +" 8#{ #+#9#0#~#1#]#3#a#b#5#c#g@h@]@}@d#B e#f#g#/. ", +" h#{ i#j#k#l#m#n#o#p#q#*#&+r#u.]@3+s#B t#u#v#w#/. ", +" x#y#z#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#T#/. ", +" U#/././././././././././././././././././././././. ", +" ", +" "}; + +#endif + diff --git a/kate/kpybrowser/pybrowse_part.cpp b/kate/kpybrowser/pybrowse_part.cpp new file mode 100644 index 0000000..d8b7551 --- /dev/null +++ b/kate/kpybrowser/pybrowse_part.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + pybrowse_part.cpp - description + ------------------- + begin : Tue Aug 28 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "pybrowse_part.h" +#include "pybrowse_part.moc" +#include "kpybrowser.h" +#include "pybrowse.xpm" + +#include <kgenericfactory.h> +#include <kaction.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kmessagebox.h> +#include <qimage.h> +#include <kdockwidget.h> + +K_EXPORT_COMPONENT_FACTORY( katepybrowseplugin, KGenericFactory<KatePluginPyBrowse>( "katepybrowse" ) ) + +PluginViewPyBrowse::PluginViewPyBrowse (Kate::MainWindow *w) + : win (w) +{ + (void) new KAction ( i18n("Update Python Browser"), 0, this, + SLOT( slotUpdatePyBrowser() ), actionCollection(), + "python_update_pybrowse" ); + + //set up the menus + setInstance(new KInstance("kate")); + setXMLFile( "plugins/katepybrowse/ui.rc" ); + win->guiFactory()->addClient(this); + + //create a python head pixmap for the tab + QPixmap *py_pixmap = new QPixmap(pybrowse_xpm); + QImage py_image = py_pixmap->convertToImage().smoothScale(20, 20); + py_pixmap->convertFromImage(py_image); + + //create the browser and put it into a dockwidget using kate's tool view manager + + Kate::ToolViewManager *tool_view_manager = win->toolViewManager(); + my_dock = tool_view_manager->createToolView("kate_plugin_kpybrowser", Kate::ToolViewManager::Left, (*py_pixmap), i18n("Python Browser")); + kpybrowser = new KPyBrowser(my_dock, "kpybrowser"); + + connect(kpybrowser, SIGNAL(selected(QString, int)), this, SLOT(slotSelected(QString, int))); +} + +PluginViewPyBrowse::~PluginViewPyBrowse () +{ + win->guiFactory()->removeClient (this); + delete my_dock; +} + + +void PluginViewPyBrowse::slotSelected(QString name, int line) +{ + //TO DO - deal with setting the active view to be the file that has this class + //if multiple files are open. + + if (name == "Classes" || name == "Globals") + return; + + Kate::View *view = win->viewManager()->activeView(); + + Kate::Document *doc = view->getDoc(); + QString docline = doc->textLine(line); + int numlines = doc->numLines(); + int done = 0, apiline = -1, forward_line = line,backward_line = line-1; + while (!done) + { + done = 1; + if (forward_line < numlines) + { + if (doc->textLine(forward_line).find(name) > -1) + { + apiline = forward_line; + break; + } + forward_line++; + done = 0; + } + if (backward_line > -1) + { + if (doc->textLine(backward_line).find(name) > -1) + { + apiline = backward_line; + break; + } + backward_line--; + done = 0; + } + } + if (apiline == -1) + { + KMessageBox::information(0, + i18n("Could not find method/class %1.").arg(name), i18n("Selection")); + } + else + { + view->setCursorPosition(apiline, 0); + } + view->setFocus(); +} + +void PluginViewPyBrowse::slotUpdatePyBrowser() +{ + Kate::ViewManager *viewManager = win->viewManager(); + if (viewManager == NULL) + return; + Kate::View *view = viewManager->activeView(); + if (view == NULL) + return; + QString pytext(view->getDoc()->text()); + kpybrowser->parseText(pytext); +} + +void PluginViewPyBrowse::slotShowPyBrowser() +{ + //TO DO implement this later so that you can turn the browser off and on +} + +KatePluginPyBrowse::KatePluginPyBrowse( QObject* parent, const char* name, const QStringList& ) + : Kate::Plugin ( (Kate::Application *)parent, name ) +{ +} + +KatePluginPyBrowse::~KatePluginPyBrowse() +{ +} + +void KatePluginPyBrowse::addView (Kate::MainWindow *win) +{ + PluginViewPyBrowse *view = new PluginViewPyBrowse(win); + m_views.append (view); +} + +void KatePluginPyBrowse::removeView(Kate::MainWindow *win) +{ + for (uint z=0; z < m_views.count(); z++) + if (m_views.at(z)->win == win) + { + PluginViewPyBrowse *view = m_views.at(z); + m_views.remove (view); + delete view; + } +} diff --git a/kate/kpybrowser/pybrowse_part.h b/kate/kpybrowser/pybrowse_part.h new file mode 100644 index 0000000..85aedbb --- /dev/null +++ b/kate/kpybrowser/pybrowse_part.h @@ -0,0 +1,72 @@ +/*************************************************************************** + pybrowse_part.h - description + ------------------- + begin : Tue Aug 28 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef _PYBROWSE_PART_H_ +#define _PYBROWSE_PART_H_ + +#include <kate/application.h> +#include <kate/document.h> +#include <kate/mainwindow.h> +#include <kate/plugin.h> +#include <kate/view.h> +#include <kate/viewmanager.h> +#include <kate/toolviewmanager.h> +#include <kate/documentmanager.h> + +#include <kdockwidget.h> +#include <klibloader.h> +#include <klocale.h> +#include <qstring.h> +#include "kpybrowser.h" + +class PluginViewPyBrowse : public QObject, KXMLGUIClient +{ + Q_OBJECT + + friend class KatePluginPyBrowse; + + public: + PluginViewPyBrowse (Kate::MainWindow *w); + ~PluginViewPyBrowse (); + + public slots: + void slotShowPyBrowser(); + void slotSelected(QString name, int line); + void slotUpdatePyBrowser(); + + private: + Kate::MainWindow *win; + QWidget *my_dock; + KPyBrowser *kpybrowser; +}; + +class KatePluginPyBrowse : public Kate::Plugin, public Kate::PluginViewInterface +{ + Q_OBJECT + + public: + KatePluginPyBrowse( QObject* parent = 0, const char* name = 0, const QStringList& = QStringList() ); + ~KatePluginPyBrowse(); + + void addView(Kate::MainWindow *win); + void removeView(Kate::MainWindow *win); + + private: + QPtrList<PluginViewPyBrowse> m_views; +}; + +#endif diff --git a/kate/kpybrowser/pybrowsenode.cpp b/kate/kpybrowser/pybrowsenode.cpp new file mode 100644 index 0000000..866924b --- /dev/null +++ b/kate/kpybrowser/pybrowsenode.cpp @@ -0,0 +1,209 @@ +/*************************************************************************** + pybrowsenode.cpp - description + ------------------- + begin : Mon Aug 27 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "pybrowsenode.h" + +static const char *py_class_xpm[] = { + "16 16 10 1", + " c None", + ". c #000000", + "+ c #A4E8FC", + "@ c #24D0FC", + "# c #001CD0", + "$ c #0080E8", + "% c #C0FFFF", + "& c #00FFFF", + "* c #008080", + "= c #00C0C0", + " .. ", + " .++.. ", + " .+++@@. ", + " .@@@@@#... ", + " .$$@@##.%%.. ", + " .$$$##.%%%&&. ", + " .$$$#.&&&&&*. ", + " ...#.==&&**. ", + " .++..===***. ", + " .+++@@.==**. ", + " .@@@@@#..=*. ", + " .$$@@##. .. ", + " .$$$###. ", + " .$$$##. ", + " ..$#. ", + " .. " +}; + +static const char *py_method_xpm[] = { + "16 16 5 1", + " c None", + ". c #000000", + "+ c #FCFC80", + "@ c #E0BC38", + "# c #F0DC5C", + " ", + " ", + " ", + " .. ", + " .++.. ", + " .+++++. ", + " .+++++@. ", + " .. .##++@@. ", + " .++..###@@@. ", + " .+++++.##@@. ", + " .+++++@..#@. ", + " .##++@@. .. ", + " .###@@@. ", + " .###@@. ", + " ..#@. ", + " .. " +}; + +static const char *py_function_xpm[] = { + "16 16 6 1", + " c None", + ". c #240000", + "+ c #000000", + "@ c #FCFC80", + "# c #E0BC38", + "$ c #F0DC5C", + " ........ ", + ". . ", + ". . ", + " ........ ++ ", + " +@@++ ", + " +@@@@@+ ", + " +@@@@@#+ ", + " ++ +$$@@##+ ", + " +@@++$$$###+ ", + " +@@@@@+$$##+ ", + " +@@@@@#++$#+ ", + " +$$@@##+ ++ ", + " +$$$###+ ", + " +$$$##+ ", + " ++$#+ ", + " ++ " +}; + + +PyBrowseNode::PyBrowseNode (QListViewItem * parent, const QString &name, + const QString &signature, int nodeType): +QListViewItem (parent, signature) +{ + init (name, signature, nodeType); +} + +PyBrowseNode::PyBrowseNode (QListView * parent, const QString &name, + const QString &signature, int nodeType): +QListViewItem (parent, signature) +{ + init (name, signature, nodeType); +} + +void +PyBrowseNode::init (const QString &a_name, const QString &a_signature, int nodeType) +{ + node_type = nodeType; + if (nodeType == PYCLASS) + setPixmap (0, QPixmap (py_class_xpm)); + if (nodeType == PYMETHOD) + setPixmap (0, QPixmap (py_method_xpm)); + if (nodeType == PYFUNCTION) + setPixmap (0, QPixmap (py_function_xpm)); + + name = a_name; + signature = a_signature; +} + +PyBrowseNode::~PyBrowseNode () +{ + setPixmap (0, QPixmap (py_class_xpm)); +} + +void +PyBrowseNode::setName (const QString &a_name) +{ + name = a_name; + setText (0, name); +} + +QString +PyBrowseNode::getName ()const +{ + return name; +} + +void +PyBrowseNode::setSig (const QString &a_signature) +{ + signature = a_signature; + +} + +QString +PyBrowseNode::getSig ()const +{ + return signature; +} + +void +PyBrowseNode::setLine (int a_line) +{ + line = a_line; +} + +int +PyBrowseNode::getLine ()const +{ + return line; +} + + +void +PyBrowseNode::setType (int type) +{ + node_type = type; +} + +int +PyBrowseNode::getType ()const +{ + return node_type; +} + +void +PyBrowseNode::setClass (const QString &a_method_class) +{ + node_class = a_method_class; +} + +QString +PyBrowseNode::getClass ()const +{ + return node_class; +} + +QString +PyBrowseNode::getQualifiedName ()const +{ + if (node_type == PYCLASS) + return node_class; + if (node_type == PYMETHOD) + return node_class + "::" + name; + if (node_type == PYFUNCTION) + return name; + return name; +} diff --git a/kate/kpybrowser/pybrowsenode.h b/kate/kpybrowser/pybrowsenode.h new file mode 100644 index 0000000..d5083f9 --- /dev/null +++ b/kate/kpybrowser/pybrowsenode.h @@ -0,0 +1,68 @@ +/*************************************************************************** + pybrowsenode.h - description + ------------------- + begin : Mon Aug 27 2001 + copyright : (C) 2001 by Christian Bird + email : chrisb@lineo.com + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef PYBROWSENODE_H +#define PYBROWSENODE_H + +#include <qlistview.h> +#include <qpixmap.h> + +#define PYCLASS 1 +#define PYMETHOD 2 +#define PYFUNCTION 3 +#define PYVARIABLE 4 +#define PYOTHER 5 + +/** + *@author Christian Bird + */ + + + +class PyBrowseNode : public QListViewItem { +public: + QPixmap *pyClassPixmap; + + PyBrowseNode(QListView *parent, const QString &a_name, const QString &a_signature, int type); + PyBrowseNode(QListViewItem *parent, const QString &a_name, const QString &a_signature, int type); + ~PyBrowseNode(); + + void init(const QString &a_name, const QString &a_signature, int nodeType); + + void setName(const QString &name); + QString getName()const ; + void setLine(int line); + int getLine()const; + void setSig(const QString &signature); + QString getSig()const; + void setType(int type); + int getType()const; + void setClass(const QString &a_method_class); + QString getClass()const; + + QString getQualifiedName()const; + +private: + QString name; + QString signature; + QString node_class; + int line; + int node_type; + +}; + +#endif diff --git a/kate/kpybrowser/ui.rc b/kate/kpybrowser/ui.rc new file mode 100644 index 0000000..0c4e9ab --- /dev/null +++ b/kate/kpybrowser/ui.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="katepybrowse" library="libkatepybrowseplugin" version="3"> +<MenuBar> + <Menu name="python"><Text>P&ython</Text> + <Action name="python_update_pybrowse" /> + </Menu> +</MenuBar> +</kpartplugin> |