Beispiel #1
0
    def __init__(self, editorTabWidget, root, app, projectSettings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.refactor = editorTabWidget.refactor
        self.root = root

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.setContentsMargins(0, 0, 2, 2)
        self.setLayout(mainLayout)

        self.progressWidget = ProgressWidget()
        mainLayout.addWidget(self.progressWidget)
        self.progressWidget.hide()

        self.viewStack = QtGui.QStackedWidget()
        mainLayout.addWidget(self.viewStack)

        self.projectTree = ProjectTree(
            editorTabWidget, root, app, projectSettings, self.progressWidget, self)
        self.viewStack.addWidget(self.projectTree)

        self.searchResultsTree = QtGui.QTreeWidget(self)
        self.searchResultsTree.setObjectName("sidebarItem")
        self.searchResultsTree.setHeaderItem(
            QtGui.QTreeWidgetItem(["Search Results:"]))
        self.searchResultsTree.activated.connect(self.loadFile)
        self.viewStack.addWidget(self.searchResultsTree)

        self.searchThread = SearchThread()
        self.searchThread.foundList.connect(self.updateSearchTree)

        self.searchTimer = QtCore.QTimer()
        self.searchTimer.setSingleShot(True)
        self.searchTimer.timeout.connect(self.search)
        
        vbox = QtGui.QVBoxLayout()
        vbox.setSpacing(0)
        mainLayout.addLayout(vbox)

        self.searchLine = LineEdit(self.viewStack, self.searchResultsTree)
        self.searchLine.textChanged.connect(self.startSearchTimer)
        self.searchLine.returnPressed.connect(self.loadFile)
        vbox.addWidget(self.searchLine)

        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setMaximumHeight(2)
        self.progressBar.setStyleSheet(
            """

                                  QProgressBar {
                                     border: None;
                                     text-align: center;
                                     padding: 0px;
                                     border-radius: 0px;
                                     background-color: Transparent;
                                 }

                                 QProgressBar::chunk {
                                      color: black;
                                      border-radius: 0px;
                                      background-color: #65B0EA;
                                 }

                                """
            )
        self.progressBar.setRange(0, 0)
        vbox.addWidget(self.progressBar)
        self.progressBar.hide()
Beispiel #2
0
    def __init__(self,
                 editorTabWidget,
                 root,
                 app,
                 projectSettings,
                 parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.refactor = editorTabWidget.refactor
        self.root = root

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.setContentsMargins(0, 0, 2, 2)
        self.setLayout(mainLayout)

        self.progressWidget = ProgressWidget()
        mainLayout.addWidget(self.progressWidget)
        self.progressWidget.hide()

        self.viewStack = QtGui.QStackedWidget()
        mainLayout.addWidget(self.viewStack)

        self.projectTree = ProjectTree(editorTabWidget, root, app,
                                       projectSettings, self.progressWidget,
                                       self)
        self.viewStack.addWidget(self.projectTree)

        self.searchResultsTree = QtGui.QTreeWidget(self)
        self.searchResultsTree.setObjectName("sidebarItem")
        self.searchResultsTree.setHeaderItem(
            QtGui.QTreeWidgetItem(["Search Results:"]))
        self.searchResultsTree.activated.connect(self.loadFile)
        self.viewStack.addWidget(self.searchResultsTree)

        self.searchThread = SearchThread()
        self.searchThread.foundList.connect(self.updateSearchTree)

        self.searchTimer = QtCore.QTimer()
        self.searchTimer.setSingleShot(True)
        self.searchTimer.timeout.connect(self.search)

        vbox = QtGui.QVBoxLayout()
        vbox.setSpacing(0)
        mainLayout.addLayout(vbox)

        self.searchLine = LineEdit(self.viewStack, self.searchResultsTree)
        self.searchLine.textChanged.connect(self.startSearchTimer)
        self.searchLine.returnPressed.connect(self.loadFile)
        vbox.addWidget(self.searchLine)

        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setMaximumHeight(2)
        self.progressBar.setStyleSheet("""

                                  QProgressBar {
                                     border: None;
                                     text-align: center;
                                     padding: 0px;
                                     border-radius: 0px;
                                     background-color: Transparent;
                                 }

                                 QProgressBar::chunk {
                                      color: black;
                                      border-radius: 0px;
                                      background-color: #65B0EA;
                                 }

                                """)
        self.progressBar.setRange(0, 0)
        vbox.addWidget(self.progressBar)
        self.progressBar.hide()
Beispiel #3
0
class ProjectView(QtGui.QWidget):

    fileActivated = QtCore.pyqtSignal(str)

    def __init__(self, editorTabWidget, root, app, projectSettings, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.refactor = editorTabWidget.refactor
        self.root = root

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.setContentsMargins(0, 0, 2, 2)
        self.setLayout(mainLayout)

        self.progressWidget = ProgressWidget()
        mainLayout.addWidget(self.progressWidget)
        self.progressWidget.hide()

        self.viewStack = QtGui.QStackedWidget()
        mainLayout.addWidget(self.viewStack)

        self.projectTree = ProjectTree(
            editorTabWidget, root, app, projectSettings, self.progressWidget, self)
        self.viewStack.addWidget(self.projectTree)

        self.searchResultsTree = QtGui.QTreeWidget(self)
        self.searchResultsTree.setObjectName("sidebarItem")
        self.searchResultsTree.setHeaderItem(
            QtGui.QTreeWidgetItem(["Search Results:"]))
        self.searchResultsTree.activated.connect(self.loadFile)
        self.viewStack.addWidget(self.searchResultsTree)

        self.searchThread = SearchThread()
        self.searchThread.foundList.connect(self.updateSearchTree)

        self.searchTimer = QtCore.QTimer()
        self.searchTimer.setSingleShot(True)
        self.searchTimer.timeout.connect(self.search)
        
        vbox = QtGui.QVBoxLayout()
        vbox.setSpacing(0)
        mainLayout.addLayout(vbox)

        self.searchLine = LineEdit(self.viewStack, self.searchResultsTree)
        self.searchLine.textChanged.connect(self.startSearchTimer)
        self.searchLine.returnPressed.connect(self.loadFile)
        vbox.addWidget(self.searchLine)

        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setMaximumHeight(2)
        self.progressBar.setStyleSheet(
            """

                                  QProgressBar {
                                     border: None;
                                     text-align: center;
                                     padding: 0px;
                                     border-radius: 0px;
                                     background-color: Transparent;
                                 }

                                 QProgressBar::chunk {
                                      color: black;
                                      border-radius: 0px;
                                      background-color: #65B0EA;
                                 }

                                """
            )
        self.progressBar.setRange(0, 0)
        vbox.addWidget(self.progressBar)
        self.progressBar.hide()
        
    def startSearchTimer(self):
        self.searchTimer.start(300)

    def loadFile(self):
        if len(self.searchResultsTree.selectedItems()) > 0:
            item = self.searchResultsTree.selectedItems()[0]
            if item.parent() is None:
                pass
            else:
                parentDir = item.parent().text(0)
                path = os.path.join(self.root, parentDir, item.text(0))
                self.fileActivated.emit(path)

    def search(self):
        text = self.searchLine.text().strip()
        if text == '':
            self.viewStack.setCurrentIndex(0)
            return
        self.searchThread.search(text, self.refactor.root,
                                self.projectTree.showAllFilesAct.isChecked())
        self.progressBar.show()

    def updateSearchTree(self, resultsDict):
        self.progressBar.hide()
        self.searchResultsTree.clear()
        self.viewStack.setCurrentIndex(1)
        if len(resultsDict) > 0:
            for folder, fileList in resultsDict.items():
                folderItem = QtGui.QTreeWidgetItem(self.searchResultsTree)
                pathRelativeToProject = folder.partition(
                    self.root + os.path.sep)[-1]
                folderItem.setText(0, pathRelativeToProject)
                folderItem.setForeground(0, QtGui.QBrush(
                    QtGui.QColor("#003366")))
                for i in fileList:
                    fileItem = QtGui.QTreeWidgetItem(folderItem)
                    icon = Global.iconFromPath(os.path.join(folder, i))
                    fileItem.setText(0, i)
                    fileItem.setIcon(0, QtGui.QIcon(icon))
                folderItem.setExpanded(True)

            item = self.searchResultsTree.topLevelItem(0)
            self.searchResultsTree.setCurrentItem(item.child(0))
        else:
            folderItem = QtGui.QTreeWidgetItem()
            item = QtGui.QTreeWidgetItem()
            item.setText(0, "<No results found>")
            item.setFlags(QtCore.Qt.NoItemFlags)
            folderItem.addChild(item)
            self.searchResultsTree.addTopLevelItem(folderItem)
            folderItem.setExpanded(True)
Beispiel #4
0
class ProjectView(QtGui.QWidget):

    fileActivated = QtCore.pyqtSignal(str)

    def __init__(self,
                 editorTabWidget,
                 root,
                 app,
                 projectSettings,
                 parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.refactor = editorTabWidget.refactor
        self.root = root

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.setContentsMargins(0, 0, 2, 2)
        self.setLayout(mainLayout)

        self.progressWidget = ProgressWidget()
        mainLayout.addWidget(self.progressWidget)
        self.progressWidget.hide()

        self.viewStack = QtGui.QStackedWidget()
        mainLayout.addWidget(self.viewStack)

        self.projectTree = ProjectTree(editorTabWidget, root, app,
                                       projectSettings, self.progressWidget,
                                       self)
        self.viewStack.addWidget(self.projectTree)

        self.searchResultsTree = QtGui.QTreeWidget(self)
        self.searchResultsTree.setObjectName("sidebarItem")
        self.searchResultsTree.setHeaderItem(
            QtGui.QTreeWidgetItem(["Search Results:"]))
        self.searchResultsTree.activated.connect(self.loadFile)
        self.viewStack.addWidget(self.searchResultsTree)

        self.searchThread = SearchThread()
        self.searchThread.foundList.connect(self.updateSearchTree)

        self.searchTimer = QtCore.QTimer()
        self.searchTimer.setSingleShot(True)
        self.searchTimer.timeout.connect(self.search)

        vbox = QtGui.QVBoxLayout()
        vbox.setSpacing(0)
        mainLayout.addLayout(vbox)

        self.searchLine = LineEdit(self.viewStack, self.searchResultsTree)
        self.searchLine.textChanged.connect(self.startSearchTimer)
        self.searchLine.returnPressed.connect(self.loadFile)
        vbox.addWidget(self.searchLine)

        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setMaximumHeight(2)
        self.progressBar.setStyleSheet("""

                                  QProgressBar {
                                     border: None;
                                     text-align: center;
                                     padding: 0px;
                                     border-radius: 0px;
                                     background-color: Transparent;
                                 }

                                 QProgressBar::chunk {
                                      color: black;
                                      border-radius: 0px;
                                      background-color: #65B0EA;
                                 }

                                """)
        self.progressBar.setRange(0, 0)
        vbox.addWidget(self.progressBar)
        self.progressBar.hide()

    def startSearchTimer(self):
        self.searchTimer.start(300)

    def loadFile(self):
        if len(self.searchResultsTree.selectedItems()) > 0:
            item = self.searchResultsTree.selectedItems()[0]
            if item.parent() is None:
                pass
            else:
                parentDir = item.parent().text(0)
                path = os.path.join(self.root, parentDir, item.text(0))
                self.fileActivated.emit(path)

    def search(self):
        text = self.searchLine.text().strip()
        if text == '':
            self.viewStack.setCurrentIndex(0)
            return
        self.searchThread.search(text, self.refactor.root,
                                 self.projectTree.showAllFilesAct.isChecked())
        self.progressBar.show()

    def updateSearchTree(self, resultsDict):
        self.progressBar.hide()
        self.searchResultsTree.clear()
        self.viewStack.setCurrentIndex(1)
        if len(resultsDict) > 0:
            for folder, fileList in resultsDict.items():
                folderItem = QtGui.QTreeWidgetItem(self.searchResultsTree)
                pathRelativeToProject = folder.partition(self.root +
                                                         os.path.sep)[-1]
                folderItem.setText(0, pathRelativeToProject)
                folderItem.setForeground(0,
                                         QtGui.QBrush(QtGui.QColor("#003366")))
                for i in fileList:
                    fileItem = QtGui.QTreeWidgetItem(folderItem)
                    icon = Global.iconFromPath(os.path.join(folder, i))
                    fileItem.setText(0, i)
                    fileItem.setIcon(0, QtGui.QIcon(icon))
                folderItem.setExpanded(True)

            item = self.searchResultsTree.topLevelItem(0)
            self.searchResultsTree.setCurrentItem(item.child(0))
        else:
            folderItem = QtGui.QTreeWidgetItem()
            item = QtGui.QTreeWidgetItem()
            item.setText(0, "<No results found>")
            item.setFlags(QtCore.Qt.NoItemFlags)
            folderItem.addChild(item)
            self.searchResultsTree.addTopLevelItem(folderItem)
            folderItem.setExpanded(True)