Commit ca06d0d6 authored by Ritesh Sarraf's avatar Ritesh Sarraf

Imported Upstream version 0.7

parent b3fd9f76
repo: 5cb8ebd6e7a42ad40fef039a66661ae4a6a9fd83
node: 92180e7d59b616f014b4cfe86bda5bb17892ef28
branch: default
latesttag: null
latesttagdistance: 109
......@@ -8,19 +8,24 @@
from distutils.core import setup
setup(name='Seascope',
version='0.6.1',
description='A PyQt GUI front-end for cscope',
long_description='A pyQt GUI front-end for cscope. Written in python using pyQt, QScintilla libraries.',
version='0.7',
description='A multi-platform multi-language source code browsing tool'
long_description='A pyQt GUI front-end for idutils, cscope and gtags. Written in python using pyQt, QScintilla libraries.',
url='http://seascope.googlecode.com',
packages=['Seascope',
'Seascope.backend',
'Seascope.backend.plugins',
'Seascope.backend.plugins.idutils'
'Seascope.backend.plugins.cscope',
'Seascope.backend.plugins.gtags',
'Seascope.view'
'Seascope.view',
'Seascope.view.filecontext',
'Seascope.view.filecontext.plugins',
'Seascope.view.filecontext.plugins.ctags_view',
'Seascope.view.filecontext.plugins.generic_view',
],
package_dir={'Seascope': 'src'},
package_data={'Seascope': ['icons/*.svg','ui/*.ui']},
package_data={'Seascope': ['icons/*.svg','ui/*.ui','tools/*.py']},
license="BSD License",
classifiers=[
'Development Status :: 4 - Beta',
......@@ -35,7 +40,7 @@ setup(name='Seascope',
'Programming Language :: Python',
'Topic :: Software Development',
],
options= {'bdist_rpm':{'requires': 'PyQt4,qscintilla-python,cscope,ctags',
options= {'bdist_rpm':{'requires': 'PyQt4,qscintilla-python,idutils,cscope,global,ctags,graphviz',
'group': 'Development Tools',
'vendor': 'The Seascope Team'}}
)
......@@ -46,13 +46,13 @@ class ProjectOpenDialog(QObject):
self.path = proj_dir
def open_btn_cb(self):
fdlg = QFileDialog(None, "Choose project directory")
fdlg = QFileDialog(None, "Choose project directory")
fdlg.setFileMode(QFileDialog.Directory);
fdlg.setDirectory(self.dlg.pod_proj_name.text())
if (fdlg.exec_()):
proj_dir = fdlg.selectedFiles()[0];
self.dlg.pod_proj_name.setText(str(proj_dir))
def ok_btn_cb(self):
p = str(self.dlg.pod_proj_name.text()).strip()
if (p == ''):
......@@ -85,7 +85,7 @@ def show_project_open_dialog(path_list):
return d.run_dialog(path_list)
class FilePreferencesDialog(QObject):
def __init__(self, app_style, edit_ext_cmd, ev_font, dontask, innered):
def __init__(self, app_style, edit_ext_cmd, ev_font, dontask, innered, ln_nr):
QObject.__init__(self)
self.dlg = uic.loadUi('ui/preferences.ui')
......@@ -100,6 +100,7 @@ class FilePreferencesDialog(QObject):
self.edit_ext_cmd = edit_ext_cmd
self.exit_dontask = dontask
self.inner_editing = innered
self.show_ln_nr = ln_nr
if self.exit_dontask:
self.dlg.prd_opt_ask_chkb.setCheckState(Qt.Unchecked)
else:
......@@ -108,6 +109,10 @@ class FilePreferencesDialog(QObject):
self.dlg.prd_opt_inner_ed.setCheckState(Qt.Checked)
else:
self.dlg.prd_opt_inner_ed.setCheckState(Qt.Unchecked)
if self.show_ln_nr:
self.dlg.prd_opt_show_ln_nr.setCheckState(Qt.Checked)
else:
self.dlg.prd_opt_show_ln_nr.setCheckState(Qt.Unchecked)
if (self.edit_ext_cmd):
self.dlg.prd_edit_ext_inp.setText(self.edit_ext_cmd)
......@@ -139,11 +144,12 @@ class FilePreferencesDialog(QObject):
self.edit_ext_cmd = self.dlg.prd_edit_ext_inp.text()
self.exit_dontask = self.dlg.prd_opt_ask_chkb.checkState() == Qt.Unchecked
self.inner_editing = self.dlg.prd_opt_inner_ed.checkState() == Qt.Checked
self.show_ln_nr = self.dlg.prd_opt_show_ln_nr.checkState() == Qt.Checked
return (self.app_style, self.dlg.prd_font_app_btn.font().toString(), self.edit_ext_cmd,
self.ev_font, self.exit_dontask, self.inner_editing)
self.ev_font, self.exit_dontask, self.inner_editing, self.show_ln_nr)
def show_preferences_dialog(app_style, edit_ext_cmd, ev_font, dontask, innered):
d = FilePreferencesDialog(app_style, edit_ext_cmd, ev_font, dontask, innered)
def show_preferences_dialog(app_style, edit_ext_cmd, ev_font, dontask, innered, ln_nr):
d = FilePreferencesDialog(app_style, edit_ext_cmd, ev_font, dontask, innered, ln_nr)
return d.run_dialog()
def show_about_dialog():
......
This diff is collapsed.
......@@ -53,7 +53,7 @@ class CtagsThread(QThread):
self.res = self.parse_result(self.res, self.sig)
if self.res != None:
self.sig.sig_result.emit(self.sig.sym, self.res)
self.sig.emit_result(self.res)
def ctags_bsearch(self, ct, n):
x = -1
......@@ -85,17 +85,17 @@ class CtagsThread(QThread):
m = self.ctags_bsearch(ct, n)
if m == -1:
return
return True
if ct[m][1] != n:
if ct[m][2] in ['variable']:
#line[0] = '***** SMART *****'
#print line
return
return True
if f.endswith('.py'):
while m > 0 and (ct[m][2] in ['namespace']):
m = m - 1
if m == - 1:
return
return True
if ct[m][1] == n:
if self.cmd_str == 'DEF':
x = m
......@@ -108,7 +108,11 @@ class CtagsThread(QThread):
for m in range(x, y + 1):
if re.match(self.sig.sym, ct[m][0]):
break
else:
if self.cmd_str == 'DEF':
return False
line[0] = ct[m][0]
return True
def _run_ctags(self):
cmd = 'ctags -n -u --fields=+K -L - -f -'
......@@ -159,12 +163,14 @@ class CtagsThread(QThread):
#t3 = datetime.now()
#print ' ct', t3 - t2
res = []
for line in self.res:
if line[0] not in self.cond_list:
continue
self._ctags_fix(line)
if not self._ctags_fix(line):
continue
res.append(line)
self.res = res
#t4 = datetime.now()
#print ' fix', t4 - t3
#print ' total', t4 - t2
......
......@@ -6,6 +6,8 @@
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import os, re
def msg_box(msg):
QMessageBox.warning(None, "Seascope", msg, QMessageBox.Ok)
......@@ -50,7 +52,7 @@ class QueryBase(QObject):
def prepare_menu(menubar):
pass
def query(self, cmd_str, req, opt):
def query(self, rquery):
msg_box('%s: %s: Not implemeted' % (__name__, __func__))
def rebuild():
......@@ -91,14 +93,26 @@ class QueryUiBase(QObject):
def query_class_graph(self, req, opt):
PluginHelper.class_graph_view_page_new(req, self.query.conf.id_dir, self.query.query, self.clgraph_args, opt)
def _prepare_rquery(self, cmd_str, req, opt):
rquery = {}
rquery['cmd'] = cmd_str
rquery['req'] = req
rquery['opt'] = opt
# add current file info
rquery['hint_file'] = PluginHelper.editor_current_file()
return rquery
def query_qdef(self, req, opt):
sig_res = self.query.query('DEF', req, opt)
rquery = {}
rquery = self._prepare_rquery('DEF', req, opt)
sig_res = self.query.query(rquery)
PluginHelper.quick_def_page_new(sig_res)
def do_query(self, cmd_str, req, opt):
## create page
name = cmd_str + ' ' + req
sig_res = self.query.query(cmd_str, req, opt)
rquery = self._prepare_rquery(cmd_str, req, opt)
sig_res = self.query.query(rquery)
PluginHelper.result_page_new(name, sig_res)
def do_rebuild(self):
......@@ -129,6 +143,72 @@ class QuerySignal(QObject):
def __init__(self):
QObject.__init__(self)
def _relevancy_sort(self, hfile, res):
pt = []
pd = {}
p = hfile
(pre, ext) = os.path.splitext(hfile)
c = None
while p != c:
e = [p, [], []]
pt += [e]
pd[p] = e
c = p
p = os.path.dirname(p)
for line in res:
f = line[1]
d = os.path.dirname(f)
p = f
while p not in pd:
p = os.path.dirname(p)
e = pd[p]
if p in [f, d]:
e[1].append(line)
else:
e[2].append(line)
for e in pt:
e[1] = sorted(e[1], key=lambda li: li[1])
e[2] = sorted(e[2], key=lambda li: li[1])
pre = pre + '.*'
e0 = []
e1 = []
for e in pt[1][1]:
if re.match(pre, e[1]):
e0 += [e]
else:
e1 += [e]
pt[0][1] += e0
pt[1][1] = e1
res1 = []
res2 = []
for e in pt:
res1 += e[1]
res2 += e[2]
res = res1 + res2
return res
def relevancy_sort(self, res):
if os.getenv('RELEVANCY_SORT', 1) == 0:
return res
hint_file = None
try:
hint_file = self.rquery['hint_file']
except:
pass
if not hint_file:
return res
if not os.path.isabs(hint_file):
print 'BUG: relevancy_sort: not abs path:', hint_file
return res
if len(res) > 10000:
return res
return self._relevancy_sort(hint_file, res)
def emit_result(self, res):
res = self.relevancy_sort(res)
self.sig_result.emit(self.sym, res)
class PluginProcess(QObject):
proc_list = []
......@@ -185,14 +265,16 @@ class PluginProcess(QObject):
except:
res = [['', '', '', 'error while parsing output of: ' + self.p_cmd]]
if res != None:
self.sig.sig_result.emit(self.sig.sym, res)
self.sig.emit_result(res)
self._cleanup()
def run_query_process(self, pargs, sym):
def run_query_process(self, pargs, sym, rquery=None):
self.sig.sym = sym
self.sig.rquery = rquery
self.p_cmd = ' '.join(pargs)
#print 'pp:cmd:', pargs[0], pargs[1:]
if os.getenv('SEASCOPE_DEBUG'):
print self.p_cmd
self.proc.start(pargs[0], pargs[1:])
if self.proc.waitForStarted() == False:
return None
......
......@@ -14,6 +14,10 @@ class_graph_view = None
file_view = None
dbg_view = None
def editor_current_file():
(f, l) = edit_book.get_current_file_line()
return f
def editor_current_word():
return edit_book.get_current_word()
......@@ -60,7 +64,8 @@ def quick_def_page_new(sig_res):
dbg_view.connect_to_sig(sig_res[1])
def call_view_page_new(req, query_func, ctree_query_args, opt):
call_view.create_page(req, query_func, ctree_query_args, opt)
hint_file = editor_current_file()
call_view.create_page(req, query_func, ctree_query_args, opt, hint_file)
def class_graph_view_page_new(req, proj_dir, query_func, clgraph_query_args, opt):
class_graph_view.create_page(req, proj_dir, query_func, clgraph_query_args, opt)
......
......@@ -204,17 +204,20 @@ class QueryCscope(QueryBase):
QueryBase.__init__(self)
self.conf = conf
def query(self, cmd_str, req, opt = None):
def query(self, rquery):
if (not self.conf or not self.conf.is_ready()):
print "pm_query not is_ready"
return None
cmd_str = rquery['cmd']
req = rquery['req']
opt = rquery['opt']
cmd_id = CscopeProjectUi.cmd_str2id[cmd_str]
if opt == None or opt == '':
opt = []
else:
opt = opt.split()
pargs = [ 'cscope' ] + self.conf.cs_opt + opt + [ '-L', '-d', '-' + str(cmd_id), req ]
qsig = CsProcess(self.conf.cs_dir, [cmd_str, req]).run_query_process(pargs, req)
qsig = CsProcess(self.conf.cs_dir, [cmd_str, req]).run_query_process(pargs, req, rquery)
return qsig
def rebuild(self):
......
......@@ -170,7 +170,7 @@ class ProjectSettingsCscopeDialog(QDialog):
QObject.connect(self, SIGNAL("accepted()"), self.ok_btn_cb)
def path_open_cb(self):
fdlg = QFileDialog(None, "Choose directory")
fdlg = QFileDialog(None, "Choose directory")
fdlg.setFileMode(QFileDialog.Directory);
fdlg.setDirectory(self.pd_path_inp.text())
if (fdlg.exec_()):
......@@ -178,7 +178,7 @@ class ProjectSettingsCscopeDialog(QDialog):
self.pd_path_inp.setText(str(path_dir))
def src_add_cb(self):
fdlg = QFileDialog(None, "Choose directory")
fdlg = QFileDialog(None, "Choose directory")
fdlg.setFileMode(QFileDialog.Directory);
fdlg.setDirectory(self.pd_path_inp.text())
if (fdlg.exec_()):
......
......@@ -68,7 +68,7 @@ class ProjectGtags(ProjectBase):
@staticmethod
def prj_new():
from PyQt4.QtGui import QFileDialog
fdlg = QFileDialog(None, "Choose source code directory")
fdlg = QFileDialog(None, "Choose source code directory")
fdlg.setFileMode(QFileDialog.Directory);
#fdlg.setDirectory(self.pd_path_inp.text())
if fdlg.exec_():
......@@ -171,11 +171,14 @@ class QueryGtags(QueryBase):
self.gt_file_list_update()
def query(self, cmd_str, req, opt):
def query(self, rquery):
if (not self.conf):
#or not self.conf.is_ready()):
print "pm_query not is_ready"
return None
cmd_str = rquery['cmd']
req = rquery['req']
opt = rquery['opt']
if opt == None or opt == '':
opt = []
else:
......@@ -184,9 +187,9 @@ class QueryGtags(QueryBase):
pargs = [ 'global', '-a', '--result=cscope', '-x' ] + opt
if cmd_opt != '':
pargs += [ cmd_opt ]
pargs += [ req ]
pargs += [ '--', req ]
qsig = GtProcess(self.conf.gt_dir, [cmd_str, req]).run_query_process(pargs, req)
qsig = GtProcess(self.conf.gt_dir, [cmd_str, req]).run_query_process(pargs, req, rquery)
return qsig
def rebuild(self):
......@@ -202,14 +205,14 @@ class QueryGtags(QueryBase):
return qsig
def gt_file_list_update(self):
gt_file = os.path.join(self.conf.gt_dir, 'GTAGS')
if not os.path.exists(gt_file):
wdir = self.conf.gt_dir
if not os.path.exists(os.path.join(wdir, 'GTAGS')):
return
fl = []
try:
import subprocess
pargs = [ 'global', '-P', '-a' ]
proc = subprocess.Popen(pargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=self.conf.gt_dir)
proc = subprocess.Popen(pargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=wdir)
(out_data, err_data) = proc.communicate()
fl = re.split('\r?\n', out_data.strip())
PluginHelper.file_view_update(fl)
......
......@@ -63,7 +63,7 @@ class ProjectIdutils(ProjectBase):
@staticmethod
def prj_new():
from PyQt4.QtGui import QFileDialog
fdlg = QFileDialog(None, "Choose source code directory")
fdlg = QFileDialog(None, "Choose source code directory")
fdlg.setFileMode(QFileDialog.Directory);
#fdlg.setDirectory(self.pd_path_inp.text())
if fdlg.exec_():
......@@ -178,11 +178,14 @@ class QueryIdutils(QueryBase):
self.id_file_list_update()
def query(self, cmd_str, req, opt = None):
def query(self, rquery):
if (not self.conf):
#or not self.conf.is_ready()):
print "pm_query not is_ready"
return None
cmd_str = rquery['cmd']
req = rquery['req']
opt = rquery['opt']
if opt == None:
opt = []
......@@ -197,8 +200,8 @@ class QueryIdutils(QueryBase):
pass
elif cmd_str in ['-->', '<--']:
pargs += ['-l']
pargs += [ req ]
qsig = IdProcess(self.conf.id_dir, [cmd_str, req]).run_query_process(pargs, req)
pargs += [ '--', req ]
qsig = IdProcess(self.conf.id_dir, [cmd_str, req]).run_query_process(pargs, req, rquery)
return qsig
def rebuild(self):
......@@ -211,16 +214,20 @@ class QueryIdutils(QueryBase):
return qsig
def id_file_list_update(self):
id_file = os.path.join(self.conf.id_dir, 'ID')
if not os.path.exists(id_file):
wdir = self.conf.id_dir
if not os.path.exists(os.path.join(wdir, 'ID')):
return
fl = []
try:
import subprocess
pargs = [ 'fnid', '-S', 'newline', '-f', id_file ]
proc = subprocess.Popen(pargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
pargs = [ 'fnid', '-S', 'newline', '-f', 'ID' ]
proc = subprocess.Popen(pargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=wdir)
(out_data, err_data) = proc.communicate()
fl = re.split('\r?\n', out_data.strip())
fl = []
for f in re.split('\r?\n', out_data.strip()):
if f == '':
continue
fl.append(os.path.join(wdir, f))
PluginHelper.file_view_update(fl)
except:
import sys
......
......@@ -30,10 +30,10 @@ class ClassGraphGenerator:
def refFiles(self, sym):
args = ['lid', '-R', 'grep', sym]
try:
# In python >= 2.7 can use subprocess.check_output
# In python >= 2.7 can use subprocess.check_output
# output = subprocess.check_output(args, cwd=self.wdir)
proc = subprocess.Popen(args, cwd=self.wdir, stdout=subprocess.PIPE)
(output, err_data) = proc.communicate()
proc = subprocess.Popen(args, cwd=self.wdir, stdout=subprocess.PIPE)
(output, err_data) = proc.communicate()
output = re.split('\r?\n', output)
except Exception as e:
print >> sys.stderr, e, '\n'
......
......@@ -69,7 +69,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Seascope 0.6&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Seascope 0.7&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;A graphical user interface for idutils, cscope and gtags.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Copyright © 2010-2012 Anil Kumar&lt;/p&gt;
......@@ -136,11 +136,14 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Shu Shen&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; shu.shen@gmail.com&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; Developer&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'微软雅黑';&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'微软雅黑';&quot;&gt;Binghoo Dang&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'微软雅黑';&quot;&gt; dangbinghoo@gmail.com&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'微软雅黑';&quot;&gt; Developer&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'微软雅黑';&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Binghoo Dang&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; dangbinghoo@gmail.com&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; Developer&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Anthony Liu&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; antliu@gmail.com&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; Developer &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="acceptRichText">
<bool>true</bool>
......@@ -164,11 +167,14 @@ p, li { white-space: pre-wrap; }
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;xuhdev@gmail.com - Bug fixes&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Ritesh Raj Sarraf&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; rrs@debian.org&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; Debian packaging&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Bug fixes&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; xuhdev@gmail.com&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; tuomas.tuurala@gmail.com&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
......
......@@ -144,6 +144,13 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="prd_opt_show_ln_nr">
<property name="text">
<string>Show line number in editor by default</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="prd_opt_vspacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
......@@ -49,12 +49,13 @@ class CallTreeWidgetItem(QTreeWidgetItem):
class CallTreeWidget(QTreeWidget):
sig_show_file_line = pyqtSignal(str, int)
def __init__(self, parent, cmd_func, cmd_id, cmd_opt):
def __init__(self, parent, cmd_func, cmd_id, cmd_opt, hint_file):
QTreeWidget.__init__(self, parent)
self.is_busy = False
self.cmd_func = cmd_func
self.cmd_id = cmd_id
self.cmd_opt = cmd_opt
self.hint_file = hint_file
self.itemExpanded.connect(self.ctree_itemExpanded)
self.itemActivated.connect(self.ctree_itemActivated)
......@@ -111,64 +112,19 @@ class CallTreeWidget(QTreeWidget):
self.pbar.show()
## add result
sig_res = self.cmd_func(self.cmd_id, tag, opt)
rquery = {}
rquery['cmd'] = self.cmd_id
rquery['req'] = tag
rquery['opt'] = opt
hfile = str(item.data(1, Qt.DisplayRole).toString())
if hfile == '':
hfile = self.hint_file
rquery['hint_file'] = hfile
sig_res = self.cmd_func(rquery)
self.query_item = item
sig_res[0].connect(self.ctree_add_result)
def ctree_add_result(self, req, res):
def __relevancy_sort(pfile, res):
import os, re
pt = []
pd = {}
p = pfile
(pre, ext) = os.path.splitext(pfile)
c = None
while p != c:
e = [p, [], []]
pt += [e]
pd[p] = e
c = p
p = os.path.dirname(p)
for line in res:
f = line[1]
d = os.path.dirname(f)
p = f
while p not in pd:
p = os.path.dirname(p)
e = pd[p]
if p in [f, d]:
e[1].append(line)
else:
e[2].append(line)
for e in pt:
e[1] = sorted(e[1], key=lambda li: li[1])
e[2] = sorted(e[2], key=lambda li: li[1])
pre = pre + '.*'
e0 = []
e1 = []
for e in pt[1][1]:
if re.match(pre, e[1]):
e0 += [e]
else:
e1 += [e]
pt[0][1] += e0
pt[1][1] = e1
res1 = []
res2 = []
for e in pt:
res1 += e[1]
res2 += e[2]
res = res1 + res2
return res
def relevancy_sort(item, res):
pfile = str(item.data(1, Qt.DisplayRole).toString())
if pfile == '':
return res
if len(res) > 10000:
return res
return __relevancy_sort(pfile, res)
res = relevancy_sort(self.query_item, res)
self.query_item.add_result(res)
self.is_busy = False
if self.pbar:
......@@ -180,7 +136,7 @@ class CallTreeWindow(QMainWindow):
sig_show_file_line = pyqtSignal(str, int)
parent = None
def __init__(self, req, cmd_func, cmd_args, cmd_opt):
def __init__(self, req, cmd_func, cmd_args, cmd_opt, hint_file):
QMainWindow.__init__(self, CallTreeWindow.parent)
self.req = req
......@@ -217,7 +173,7 @@ class CallTreeWindow(QMainWindow):
self.bgrp.addButton(btn, inx)
self.hlay.addWidget(btn)
ct = CallTreeWidget(self, cmd_func, cmd[0], cmd_opt)
ct = CallTreeWidget(self, cmd_func, cmd[0], cmd_opt, hint_file)
ct.sig_show_file_line.connect(self.sig_show_file_line)
self.sw.addWidget(ct)
......@@ -241,7 +197,7 @@ def ctree_show_file_line(filename, line):
parent.activateWindow()
parent.show_file_line(filename, line)
def create_page(req, cmd_func, cmd_args, cmd_opt):
w = CallTreeWindow(req, cmd_func, cmd_args, cmd_opt)
def create_page(req, cmd_func, cmd_args, cmd_opt, hint_file):
w = CallTreeWindow(req, cmd_func, cmd_args, cmd_opt, hint_file)
w.sig_show_file_line.connect(ctree_show_file_line)
w.show()
#!/usr/bin/env python
# Copyright (c) 2012 Anthony Liu
# All rights reserved.
#
# License: BSD
import sys
from array import *
class CodemarkManager():
def __init__(self, parent=None):
self.haystack = []
def check(self, filename, line):
if self.haystack.count((filename, line)):
return 1
return 0
def append(self, filename, line):
if self.check(filename, line) == 0:
self.haystack.append((filename, line))
return self.haystack.index((filename, line))
def delete(self, filename, line):
if self.haystack.count((filename, line)) == 0: