~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/Refactoring/MatchesDialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2008-01-28 18:02:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080128180225-6nrox6yrworh2c4v
Tags: 4.0.4-1ubuntu1
* Add python-qt3 to build-depends becuase that's where Ubuntu puts 
  pyqtconfig
* Change maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Copyright (c) 2003 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
4
4
#
5
5
 
6
 
from qt import *
7
 
from MatchesForm import MatchesForm
 
6
from PyQt4.QtCore import *
 
7
from PyQt4.QtGui import *
 
8
 
 
9
from KdeQt.KQApplication import e4App
 
10
 
 
11
from Ui_MatchesDialog import Ui_MatchesDialog
8
12
 
9
13
"""
10
14
Module implementing a dialog to show matching references/definitions.
11
15
"""
12
16
 
13
 
class MatchesDialog(MatchesForm):
 
17
class MatchesDialog(QDialog, Ui_MatchesDialog):
14
18
    """
15
19
    Class implementing a dialog to show matching references/definitions.
16
20
    """
17
 
    def __init__(self,ui,parent = None,name = None,modal = 0,fl = 0):
 
21
    def __init__(self, ui, parent = None, name = None):
18
22
        """
19
23
        Constructor
20
24
        
21
25
        @param ui reference to the UI object
22
26
        @param parent parent of this dialog (QWidget)
23
27
        @param name name of this dialog (string or QString)
24
 
        @param modal flag indicating a modal window (boolean)
25
 
        @param fl window flags
26
28
        """
27
 
        MatchesForm.__init__(self,parent,name,modal,fl)
 
29
        QDialog.__init__(self, parent)
 
30
        if name:
 
31
            self.setObjectName(name)
 
32
        self.setupUi(self)
 
33
        
 
34
        self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
28
35
        
29
36
        self.ui = ui
30
 
        
31
 
        self.matchesList.setSorting(0)
32
 
        self.matchesList.setColumnAlignment(1, Qt.AlignRight)
33
 
        self.matchesList.setColumnAlignment(2, Qt.AlignRight)
34
 
        
35
 
        dummy = self.trUtf8("Dummy")
36
 
        
37
 
    def handleDoubleClicked(self, itm):
38
 
        """
39
 
        Private slot to handle the DoubleClicked signal of the list.
 
37
        self.matchesList.header().setSortIndicator(0, Qt.AscendingOrder)
 
38
        
 
39
    def __resort(self):
 
40
        """
 
41
        Private method to resort the tree.
 
42
        """
 
43
        self.matchesList.sortItems(self.matchesList.sortColumn(), 
 
44
                                   self.matchesList.header().sortIndicatorOrder())
 
45
        
 
46
    def __resizeColumns(self):
 
47
        """
 
48
        Private method to resize the list columns.
 
49
        """
 
50
        self.matchesList.header().resizeSections(QHeaderView.ResizeToContents)
 
51
        self.matchesList.header().setStretchLastSection(True)
 
52
        
 
53
    def on_matchesList_itemActivated(self, itm, column):
 
54
        """
 
55
        Private slot to handle the itemActivated signal of the list.
40
56
        """
41
57
        lineno = int(str(itm.text(1)))
42
58
        fn = unicode(itm.text(0))
43
 
        self.ui.getViewManager().displayPythonFile(fn, lineno)
 
59
        e4App().getObject("ViewManager").openSourceFile(fn, lineno)
44
60
        
45
61
    def addEntry(self, ref):
46
62
        """
47
 
        Public slot to add a reference to the listview.
 
63
        Public slot to add a reference to the list.
48
64
        """
49
 
        itm = QListViewItem(self.matchesList, ref.filename, 
50
 
            " %5d" % ref.lineno, " %5d" % ref.confidence)
 
65
        itm = QTreeWidgetItem(self.matchesList, QStringList() \
 
66
            << ref.filename << " %5d" % ref.lineno << " %5d" % ref.confidence)
 
67
        itm.setTextAlignment(1, Qt.AlignRight)
 
68
        itm.setTextAlignment(2, Qt.AlignRight)
 
69
        self.__resort()
 
70
        self.__resizeColumns()