コード例 #1
0
def main():
    app = QApplication(sys.argv)

    QCoreApplication.setOrganizationName(AUTHOR)
    QCoreApplication.setApplicationName(APP_NAME)

    from itreefile import IResNode

    root = IResNode()
    root.insert('hh/a.jpg', 'temp/1.png')
    root.insert('a.jpg', 'temp/1.png')

    p = root.at(root.findName('a.jpg')).dataPointer()
    root.insert('b.jpg', p)

    mainWindow = DialogInsertFile(root, '/')
    mainWindow.show()

    sys.exit(app.exec_())
コード例 #2
0
ファイル: itree.py プロジェクト: peior/ITree
 def closeFile(self):
     """ close a file """
     if self.maybeSave():
         del self.nodeRoot
         del self.resRoot
         self.nodeRoot = INode()
         self.resRoot = IResNode()
         self.mainWidget.setRoot(self.nodeRoot)
         self.mainWidget.setResRoot(self.resRoot)
         self.resCurrentPath = '/'
         self.setCurrentName('')
         self.actionRedo.setEnabled(False)
         self.actionUndo.setEnabled(False)
コード例 #3
0
 def actionNewFolder(self):
     name, ok = QInputDialog.getText(None, self.tr("New Folder"),
                                     self.tr('Input a string'),
                                     QLineEdit.Normal, self.tr('Untitled'))
     if ok:
         if not IResNode.isNameVaild(name):
             QMessageBox.warning(self, self.tr('Error'),
                                 self.tr('name is invalid'))
             return
         while self.currentNode.findName(name) != -1:
             name = '-' + name
         self.currentNode.insert(name)
         row, info = self.findInfo(self.currentNode, name)
         self.insertItem(row, self.makeItem(info.name, info.isFile))
         self.setCurrentRow(row)
         self.isModified = True
コード例 #4
0
ファイル: itree.py プロジェクト: peior/ITree
 def _openFile(self, filename):
     """ openfile with ITreeFile """
     if os.path.exists(filename) and open(filename, 'rb'):
         itf = ITreeFile(filename)
         x = INode()
         y = IResNode()
         if itf.open(x, y):
             self.mainWidget.setRoot(x)
             self.mainWidget.setResRoot(y)
             del self.nodeRoot
             del self.resRoot
             self.nodeRoot = x
             self.resRoot = y
             self.resCurrentPath = '/'
             self.setCurrentName(filename)
             self.actionRedo.setEnabled(False)
             self.actionUndo.setEnabled(False)
             return
     QMessageBox.warning(self, self.tr('Error'),
                         self.tr('Cannot open file {}'.format(filename)))
コード例 #5
0
ファイル: itree.py プロジェクト: peior/ITree
    def __init__(self, parent=None):
        super().__init__(parent)

        self.nodeRoot = INode()
        self.resRoot = IResNode()
        self.mySettings = QSettings()
        self.mainWidget = MainWidget(self)
        self.isResModified = False
        self.currentFileName = ''
        self.resCurrentPath = '/'

        self.appearance()
        self.actions()
        self.shortcuts()
        self.loadSettings()
        self.connections()
        self.setCurrentName('')
        self.setCentralWidget(self.mainWidget)
        self.setMinimumSize(QSize(800, 600))
        self.setCenter()
コード例 #6
0
 def actionRename(self):
     node = self.getSelectedNode()
     if node:
         name, ok = QInputDialog.getText(None, self.tr("Rename"),
                                         self.tr('Input a string'),
                                         QLineEdit.Normal, node.name)
         if ok and node.name != name:
             if not IResNode.isNameVaild(name):
                 QMessageBox.warning(self, self.tr('Error'),
                                     self.tr('name is invalid'))
                 return
             if self.currentNode.findName(name) != -1:
                 QMessageBox.warning(self, self.tr('Error'),
                                     name + self.tr(' has been existed!'))
                 return
             node.name = name
             self.takeItem(self.currentRow())
             row, info = self.findInfo(self.currentNode, name)
             self.insertItem(row, self.makeItem(info.name, info.isFile))
             self.setCurrentRow(row)
             self.pasteBin = None
             self.isModified = True
コード例 #7
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.mySettings = QSettings()
        self.markdown = IMarkdown()
        self.model = TreeViewModel(TreeNode(), self)
        self.treeView = TreeView(self)
        self.editView = TextEdit(self)
        self.webView = WebView(IResNode())
        self.splitter = QSplitter(self)
        self.undoStack = UndoStack(self)
        self.rightWidget = QStackedWidget(self)
        self.htmlHeader = ''
        self.htmlFooter = ''
        self.isEditView = True
        self.viewPreviousIndex = QModelIndex()
        self.tempList = []

        self.rightWidget.addWidget(self.editView)
        self.rightWidget.addWidget(self.webView)
        self.rightWidget.setCurrentIndex(0)

        self.treeView.setMinimumWidth(1)
        self.rightWidget.setMinimumWidth(1)
        self.splitter.addWidget(self.treeView)
        self.splitter.addWidget(self.rightWidget)
        self.splitter.setHandleWidth(5)
        self.splitter.setContentsMargins(0, 0, 0, 0)

        self.loadSettings()
        self.connections()
        self.loadInternalJavaScript()
        self.setTree()

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.splitter)
        self.setLayout(layout)
コード例 #8
0
def main():
    app = QApplication(sys.argv)

    QCoreApplication.setOrganizationName(AUTHOR)
    QCoreApplication.setApplicationName(APP_NAME)

    from itreefile import IResNode

    root = IResNode()
    for i in range(1, 10):
        root.insert(str(i) + '.png', 'temp/{}.png'.format(i % 5 + 1))
    root.insert('1048237438927482937492384328974234324234234.png',
                'temp/1.png')
    for i in range(10, 20):
        root.insert(str(i) + '.png', 'temp/{}.png'.format(i % 5 + 1))

    root.insert('hhhh')
    h = root.at(root.findName('hhhh'))
    for i in range(1, 10):
        h.insert(str(10 - i) + '.png', 'temp/{}.png'.format(i % 5 + 1))

    mainWindow = DialogInsertPicture(root)
    mainWindow.show()

    sys.exit(app.exec_())