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

status: make selected file rows draggable

This may need tweaking, but is basically functional on Linux. I can
drag filenames out of the status window and into my console or firefox.
Firefox decodes the filename as an URL. Perhaps we need to prefix these
paths with file://

Changeset cc01b492e6b7

Parent e05084344071

by Steve Borho

Changes to one file · Browse files at cc01b492e6b7 Showing diff from parent e05084344071 Diff from another changeset...

 
11
12
13
14
 
15
16
 
17
18
19
 
65
66
67
68
 
69
70
71
72
73
 
133
134
135
136
137
138
139
140
141
142
143
144
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
147
148
 
236
237
238
239
 
240
241
242
 
11
12
13
 
14
15
 
16
17
18
19
 
65
66
67
 
68
69
 
70
71
72
 
132
133
134
 
 
 
 
 
 
 
 
 
 
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
 
250
251
252
 
253
254
255
256
@@ -11,9 +11,9 @@
 from tortoisehg.util.i18n import _    from PyQt4.QtCore import Qt, QVariant, SIGNAL, QAbstractTableModel -from PyQt4.QtCore import QObject, QEvent +from PyQt4.QtCore import QObject, QEvent, QMimeData, QPoint  from PyQt4.QtGui import QWidget, QVBoxLayout, QSplitter, QTreeView -from PyQt4.QtGui import QTextEdit, QFont, QColor +from PyQt4.QtGui import QTextEdit, QFont, QColor, QDrag    # This widget can be used as the basis of the commit tool or any other  # working copy browser. @@ -65,9 +65,8 @@
  layout.addWidget(split)   self.setLayout(layout)   - self.tv = QTreeView(split) + self.tv = WctxFileTree(split)   self.connect(self.tv, SIGNAL('clicked(QModelIndex)'), self.rowSelected) - self.tv.installEventFilter(TvEventFilter(self))     self.te = QTextEdit(split)   self.te.document().setDefaultStyleSheet(qtlib.thgstylesheet) @@ -133,16 +132,31 @@
  self.te.setHtml(o)     -class TvEventFilter(QObject): - '''Event filter for our QTreeView''' - def __init__(self, parent): - QObject.__init__(self, parent) - def eventFilter(self, treeview, event): - if event.type() == QEvent.KeyPress and event.key() == 32: - for index in treeview.selectedIndexes(): - treeview.model().toggleRow(index) - return True - return treeview.eventFilter(treeview, event) +class WctxFileTree(QTreeView): + def __init__(self, parent=None): + QTreeView.__init__(self, parent) + + def keyPressEvent(self, event): + if event.key() == 32: + for index in self.selectedIndexes(): + self.model().toggleRow(index) + + def dragObject(self): + rows = set() + fnames = [] + for index in self.selectedIndexes(): + if index.row() not in rows: + rows.add(index.row()) + fnames.append(self.model().getPath(index)) + if rows: + d = QDrag(self) + m = QMimeData() + m.setText(', '.join(fnames)) + d.setMimeData(m) + d.start(Qt.CopyAction) + + def mouseMoveEvent(self, event): + self.dragObject()      COL_CHECK = 0 @@ -236,7 +250,7 @@
  return QVariant(self.headers[col])     def flags(self, index): - flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled + flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled   if index.column() == COL_CHECK:   flags |= Qt.ItemIsUserCheckable   return flags