1 # -*- coding: utf-8 -*-
2 # Pretty-printers for KDE4.
4 # Copyright (C) 2009 Milian Wolff <mail@milianw.de>
5 # Copyright (C) 2014 Kevin Funk <kfunk@kde.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29 def __init__(self
, val
):
33 iterator
= qt
.QVectorPrinter(self
.val
['m_data'], 'QVector').children()
34 pathSegments
= [str(it
[1]) for it
in iterator
]
35 return "(" + ", ".join(pathSegments
) + ")" if pathSegments
else None
37 class KTextEditor_CursorPrinter
:
38 "Pretty Printer for KTextEditor::Cursor"
40 def __init__(self
, val
):
44 return "[%d, %d]" % (self
.val
['m_line'], self
.val
['m_column'])
46 class KTextEditor_RangePrinter
:
47 "Pretty Printer for KTextEditor::Range"
49 def __init__(self
, val
):
53 return "[(%d, %d) -> (%d, %d)]" % (self
.val
['m_start']['m_line'], self
.val
['m_start']['m_column'],
54 self
.val
['m_end']['m_line'], self
.val
['m_end']['m_column'])
56 pretty_printers_dict
= {}
58 def register_kde_printers (obj
):
62 obj
.pretty_printers
.append(FunctionLookup(gdb
, pretty_printers_dict
))
64 def build_dictionary ():
65 pretty_printers_dict
[re
.compile('^KDevelop::Path$')] = lambda val
: KDevelop_Path(val
)
67 pretty_printers_dict
[re
.compile('^KTextEditor::Cursor$')] = lambda val
: KTextEditor_CursorPrinter(val
)
68 pretty_printers_dict
[re
.compile('^KTextEditor::Range$')] = lambda val
: KTextEditor_RangePrinter(val
)