Ejemplo n.º 1
0
 def treeIncremNext(self):
     """Search for next occurance of increm string"""
     if self.incremSearchStr:
         if globalref.docRef.selection.findNextTitle(self.incremSearchStr, True):
             globalref.setStatusBar(_("Next:  %s") % self.incremSearchStr, 0, True)
         else:
             globalref.setStatusBar(_("Next:  %s  (not found)") % self.incremSearchStr, 0, True)
Ejemplo n.º 2
0
 def firstWindow(self, fileNames):
     """Open first main window"""
     try:
         # check for existing TreeLine session
         socket = QtNetwork.QLocalSocket()
         socket.connectToServer('treeline-session',
                                QtCore.QIODevice.WriteOnly)
         # if found, send files to open and exit TreeLine
         if socket.waitForConnected(1000):
             socket.write(repr(fileNames))
             if socket.waitForBytesWritten(1000):
                 socket.close()
                 sys.exit(0)
         qApp = QtGui.QApplication.instance()
         # start local server to listen for attempt to start new session
         self.serverSocket = QtNetwork.QLocalServer()
         self.serverSocket.listen('treeline-session')
         qApp.connect(self.serverSocket, QtCore.SIGNAL('newConnection()'),
                      self.getSocket)
     except AttributeError:
         print 'Warning:  Could not create local socket'
     if fileNames:
         fileNames = [unicode(fileName, globalref.localTextEncoding) for
                      fileName in fileNames]
         self.openMultipleFiles(fileNames)
     else:
         win = treemainwin.TreeMainWin()
         self.windowList.append(win)
         self.updateWinMenu()
         self.autoOpen()
         win.show()
     globalref.setStatusBar(_('Ready'), 2000)
Ejemplo n.º 3
0
 def treeIncremPrev(self):
     """Search for previous occurance of increm string"""
     if self.incremSearchStr:
         if globalref.docRef.selection.findNextTitle(self.incremSearchStr, False):
             globalref.setStatusBar(_("Previous:  %s") % self.incremSearchStr, 0, True)
         else:
             globalref.setStatusBar(_("Previous:  %s  (not found)") % self.incremSearchStr, 0, True)
Ejemplo n.º 4
0
 def keyPressEvent(self, event):
     """Bind keys to functions"""
     keyText = unicode(event.text())
     if self.incremSearchMode:
         if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter, QtCore.Qt.Key_Escape):
             self.incremSearchMode = False
             globalref.setStatusBar("")
         elif event.key() == QtCore.Qt.Key_Backspace and self.incremSearchStr:
             self.incremSearchStr = self.incremSearchStr[:-1]
             self.doIncremSearch()
         elif keyText and keyText in string.printable:
             self.incremSearchStr += keyText
             self.doIncremSearch()
         event.accept()
     elif (
         event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter)
         and event.modifiers() == QtCore.Qt.NoModifier
         and globalref.options.boolData("InsertOnEnter")
         and self.state() != QtGui.QAbstractItemView.EditingState
     ):
         if len(globalref.docRef.selection) == 1 and not globalref.docRef.selection[0].parent:
             globalref.mainWin.editAddChild()  # only root selected
         else:
             globalref.mainWin.editInAfter()
         event.accept()
     else:
         origX = self.horizontalScrollBar().value()
         QtGui.QTreeWidget.keyPressEvent(self, event)
         self.horizontalScrollBar().setValue(origX)
Ejemplo n.º 5
0
 def keyPressEvent(self, event):
     """Bind keys to functions"""
     keyText = unicode(event.text())
     if self.incremSearchMode:
         if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter,
                            QtCore.Qt.Key_Escape):
             self.incremSearchMode = False
             globalref.setStatusBar('')
         elif event.key() == QtCore.Qt.Key_Backspace and \
                             self.incremSearchStr:
             self.incremSearchStr = self.incremSearchStr[:-1]
             self.doIncremSearch()
         elif keyText and keyText in string.printable:
             self.incremSearchStr += keyText
             self.doIncremSearch()
         event.accept()
     elif event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter) and \
             event.modifiers() == QtCore.Qt.NoModifier and \
             globalref.options.boolData('InsertOnEnter') and \
             self.state() != QtGui.QAbstractItemView.EditingState:
         if len(globalref.docRef.selection) == 1 and \
                    not globalref.docRef.selection[0].parent:
             globalref.mainWin.editAddChild()  # only root selected
         else:
             globalref.mainWin.editInAfter()
         event.accept()
     else:
         origX = self.horizontalScrollBar().value()
         QtGui.QTreeWidget.keyPressEvent(self, event)
         self.horizontalScrollBar().setValue(origX)
Ejemplo n.º 6
0
 def firstWindow(self, fileNames):
     """Open first main window"""
     try:
         # check for existing TreeLine session
         socket = QtNetwork.QLocalSocket()
         socket.connectToServer('treeline-session',
                                QtCore.QIODevice.WriteOnly)
         # if found, send files to open and exit TreeLine
         if socket.waitForConnected(1000):
             socket.write(repr(fileNames))
             if socket.waitForBytesWritten(1000):
                 socket.close()
                 sys.exit(0)
         qApp = QtGui.QApplication.instance()
         # start local server to listen for attempt to start new session
         self.serverSocket = QtNetwork.QLocalServer()
         self.serverSocket.listen('treeline-session')
         qApp.connect(self.serverSocket, QtCore.SIGNAL('newConnection()'),
                      self.getSocket)
     except AttributeError:
         print 'Warning:  Could not create local socket'
     if fileNames:
         fileNames = [unicode(fileName, globalref.localTextEncoding) for
                      fileName in fileNames]
         self.openMultipleFiles(fileNames)
     else:
         win = treemainwin.TreeMainWin()
         self.windowList.append(win)
         self.updateWinMenu()
         self.autoOpen()
         win.show()
     globalref.setStatusBar(_('Ready'), 2000)
Ejemplo n.º 7
0
 def treeIncremPrev(self):
     """Search for previous occurance of increm string"""
     if self.incremSearchStr:
         if self.findTitleText(self.incremSearchStr, False, False):
             globalref.setStatusBar(_('Previous:  %s') %
                                    self.incremSearchStr, 0, True)
         else:
             globalref.setStatusBar(_('Previous:  %s  (not found)') %
                                    self.incremSearchStr, 0, True)
Ejemplo n.º 8
0
 def treeIncremPrev(self):
     """Search for previous occurance of increm string"""
     if self.incremSearchStr:
         if self.findTitleText(self.incremSearchStr, False, False):
             globalref.setStatusBar(
                 _('Previous:  %s') % self.incremSearchStr, 0, True)
         else:
             globalref.setStatusBar(
                 _('Previous:  %s  (not found)') % self.incremSearchStr, 0,
                 True)
Ejemplo n.º 9
0
 def treeIncremNext(self):
     """Search for next occurance of increm string"""
     if self.incremSearchStr:
         if globalref.docRef.selection.findNextTitle(
                 self.incremSearchStr, True):
             globalref.setStatusBar(
                 _('Next:  %s') % self.incremSearchStr, 0, True)
         else:
             globalref.setStatusBar(
                 _('Next:  %s  (not found)') % self.incremSearchStr, 0,
                 True)
Ejemplo n.º 10
0
 def mousePressEvent(self, event):
     """Mouse press down event saves selected item for rename"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar('')
     clickedItem = self.itemAt(event.pos())
     if not clickedItem:  # skip unselecting click on blank space
         return
     if self.noSelectClickCallback:
         self.noSelectClickCallback(clickedItem.docItemRef)
         self.noSelectClickCallback = None
         return
     if event.button() == QtCore.Qt.RightButton:
         return           # stop rename when context menu is used
     QtGui.QListWidget.mousePressEvent(self, event)
Ejemplo n.º 11
0
 def mousePressEvent(self, event):
     """Mouse press down event saves selected item for rename"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar('')
     clickedItem = self.itemAt(event.pos())
     if not clickedItem:  # skip unselecting click on blank space
         return
     if self.noSelectClickCallback:
         self.noSelectClickCallback(clickedItem.docItemRef)
         self.noSelectClickCallback = None
         return
     if event.button() == QtCore.Qt.RightButton:
         return  # stop rename when context menu is used
     QtGui.QListWidget.mousePressEvent(self, event)
Ejemplo n.º 12
0
 def keyPressEvent(self, event):
     """Bind keys to functions"""
     keyText = unicode(event.text())
     if self.incremSearchMode:
         if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter,
                            QtCore.Qt.Key_Escape):
             self.incremSearchMode = False
             globalref.setStatusBar('')
         elif event.key() == QtCore.Qt.Key_Backspace and \
                             self.incremSearchStr:
             self.incremSearchStr = self.incremSearchStr[:-1]
             self.doIncremSearch()
         elif keyText and keyText in string.printable:
             self.incremSearchStr += keyText
             self.doIncremSearch()
         event.accept()
     else:
         QtGui.QListWidget.keyPressEvent(self, event)
Ejemplo n.º 13
0
 def keyPressEvent(self, event):
     """Bind keys to functions"""
     keyText = unicode(event.text())
     if self.incremSearchMode:
         if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter,
                            QtCore.Qt.Key_Escape):
             self.incremSearchMode = False
             globalref.setStatusBar('')
         elif event.key() == QtCore.Qt.Key_Backspace and \
                             self.incremSearchStr:
             self.incremSearchStr = self.incremSearchStr[:-1]
             self.doIncremSearch()
         elif keyText and keyText in string.printable:
             self.incremSearchStr += keyText
             self.doIncremSearch()
         event.accept()
     else:
         QtGui.QListWidget.keyPressEvent(self, event)
Ejemplo n.º 14
0
 def doIncremSearch(self):
     """Search for searchStr in all titles"""
     globalref.setStatusBar(_("Search for: %s") % self.incremSearchStr, 0, True)
     if globalref.docRef.selection.findTitleText(self.incremSearchStr):
         globalref.setStatusBar(_("Search for: %s") % self.incremSearchStr, 0, True)
     else:
         globalref.setStatusBar(_("Search for: %s  (not found)") % self.incremSearchStr, 0, True)
Ejemplo n.º 15
0
 def mousePressEvent(self, event):
     """Mouse press down event stores position to check for dragging
        and selects item on right-click for popup menu"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar("")
     clickedItem = self.itemAt(event.pos())
     if not clickedItem:  # skip unselecting click on blank space
         self.dragStartPos = None
         return
     if self.noSelectClickCallback:
         self.noSelectClickCallback(clickedItem.docItemRef)
         self.noSelectClickCallback = None
         return
     if event.button() == QtCore.Qt.LeftButton:
         self.dragStartPos = QtCore.QPoint(event.pos())
     elif event.button() == QtCore.Qt.RightButton:
         return  # stop rename when context menu is used
     origX = self.horizontalScrollBar().value()
     QtGui.QTreeWidget.mousePressEvent(self, event)
     # work around Qt bug - can't set to old value directly?
     self.horizontalScrollBar().setValue(origX + 1)
     self.horizontalScrollBar().setValue(origX)
Ejemplo n.º 16
0
 def mousePressEvent(self, event):
     """Mouse press down event stores position to check for dragging
        and selects item on right-click for popup menu"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar('')
     clickedItem = self.itemAt(event.pos())
     if not clickedItem:  # skip unselecting click on blank space
         self.dragStartPos = None
         return
     if self.noSelectClickCallback:
         self.noSelectClickCallback(clickedItem.docItemRef)
         self.noSelectClickCallback = None
         return
     if event.button() == QtCore.Qt.LeftButton:
         self.dragStartPos = QtCore.QPoint(event.pos())
     elif event.button() == QtCore.Qt.RightButton:
         return  # stop rename when context menu is used
     origX = self.horizontalScrollBar().value()
     QtGui.QTreeWidget.mousePressEvent(self, event)
     # work around Qt bug - can't set to old value directly?
     self.horizontalScrollBar().setValue(origX + 1)
     self.horizontalScrollBar().setValue(origX)
Ejemplo n.º 17
0
 def doIncremSearch(self):
     """Search for searchStr in all titles"""
     globalref.setStatusBar(_('Search for: %s') % self.incremSearchStr,
                            0, True)
     if self.findTitleText(self.incremSearchStr):
         globalref.setStatusBar(_('Search for: %s') % self.incremSearchStr,
                                0, True)
     else:
         globalref.setStatusBar(_('Search for: %s  (not found)') %
                                          self.incremSearchStr, 0, True)
Ejemplo n.º 18
0
 def doIncremSearch(self):
     """Search for searchStr in all titles"""
     globalref.setStatusBar(
         _('Search for: %s') % self.incremSearchStr, 0, True)
     if self.findTitleText(self.incremSearchStr):
         globalref.setStatusBar(
             _('Search for: %s') % self.incremSearchStr, 0, True)
     else:
         globalref.setStatusBar(
             _('Search for: %s  (not found)') % self.incremSearchStr, 0,
             True)
Ejemplo n.º 19
0
 def focusOutEvent(self, event):
     """Stop incremental search on focus loss"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar("")
     QtGui.QTreeWidget.focusOutEvent(self, event)
Ejemplo n.º 20
0
 def showLink(self, text):
     """Send link text to the statusbar"""
     text = xml.sax.saxutils.unescape(unicode(text), treedoc.unEscDict)
     globalref.setStatusBar(text)
Ejemplo n.º 21
0
 def treeIncremSearch(self):
     """Begin iterative search"""
     self.incremSearchMode = True
     self.incremSearchStr = ""
     globalref.setStatusBar(_("Search for:"), 0, True)
Ejemplo n.º 22
0
 def focusOutEvent(self, event):
     """Stop incremental search on focus loss"""
     if self.incremSearchMode:
         self.incremSearchMode = False
         globalref.setStatusBar('')
     QtGui.QListWidget.focusOutEvent(self, event)
Ejemplo n.º 23
0
 def treeIncremSearch(self):
     """Begin iterative search"""
     self.incremSearchMode = True
     self.incremSearchStr = ''
     globalref.setStatusBar(_('Search for:'), 0, True)