8 """ |
8 """ |
9 |
9 |
10 |
10 |
11 import os |
11 import os |
12 |
12 |
13 from PyQt5.QtCore import QModelIndex, pyqtSignal, Qt, QCoreApplication, \ |
13 from PyQt5.QtCore import ( |
14 QItemSelectionModel, QItemSelection, QElapsedTimer |
14 QModelIndex, pyqtSignal, Qt, QCoreApplication, QItemSelectionModel, |
|
15 QItemSelection, QElapsedTimer |
|
16 ) |
15 from PyQt5.QtGui import QCursor |
17 from PyQt5.QtGui import QCursor |
16 from PyQt5.QtWidgets import QTreeView, QApplication, QMenu, QDialog, \ |
18 from PyQt5.QtWidgets import ( |
17 QAbstractItemView |
19 QTreeView, QApplication, QMenu, QDialog, QAbstractItemView |
|
20 ) |
18 |
21 |
19 from E5Gui.E5Application import e5App |
22 from E5Gui.E5Application import e5App |
20 from E5Gui import E5MessageBox |
23 from E5Gui import E5MessageBox |
21 |
24 |
22 from UI.Browser import Browser |
25 from UI.Browser import Browser |
23 from UI.BrowserModel import BrowserDirectoryItem, BrowserFileItem |
26 from UI.BrowserModel import BrowserDirectoryItem, BrowserFileItem |
24 |
27 |
25 from .ProjectBrowserModel import ProjectBrowserSimpleDirectoryItem, \ |
28 from .ProjectBrowserModel import ( |
26 ProjectBrowserDirectoryItem, ProjectBrowserFileItem |
29 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, |
27 from .ProjectBrowserSortFilterProxyModel import \ |
30 ProjectBrowserFileItem |
|
31 ) |
|
32 from .ProjectBrowserSortFilterProxyModel import ( |
28 ProjectBrowserSortFilterProxyModel |
33 ProjectBrowserSortFilterProxyModel |
|
34 ) |
29 |
35 |
30 |
36 |
31 class ProjectBaseBrowser(Browser): |
37 class ProjectBaseBrowser(Browser): |
32 """ |
38 """ |
33 Baseclass implementing common functionality for the various project |
39 Baseclass implementing common functionality for the various project |
281 dn = itm.dirName() |
287 dn = itm.dirName() |
282 fullNames.append(dn) |
288 fullNames.append(dn) |
283 dn = self.project.getRelativePath(dn) |
289 dn = self.project.getRelativePath(dn) |
284 dirs.append(dn) |
290 dirs.append(dn) |
285 |
291 |
286 from UI.DeleteFilesConfirmationDialog import \ |
292 from UI.DeleteFilesConfirmationDialog import ( |
287 DeleteFilesConfirmationDialog |
293 DeleteFilesConfirmationDialog |
|
294 ) |
288 dlg = DeleteFilesConfirmationDialog( |
295 dlg = DeleteFilesConfirmationDialog( |
289 self.parent(), |
296 self.parent(), |
290 QCoreApplication.translate( |
297 QCoreApplication.translate( |
291 "ProjectBaseBrowser", "Delete directories"), |
298 "ProjectBaseBrowser", "Delete directories"), |
292 QCoreApplication.translate( |
299 QCoreApplication.translate( |
362 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
369 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
363 QApplication.processEvents() |
370 QApplication.processEvents() |
364 index = self.model().index(0, 0) |
371 index = self.model().index(0, 0) |
365 while index.isValid(): |
372 while index.isValid(): |
366 itm = self.model().item(index) |
373 itm = self.model().item(index) |
367 if (isinstance(itm, ProjectBrowserSimpleDirectoryItem) or |
374 if ( |
368 isinstance(itm, ProjectBrowserDirectoryItem)) and \ |
375 isinstance( |
369 not self.isExpanded(index): |
376 itm, |
|
377 (ProjectBrowserSimpleDirectoryItem, |
|
378 ProjectBrowserDirectoryItem)) and |
|
379 not self.isExpanded(index) |
|
380 ): |
370 self.expand(index) |
381 self.expand(index) |
371 index = self.indexBelow(index) |
382 index = self.indexBelow(index) |
372 self.layoutDisplay() |
383 self.layoutDisplay() |
373 self._connectExpandedCollapsed() |
384 self._connectExpandedCollapsed() |
374 QApplication.restoreOverrideCursor() |
385 QApplication.restoreOverrideCursor() |
389 |
400 |
390 # step 2: go up collapsing all directory items |
401 # step 2: go up collapsing all directory items |
391 index = vindex |
402 index = vindex |
392 while index.isValid(): |
403 while index.isValid(): |
393 itm = self.model().item(index) |
404 itm = self.model().item(index) |
394 if (isinstance(itm, ProjectBrowserSimpleDirectoryItem) or |
405 if ( |
395 isinstance(itm, ProjectBrowserDirectoryItem)) and \ |
406 isinstance( |
396 self.isExpanded(index): |
407 itm, |
|
408 (ProjectBrowserSimpleDirectoryItem, |
|
409 ProjectBrowserDirectoryItem)) and |
|
410 self.isExpanded(index) |
|
411 ): |
397 self.collapse(index) |
412 self.collapse(index) |
398 index = self.indexAbove(index) |
413 index = self.indexAbove(index) |
399 self.layoutDisplay() |
414 self.layoutDisplay() |
400 self._connectExpandedCollapsed() |
415 self._connectExpandedCollapsed() |
401 QApplication.restoreOverrideCursor() |
416 QApplication.restoreOverrideCursor() |
481 """ |
496 """ |
482 if self.project.vcs is None: |
497 if self.project.vcs is None: |
483 return |
498 return |
484 |
499 |
485 if local: |
500 if local: |
486 compareString = \ |
501 compareString = QCoreApplication.translate( |
487 QCoreApplication.translate('ProjectBaseBrowser', "local") |
502 'ProjectBaseBrowser', "local") |
488 else: |
503 else: |
489 compareString = self.project.vcs.vcsName() |
504 compareString = self.project.vcs.vcsName() |
490 |
505 |
491 # expand all directories in order to iterate over all entries |
506 # expand all directories in order to iterate over all entries |
492 self._expandAllDirs() |
507 self._expandAllDirs() |
501 endIndex = None |
516 endIndex = None |
502 selectedEntries = 0 |
517 selectedEntries = 0 |
503 index = self.model().index(0, 0) |
518 index = self.model().index(0, 0) |
504 while index.isValid(): |
519 while index.isValid(): |
505 itm = self.model().item(index) |
520 itm = self.model().item(index) |
506 if self.wantedItem(itm, filterList) and \ |
521 if ( |
507 compareString == itm.data(1): |
522 self.wantedItem(itm, filterList) and |
508 if startIndex is not None and \ |
523 compareString == itm.data(1) |
509 startIndex.parent() != index.parent(): |
524 ): |
|
525 if ( |
|
526 startIndex is not None and |
|
527 startIndex.parent() != index.parent() |
|
528 ): |
510 self._setItemRangeSelected(startIndex, endIndex, True) |
529 self._setItemRangeSelected(startIndex, endIndex, True) |
511 startIndex = None |
530 startIndex = None |
512 selectedEntries += 1 |
531 selectedEntries += 1 |
513 if startIndex is None: |
532 if startIndex is None: |
514 startIndex = index |
533 startIndex = index |
643 index = self.model().mapFromSource(sindex) |
662 index = self.model().mapFromSource(sindex) |
644 if index.isValid(): |
663 if index.isValid(): |
645 if self.isExpanded(index): |
664 if self.isExpanded(index): |
646 childIndex = self.indexBelow(index) |
665 childIndex = self.indexBelow(index) |
647 while childIndex.isValid(): |
666 while childIndex.isValid(): |
648 if not childIndex.isValid() or \ |
667 if ( |
649 childIndex.parent() == index.parent(): |
668 not childIndex.isValid() or |
|
669 childIndex.parent() == index.parent() |
|
670 ): |
650 break |
671 break |
651 itm = self.model().item(childIndex) |
672 itm = self.model().item(childIndex) |
652 if itm is not None: |
673 if itm is not None: |
653 itemData = itm.data(0) |
674 itemData = itm.data(0) |
654 if self.currentItemName and \ |
675 if ( |
655 self.currentItemName == itemData: |
676 self.currentItemName and |
|
677 self.currentItemName == itemData |
|
678 ): |
656 self._selectSingleItem(childIndex) |
679 self._selectSingleItem(childIndex) |
657 if itemData in self.expandedNames: |
680 if itemData in self.expandedNames: |
658 self.setExpanded(childIndex, True) |
681 self.setExpanded(childIndex, True) |
659 childIndex = self.indexBelow(childIndex) |
682 childIndex = self.indexBelow(childIndex) |
660 else: |
683 else: |