Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

grep: make search a dockable widget

This is mainly a proof-of-concept to see if this would work. I would have no
problem if this is backed out and tried again later. For one, it causes an
occasional SEGV on exit on my machine.

Changeset 9e27526a4e22

Parent 7262162aba46

by Steve Borho

Changes to 2 files · Browse files at 9e27526a4e22 Showing diff from parent 7262162aba46 Diff from another changeset...

 
18
19
20
21
 
22
23
24
25
26
27
28
 
29
30
31
 
33
34
35
36
 
 
 
 
 
 
 
 
 
 
 
37
38
39
40
41
42
43
44
45
 
 
 
 
46
47
48
 
112
113
114
115
 
116
117
 
118
119
120
 
123
124
125
126
 
127
128
129
 
132
133
134
135
136
137
138
139
140
141
 
18
19
20
 
21
22
23
24
25
26
27
 
28
29
30
31
 
33
34
35
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
 
 
53
54
55
56
57
58
59
 
123
124
125
 
126
127
 
128
129
130
131
 
134
135
136
 
137
138
139
140
 
143
144
145
 
 
 
 
146
147
148
@@ -18,14 +18,14 @@
 from PyQt4.QtGui import *    # This widget can be embedded in any application that would like to -# prove search features +# provide search features    # Technical Debt  # tortoisehg.editor with line number  # smart visual diffs (what does this mean?)  # context menu for matches (view file, annotate file)   -class SearchWidget(QWidget): +class SearchWidget(QDockWidget):   '''Working copy and repository search widget   SIGNALS:   loadBegin() - for progress bar @@ -33,16 +33,27 @@
  errorMessage(QString) - for status bar   '''   def __init__(self, pats, root=None, parent=None): - QWidget.__init__(self, parent) + QDockWidget.__init__(self, parent) + + if parent is None: + self.setFeatures(QDockWidget.NoDockWidgetFeatures) + self.setWindowTitle(_('TortoiseHg Search')) + self.resize(800, 500) + else: + self.setFeatures(QDockWidget.DockWidgetClosable | + QDockWidget.DockWidgetMovable | + QDockWidget.DockWidgetFloatable) + self.setWindowTitle(_('Search'))     self.thread = None   root = paths.find_root(root)   repo = hg.repository(ui.ui(), path=root)   assert(repo)   - layout = QVBoxLayout() - layout.setMargin(0) - self.setLayout(layout) + mainframe = QFrame() + mainvbox = QVBoxLayout() + mainframe.setLayout(mainvbox) + self.setWidget(mainframe)     hbox = QHBoxLayout()   hbox.setMargin(0) @@ -112,9 +123,9 @@
  expandtoggled()   hbox.insertWidget(0, expand)   - layout.addLayout(hbox) + mainvbox.addLayout(hbox)   frame.setLayout(grid) - layout.addWidget(frame) + mainvbox.addWidget(frame)     tv = MatchTree(repo, self)   tv.setItemsExpandable(False) @@ -123,7 +134,7 @@
  tv.setModel(tm)   tv.setColumnHidden(COL_REVISION, True)   tv.setColumnHidden(COL_USER, True) - layout.addWidget(tv) + mainvbox.addWidget(tv)   le.returnPressed.connect(self.searchActivated)   self.repo = repo   self.tv, self.regexple, self.chk = tv, le, chk @@ -132,10 +143,6 @@
  self.singlematch = singlematch   self.regexple.setFocus()   - if not parent: - self.setWindowTitle(_('TortoiseHg Search')) - self.resize(800, 500) -   def keyPressEvent(self, event):   if event.key() == Qt.Key_Escape:   if self.thread and self.thread.isRunning():
 
50
51
52
 
53
54
55
 
220
221
222
 
 
223
224
225
 
247
248
249
 
 
 
 
250
251
252
253
254
 
 
255
256
257
 
412
413
414
 
 
 
 
 
 
 
 
 
 
 
415
416
417
 
50
51
52
53
54
55
56
 
221
222
223
224
225
226
227
228
 
250
251
252
253
254
255
256
257
258
 
 
 
259
260
261
262
263
 
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
@@ -50,6 +50,7 @@
    self._loading = True   self._scanForRepoChanges = True + self._searchWidgets = []     QtGui.QMainWindow.__init__(self)   HgDialogMixin.__init__(self, ui) @@ -220,6 +221,8 @@
  self.branch_label_action = self.toolBar_treefilters.addWidget(self.branch_label)   self.branch_comboBox_action = self.toolBar_treefilters.addWidget(self.branch_comboBox)   self.toolBar_treefilters.addSeparator() + self.toolBar_treefilters.addAction(self.actionSearch) + self.toolBar_treefilters.addSeparator()     # diff mode toolbar   self.toolBar_diff.addAction(self.actionDiffMode) @@ -247,11 +250,14 @@
  self.actionAnnMode.setCheckable(True)   connect(self.actionAnnMode, SIGNAL('toggled(bool)'), self.setAnnotate)   + self.actionSearch = QtGui.QAction('Search', self) + self.actionSearch.setShortcut(Qt.Key_F3) + connect(self.actionSearch, SIGNAL('triggered()'), self.on_search) +   self.actionHelp.setShortcut(Qt.Key_F1)   self.actionHelp.setIcon(geticon('help')) - connect(self.actionHelp, SIGNAL('triggered()'), - self.on_help) - + connect(self.actionHelp, SIGNAL('triggered()'), self.on_help) +   # Next/Prev diff (in full file mode)   self.actionNextDiff = QtGui.QAction(geticon('down'), 'Next diff', self)   self.actionNextDiff.setShortcut('Alt+Down') @@ -412,6 +418,17 @@
  def on_help(self, *args):   pass   + def on_search(self, *args): + from tortoisehg.hgqt.grep import SearchWidget + # todo: get root of current repo, pass to search widget + root = None + s = SearchWidget('', root, self) + s.setAllowedAreas(QtCore.Qt.TopDockWidgetArea| + QtCore.Qt.BottomDockWidgetArea) + s.show() + s.setObjectName("searchWidget%d" % len(self._searchWidgets)) + self._searchWidgets.append(s) +   def okToContinue(self):   '''   returns False if there is unsaved data