f6c1ef43 pyros2097

13 years ago
v0.32
Config.pyc DELETED
Binary file
Dialog/__init__.pyc DELETED
Binary file
Dialog/dialogs.pyc DELETED
Binary file
Dialog/filebrowser.py DELETED
@@ -1,689 +0,0 @@
1
- """
2
- filebrowser --- Dock with file system tree
3
- ==========================================
4
- """
5
- import sys
6
- import os
7
- import os.path
8
- import operator
9
- import json
10
- import logging
11
-
12
- from PyQt4.QtCore import QDir, QRect, QEvent, QModelIndex, QObject, Qt, QTimer, \
13
- pyqtSignal, pyqtSlot
14
- from PyQt4.QtGui import QAction, QCompleter, QDirModel, \
15
- QFrame, QFileSystemModel, \
16
- QIcon, QItemSelectionModel, QKeySequence, QComboBox, \
17
- QPainter, \
18
- QShortcut, QApplication,QSortFilterProxyModel, QToolButton, QTreeView, QVBoxLayout, QWidget ,QMainWindow
19
-
20
- from mks.widgets.dockwidget import DockWidget
21
-
22
- from mks.core.defines import CONFIG_DIR
23
- from mks.core.core import core
24
- from mks.plugins.filebrowser import DockFileBrowser
25
-
26
- def _getCurDir():
27
- """Get process current directory
28
- """
29
- try:
30
- return os.path.abspath(unicode(os.curdir))
31
- except OSError:
32
- return ''
33
-
34
- class Plugin(QObject):
35
- """File system tree.
36
-
37
- Allows to open files quickly
38
- """
39
-
40
- def __init__(self):
41
- """Create and install the plugin
42
- """
43
- QObject.__init__(self)
44
- # create dock
45
- self.dock = DockFileBrowser(core.mainWindow())
46
- self.dock.hide()
47
- # add dock to dock toolbar entry
48
- core.mainWindow().addDockWidget(Qt.LeftDockWidgetArea, self.dock)
49
-
50
- def del_(self):
51
- """Uninstall the plugin
52
- """
53
- self.dock.del_()
54
-
55
-
56
- class FileBrowserFilteredModel(QSortFilterProxyModel):
57
- """Model filters out files using negative filter.
58
- i.e. does not show .o .pyc and other temporary files
59
- """
60
- def __init__(self, parent):
61
- QSortFilterProxyModel.__init__(self, parent)
62
- core.fileFilter().regExpChanged.connect(self.invalidate)
63
-
64
- def columnCount(self, parent = QModelIndex()): # pylint: disable=W0613
65
- """Column count for the model
66
- """
67
- return 1
68
-
69
- def hasChildren(self, parent = QModelIndex()):
70
- """Check if node has children. QAbstractItemModel standard method
71
- """
72
- return self.sourceModel().hasChildren( self.mapToSource( parent ) )
73
-
74
- def filterAcceptsRow(self, source_row, source_parent):
75
- """ Main method. Check if file matches filter
76
- """
77
- if source_parent == QModelIndex():
78
- return True
79
- return not core.fileFilter().regExp().match(source_parent.child( source_row, 0 ).data().toString() )
80
-
81
-
82
- class SmartRecents(QObject):
83
- """Class stores File Browser recent directories and provides variants for combo box.
84
-
85
- "Active directory" in this class means the last directory, where one or more files has been opened
86
- """
87
- MAX_RECENTS_SIZE = 5
88
- FILE_PATH = os.path.join(CONFIG_DIR, 'file_browser_popular_dirs.json')
89
-
90
- STATISTICS_SIZE = 10.
91
- BONUS_FOR_OPENING = 1.
92
- MAX_POINTS_COUNT = 100.
93
-
94
- _recentsChanged = pyqtSignal(list)
95
-
96
- def __init__(self, fileBrowser):
97
- QObject.__init__(self)
98
- self._currDir = None
99
- self._currIsActive = False
100
- self._popularDirs = None
101
- self._loadPopularDirs()
102
- core.workspace().currentDocumentChanged.connect(self._updateRecents)
103
-
104
- # incoming connections
105
- fileBrowser.rootChanged.connect(self._onRootChanged)
106
- fileBrowser.fileActivated.connect(self._onFileActivated)
107
- # outgoing connections
108
- self._recentsChanged.connect(fileBrowser.updateComboItems)
109
-
110
- def _loadPopularDirs(self):
111
- """Load popular directories from the config
112
- """
113
- self._popularDirs = {}
114
- if os.path.exists(self.FILE_PATH):
115
- try:
116
- with open(self.FILE_PATH, 'r') as f:
117
- self._popularDirs = json.load(f)
118
- except (OSError, IOError, ValueError), ex:
119
- error = unicode(str(ex), 'utf8')
120
- text = "Failed to load popular directories from '%s': %s" % (self.FILE_PATH, error)
121
- core.mainWindow().appendMessage(text)
122
-
123
- for k in self._popularDirs.iterkeys():
124
- try:
125
- self._popularDirs[k] = float(self._popularDirs[k])
126
- except ValueError as ex:
127
- logging.error('Invalid PopularDirs value: ' + unicode(ex))
128
- self._popularDirs[k] = 0.0
129
-
130
- def _savePopularDirs(self):
131
- """Save dirs to file
132
- """
133
- try:
134
- with open(self.FILE_PATH, 'w') as f:
135
- json.dump(self._popularDirs, f, sort_keys=True, indent=4)
136
- except (OSError, IOError), ex:
137
- error = unicode(str(ex), 'utf8')
138
- text = "Failed to save popular directories to '%s': %s" % (self.FILE_PATH, error)
139
- print >> sys.stderr, error
140
-
141
-
142
- def _dirsByPopularity(self):
143
- """Return list of dirrectories, sorted by popularity
144
- """
145
- if not self._popularDirs:
146
- return ()
147
-
148
- dirAndPopularity = sorted(self._popularDirs.iteritems(), key=operator.itemgetter(1), reverse=True)
149
- dirs = [dp[0] for dp in dirAndPopularity] # take only first elements
150
- return dirs
151
-
152
- def _onFileActivated(self):
153
- """FileBrowserDock notifies SmartRecents that file has been activated
154
- """
155
- if self._currIsActive: # statistics already has been updated
156
- return
157
-
158
- self._currIsActive = True
159
-
160
- # Replace the least popular
161
- if self._currDir not in self._popularDirs:
162
- if len(self._popularDirs) == self.STATISTICS_SIZE:
163
- leastPopular = self._dirsByPopularity()[-1]
164
- del self._popularDirs[leastPopular]
165
- self._popularDirs[self._currDir] = 0
166
-
167
- self._popularDirs[self._currDir] += self.BONUS_FOR_OPENING
168
-
169
- # Normalization
170
- pointsSum = sum(self._popularDirs.itervalues())
171
- multiplier = self.MAX_POINTS_COUNT / pointsSum
172
- if multiplier < 1:
173
- for k in self._popularDirs.iterkeys():
174
- self._popularDirs[k] *= multiplier
175
-
176
- self._savePopularDirs()
177
-
178
- # History update is not scheduled here, because it will be scheduled when workspace changes current file
179
-
180
- def _onRootChanged(self, newCurrDir):
181
- """FileBrowserDock notifies SmartRecents that user changed current directory
182
- """
183
- self._currDir = newCurrDir
184
- self._currIsActive = False
185
- self._updateRecents()
186
-
187
- def _updateRecents(self):
188
- """Generate new list of directories, which will be shown in the combo box.
189
- Emit this list
190
- """
191
- # Popular directories
192
- history = [path for path in self._dirsByPopularity() \
193
- if os.path.isdir(path) and \
194
- path != self._currDir]
195
- # leave not more than MAX_RECENTS_SIZE
196
- if len(history) > self.MAX_RECENTS_SIZE:
197
- history = history[:self.MAX_RECENTS_SIZE]
198
-
199
- # now sort by path
200
- history = sorted(history)
201
-
202
- self._recentsChanged.emit(history)
203
-
204
-
205
- class SmartHistory(QObject):
206
- """Class remembers file browser history and manages Back and Forward buttons
207
- """
208
- def __init__(self, fileBrowser):
209
- QObject.__init__(self)
210
- self._fileBrowser = fileBrowser
211
- self._currDir = None
212
- self._currIsActive = False
213
- self._history = []
214
- self._historyIndex = -1
215
-
216
- fileBrowser.titleBarWidget().addSeparator()
217
- self._aBack = QAction( QIcon(':mksicons/previous.png'),
218
- self.tr("Back"),
219
- self)
220
- self._aBack.setShortcut('Alt+Left')
221
- fileBrowser.titleBarWidget().addAction(self._aBack)
222
- core.actionManager().addAction("mNavigation/mFileBrowser/aBack", self._aBack)
223
- self._aBack.triggered.connect(self._onTbBackTriggered)
224
-
225
- self._aForward = QAction( QIcon(':mksicons/next.png'),
226
- self.tr("Forward"),
227
- self)
228
- self._aForward.setShortcut('Alt+Right')
229
- fileBrowser.titleBarWidget().addAction(self._aForward)
230
- core.actionManager().addAction("mNavigation/mFileBrowser/aForward", self._aForward)
231
- self._aForward.triggered.connect(self._onTbForwardTriggered)
232
-
233
- fileBrowser.titleBarWidget().addSeparator()
234
-
235
- # incoming connections
236
- fileBrowser.rootChanged.connect(self._onRootChanged)
237
- fileBrowser.fileActivated.connect(self._onFileActivated)
238
-
239
- def del_(self):
240
- """Explicitly called destructor
241
- """
242
- core.actionManager().removeAction("mNavigation/mFileBrowser/aBack")
243
- core.actionManager().removeAction("mNavigation/mFileBrowser/aForward")
244
-
245
- def _onRootChanged(self, newCurrDir):
246
- """FileBrowserDock notifies SmartHistory that root has been changed
247
- """
248
- self._currDir = newCurrDir
249
- self._currIsActive = False
250
- self._updateActions()
251
-
252
- def _onFileActivated(self):
253
- """FileBrowserDock notifies SmartHistory that file has been activated
254
- """
255
- if self._currIsActive:
256
- return
257
- self._currIsActive = True
258
- self._updateHistory()
259
-
260
- def _updateHistory(self):
261
- """Directory has been activated. Update history
262
- """
263
- if self._history and \
264
- self._history[self._historyIndex] == self._currDir:
265
- return # Do nothing, if moved back or forward
266
-
267
- if (self._historyIndex + 1) < len(self._history): # not on the top of the stack
268
- # Cut history
269
- self._history = self._history[:self._historyIndex + 1]
270
-
271
- # Append new root to the history
272
- self._history.append(self._currDir)
273
- self._historyIndex += 1
274
-
275
- self._updateActions()
276
-
277
- def _onTbBackTriggered(self):
278
- """Back action handler
279
- """
280
- if not self._currIsActive:
281
- self._updateHistory()
282
-
283
- self._historyIndex -= 1
284
- self._fileBrowser.setCurrentPath(self._history[self._historyIndex])
285
-
286
- def _onTbForwardTriggered(self):
287
- """Forward action handler
288
- """
289
- self._historyIndex += 1
290
- self._fileBrowser.setCurrentPath(self._history[self._historyIndex])
291
-
292
- def _updateActions(self):
293
- """Update actions enabled state
294
- """
295
- if self._history and self._currDir != self._history[self._historyIndex]:
296
- self._aBack.setEnabled(True)
297
- self._aBack.setStatusTip(self._history[-1])
298
- self._aBack.setToolTip(self._history[-1])
299
- elif self._history and self._historyIndex > 0:
300
- self._aBack.setEnabled(True)
301
- self._aBack.setStatusTip(self._history[self._historyIndex - 1])
302
- self._aBack.setToolTip(self._history[self._historyIndex - 1])
303
- else:
304
- self._aBack.setEnabled(False)
305
- self._aBack.setStatusTip(self.tr("Back"))
306
- self._aBack.setToolTip(self.tr("Back"))
307
-
308
- if (self._historyIndex + 1) < len(self._history):
309
- self._aForward.setEnabled(True)
310
- self._aForward.setStatusTip(self._history[self._historyIndex + 1])
311
- self._aForward.setToolTip(self._history[self._historyIndex + 1])
312
- else:
313
- self._aForward.setEnabled(False)
314
- self._aForward.setStatusTip(self.tr("Forward"))
315
- self._aForward.setToolTip(self.tr("Forward"))
316
-
317
- class Tree(QTreeView):
318
- """File system tree
319
- """
320
-
321
- _fileActivated = pyqtSignal()
322
-
323
- def __init__(self, fileBrowser):
324
- QTreeView.__init__(self, fileBrowser)
325
-
326
- self._fileBrowser = fileBrowser
327
-
328
- self.setAttribute( Qt.WA_MacShowFocusRect, False )
329
- self.setAttribute( Qt.WA_MacSmallSize )
330
- self.setContextMenuPolicy( Qt.ActionsContextMenu )
331
- self.setHeaderHidden( True )
332
- self.setUniformRowHeights( True )
333
- self.setTextElideMode(Qt.ElideMiddle)
334
-
335
- # dir model
336
- self._dirsModel = QFileSystemModel( self )
337
- self._dirsModel.setNameFilterDisables( False )
338
- self._dirsModel.setFilter( QDir.AllDirs | QDir.AllEntries | QDir.CaseSensitive | QDir.NoDotAndDotDot )
339
- # self._dirsModel.directoryLoaded.connect(self.setFocus) TODO don't have this signal in my Qt version
340
-
341
- # create proxy model
342
- self._filteredModel = FileBrowserFilteredModel( self )
343
- self._filteredModel.setSourceModel( self._dirsModel )
344
-
345
- self.setModel( self._filteredModel)
346
-
347
- if not sys.platform.startswith('win'):
348
- self._dirsModel.setRootPath( "/" )
349
- else:
350
- self._dirsModel.setRootPath('')
351
-
352
- # shortcut accessible only when self._tree has focus
353
- self._upShortcut = QShortcut( QKeySequence( "BackSpace" ), self )
354
- self._upShortcut.setContext( Qt.WidgetShortcut )
355
- self._upShortcut.activated.connect(self.moveUp)
356
-
357
- # shortcut accessible only when self._tree has focus
358
- self._homeShortcut = QShortcut( QKeySequence( "`" ), self )
359
- self._homeShortcut.setContext( Qt.WidgetShortcut )
360
- self._homeShortcut.activated.connect(self._goUserHomeDir)
361
-
362
- # shortcut accessible only when self._tree has focus
363
- self._homeShortcut = QShortcut( QKeySequence( "." ), self )
364
- self._homeShortcut.setContext( Qt.WidgetShortcut )
365
- self._homeShortcut.activated.connect(self._goCurrentDir)
366
-
367
- self.activated.connect(self._onActivated)
368
- self._fileActivated.connect(fileBrowser.fileActivated)
369
-
370
- # QDirModel loads item asynchronously, therefore we need timer for setting focus to the first item
371
- self._setFocusTimer = QTimer()
372
- self._setFocusTimer.timeout.connect(self._setFirstItemAsCurrent)
373
- self._setFocusTimer.setInterval(50)
374
- self._timerAttempts = 0
375
-
376
- def _onActivated(self, idx ):
377
- """File or directory doubleClicked
378
- """
379
- index = self._filteredModel.mapToSource( idx )
380
- path = self._dirsModel.filePath( index )
381
-
382
- if os.path.isdir( path ) :
383
- self._fileBrowser.setCurrentPath(path)
384
- else:
385
- self._fileActivated.emit()
386
- core.workspace().openFile(path)
387
-
388
- def moveUp(self):
389
- """User pressed Up key or button. Move focus and root up
390
- """
391
- current = self.currentIndex()
392
- if not current.isValid():
393
- current = self.rootIndex().child(0, 0)
394
- self.setCurrentIndex(current)
395
-
396
- if current.parent() == self.rootIndex() or \
397
- current == self.rootIndex(): # need to move root up
398
- if self.rootIndex().parent().isValid(): # not reached root of the FS tree
399
- newRoot = self.rootIndex().parent()
400
- parentPath = self._filteredModelIndexToPath(current.parent())
401
- self._fileBrowser.setCurrentPath(self._filteredModelIndexToPath(newRoot))
402
- self.collapseAll() # if moving root up - collapse all items
403
- parentIndex = self._filteredModel.mapFromSource(self._dirsModel.index(parentPath))
404
- self._setCurrentItem(parentIndex)
405
- else: # need to move selection up
406
- parentOfCurrent = self.currentIndex().parent()
407
- self._setCurrentItem(parentOfCurrent) # move selection up
408
-
409
- def _goUserHomeDir(self):
410
- """Go to home directory
411
- """
412
- self._fileBrowser.setCurrentPath(os.path.expanduser("~"))
413
- self.collapseAll()
414
-
415
- def _goCurrentDir(self):
416
- """Go to current directory
417
- """
418
- self._fileBrowser.setCurrentPath(os.path.abspath("."))
419
- self.collapseAll()
420
-
421
- def _filteredModelIndexToPath(self, index):
422
- """Map index to file path
423
- """
424
- srcIndex = self._filteredModel.mapToSource( index )
425
- return self._dirsModel.filePath( srcIndex )
426
-
427
- def currentPath(self):
428
- """Get current path (root of the tree)
429
- """
430
- index = self.rootIndex()
431
- index = self._filteredModel.mapToSource( index )
432
- return self._dirsModel.filePath( index )
433
-
434
- def _isDescendant(self, child, parent):
435
- """Check if child is descendant of parent
436
- """
437
- while child.isValid():
438
- if child.parent() == parent:
439
- return True
440
- child = child.parent()
441
- return False
442
-
443
- def _setFirstItemAsCurrent(self):
444
- """QDirModel loads items asynchronously.
445
- Therefore we select current item by timer
446
- """
447
- if not self.currentIndex().isValid() or \
448
- not self._isDescendant(self.currentIndex(), self.rootIndex()):
449
- firstChild = self.rootIndex().child(0, 0)
450
- if firstChild.isValid():
451
- self._setFocusTimer.stop()
452
- self._setCurrentItem(self.rootIndex().child(0, 0))
453
- else:
454
- self._timerAttempts -= 1
455
- if not self._timerAttempts:
456
- self._setFocusTimer.stop()
457
- else: # nothing to do, have focus
458
- self._setFocusTimer.stop()
459
-
460
- def setCurrentPath(self, path):
461
- """Set current path (root of the tree)
462
- """
463
- # get index
464
- index = self._dirsModel.index(path)
465
-
466
- # set current path
467
- self._filteredModel.invalidate()
468
- newRoot = self._filteredModel.mapFromSource( index )
469
- self.setRootIndex(newRoot)
470
-
471
- self._timerAttempts = 10
472
- self._setFocusTimer.start()
473
-
474
- def _setCurrentItem(self, index):
475
- """Make the item current and select it
476
- """
477
- self.setCurrentIndex(index)
478
- self.selectionModel().select(index, QItemSelectionModel.SelectCurrent)
479
-
480
- class ComboBox(QComboBox):
481
- """File browser combo box.
482
- Widget and functionality
483
- """
484
- def __init__(self, fileBrowser):
485
- QComboBox.__init__(self, fileBrowser)
486
-
487
- self._fileBrowser = fileBrowser
488
-
489
- self.setAttribute( Qt.WA_MacShowFocusRect, False )
490
- self.setAttribute( Qt.WA_MacSmallSize )
491
- self.setEditable(True)
492
- self.setMinimumContentsLength(1)
493
- self.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
494
- self.lineEdit().setReadOnly( False )
495
- self._completionModel = QDirModel(self.lineEdit())
496
- self._completionModel.setFilter( QDir.AllDirs | QDir.NoDotAndDotDot )
497
- self.lineEdit().setCompleter(QCompleter(self._completionModel,
498
- self.lineEdit()))
499
- #TODO QDirModel is deprecated but QCompleter does not yet handle
500
- #QFileSystemModel - please update when possible.
501
- self._count = 0
502
-
503
- # Show popup action
504
- self._showPopupAction = QAction(QIcon(':mksicons/filtered.png'), "File browser history", self)
505
- self._showPopupAction.setShortcut('Ctrl+H')
506
- core.actionManager().addAction("mNavigation/mFileBrowser/aMenuShow", self._showPopupAction)
507
- self._showPopupAction.triggered.connect(self._onShowPopup)
508
-
509
- # reconnected in self.updateComboItems()
510
- self.currentIndexChanged[int].connect(self._onItemSelected)
511
-
512
- def del_(self):
513
- """Explicitly called destructor
514
- """
515
- core.actionManager().removeAction(self._showPopupAction)
516
-
517
- def _onShowPopup(self, triggered):
518
- """Handler for self._showPopupAction
519
- """
520
- self.showPopup()
521
-
522
- @pyqtSlot(int)
523
- def _onItemSelected(self, index):
524
- """Handler of item selection in the combo box
525
- """
526
- if self.count() > self._count: # It is user input
527
- path = self.itemText(index)
528
- if os.path.isdir(path):
529
- self._fileBrowser.setCurrentPath(path)
530
- else:
531
- path = self.itemData(index).toString()
532
- self._fileBrowser.setCurrentPath(path)
533
-
534
- def updateItems(self, items):
535
- """Update items in the combo box according to current history
536
- """
537
- self.currentIndexChanged[int].disconnect()
538
- self.clear()
539
- # Current text
540
- self.addItem(self._fileBrowser.currentPath())
541
- self.setItemData(0, self._fileBrowser.currentPath())
542
- self.insertSeparator(self.count())
543
-
544
- for index, path in enumerate(items):
545
- self.addItem(path)
546
- self.setItemData(index + 2, path)
547
- self._count = self.count()
548
- self.currentIndexChanged[int].connect(self._onItemSelected)
549
-
550
-
551
- class DockFileBrowser(DockWidget):
552
- """UI interface of FileBrowser plugin.
553
-
554
- Dock with file system tree, Box, navigation in a file system
555
- tree, for moving root of tree to currently selected directory and
556
- up (relatively for current directory)
557
- """
558
- rootChanged = pyqtSignal(unicode)
559
- """
560
- rootChanged(path)
561
-
562
- **Signal** emitted, when tree root has been changed
563
- """ # pylint: disable=W0105
564
-
565
- fileActivated = pyqtSignal()
566
- """
567
- rootChanged(path)
568
-
569
- **Signal** emitted, when file has been activated
570
- """ # pylint: disable=W0105
571
-
572
- def __init__(self, parent):
573
- DockWidget.__init__(self, parent)
574
-
575
- self._comboBox = None
576
- self._tree = None
577
- self._smartRecents = None
578
- self._smartHistory = None
579
-
580
- self.setObjectName("FileBrowserDock")
581
- self.setWindowTitle(self.tr( "&File Browser" ))
582
- self.setWindowIcon(QIcon(':/mksicons/open.png'))
583
- # restrict areas
584
- self.setAllowedAreas( Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea )
585
-
586
- self.showAction().setShortcut("Alt+F")
587
- core.actionManager().addAction("mView/aFileBrowser", self.showAction())
588
-
589
- core.mainWindow().directoryDropt.connect(self._onDirectoryDropt)
590
-
591
- self.visibilityChanged.connect(self._onVisibilityChanged)
592
-
593
- def del_(self):
594
- """Explicitly called destructor
595
- """
596
- if self._smartHistory is not None:
597
- self._smartHistory.del_()
598
- if self._comboBox is not None:
599
- self._comboBox.del_()
600
- core.actionManager().removeAction("mView/aFileBrowser")
601
-
602
- def _onVisibilityChanged(self, visible):
603
- """Postnoted widget initialization.
604
- Create element, when widget appears first timer
605
- """
606
- if visible:
607
- self._initialize()
608
- self.visibilityChanged.disconnect(self._onVisibilityChanged)
609
-
610
- def _initialize(self):
611
- """Delayed initialization of the widget for quicker start of application
612
- """
613
- # central widget
614
- wdg = QWidget( self )
615
- self.setWidget( wdg )
616
-
617
- # vertical layout
618
- vertLayout = QVBoxLayout( wdg )
619
- vertLayout.setMargin( 5 )
620
- vertLayout.setSpacing( 3 )
621
-
622
- # combo
623
- self._comboBox = ComboBox(self)
624
- vertLayout.addWidget( self._comboBox )
625
-
626
- # hline
627
- hline = QFrame( self )
628
- hline.setFrameStyle( QFrame.HLine | QFrame.Sunken )
629
- vertLayout.addWidget( hline )
630
-
631
- # files view
632
- self._tree = Tree(self)
633
- vertLayout.addWidget( self._tree )
634
-
635
- # cd up button
636
- self._aCdUp = QAction( QIcon(':mksicons/go-up.png'),
637
- self.tr("Up"),
638
- self)
639
- self.titleBarWidget().addAction(self._aCdUp)
640
- self._aCdUp.triggered.connect(self.moveUp)
641
-
642
- # redirirect focus proxy
643
- self.setFocusProxy( self._tree )
644
-
645
- self._smartRecents = SmartRecents(self)
646
- self._smartHistory = SmartHistory(self)
647
-
648
- self.setCurrentPath(_getCurDir())
649
-
650
-
651
- def _onDirectoryDropt(self, path):
652
- """Directory drag-n-dropt to main window. Show it
653
- """
654
- self.setCurrentPath(path)
655
- self.show()
656
-
657
- @pyqtSlot(list)
658
- def updateComboItems(self, items):
659
- """Update items in the combo box according to current history
660
- """
661
- self._comboBox.updateItems(items)
662
-
663
- def currentPath(self):
664
- """Get current path (root of the tree)
665
- """
666
- return self._tree.currentPath()
667
-
668
- def setCurrentPath(self, path):
669
- """Set current path (root of the tree)
670
- If there are no documents on workspace, also changes process current directory
671
- """
672
- self._tree.setCurrentPath(path)
673
- self._tree.setFocus()
674
-
675
- # set lineedit path
676
- self._comboBox.setToolTip(path)
677
-
678
- # notify SmartRecents and own slots
679
- self.rootChanged.emit(path)
680
-
681
- # cd if no files with known path
682
- if not any([doc for doc in core.workspace().documents() \
683
- if doc.filePath() is not None]):
684
- os.chdir(path)
685
-
686
- def moveUp(self):
687
- """Move tree root up, or only move focus"""
688
- self.setCurrentPath(os.path.dirname(self._tree.currentPath()))
689
-
Widget/__init__.pyc CHANGED
Binary file
Widget/editor.pyc CHANGED
Binary file
Widget/httpWidget.pyc CHANGED
Binary file
Widget/run.pyc CHANGED
Binary file
Widget/tab.pyc CHANGED
Binary file
icons_rc.pyc CHANGED
Binary file
main.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  __author__ = "pyros2097"
3
3
  __license__ = "GPLv3"
4
- __version__ = "0.31"
4
+ __version__ = "0.32"
5
5
  __copyright__ = 'Copyright 2012, pyros2097'
6
6
  __credits__ = ['pyros2097', 'eclipse']
7
7
  __email__ = 'pyros2097@gmail.com'
main.pyc DELETED
Binary file
ui_simple.pyc CHANGED
Binary file