示例#1
0
    def __init__(self, db, parent=None):
        QWidget.__init__(self)
        self.db = db
        self.cardView = CardView(db)
        self.newCardTextBox = NewCardTextBox()

        mainLayout = QHBoxLayout()

        self.leftLayout = QVBoxLayout()
        self.sidebarView = SidebarView()
        self.leftLayout.addWidget(self.sidebarView)
        self.newBoardButton = NewBoardButton()
        self.leftLayout.addWidget(self.newBoardButton)
        mainLayout.addLayout(self.leftLayout)

        centralLayout = QVBoxLayout()
        centralLayout.addWidget(self.newCardTextBox)
        centralLayout.addWidget(self.cardView)
        mainLayout.addLayout(centralLayout)

        self.buttonTray = ButtonTray(db)
        mainLayout.addWidget(self.buttonTray)

        self.setLayout(mainLayout)

        self.setupSidebar()
        self.setupCardView()
        self.setupNewBoardButton()
        self.setupNewCardTextBox()
        self.setupButtonTray()
        return
示例#2
0
class MainWidget(QWidget):
    def __init__(self, db, parent=None):
        QWidget.__init__(self)
        self.db = db
        self.cardView = CardView(db)
        self.newCardTextBox = NewCardTextBox()

        mainLayout = QHBoxLayout()

        self.leftLayout = QVBoxLayout()
        self.sidebarView = SidebarView()
        self.leftLayout.addWidget(self.sidebarView)
        self.newBoardButton = NewBoardButton()
        self.leftLayout.addWidget(self.newBoardButton)
        mainLayout.addLayout(self.leftLayout)

        centralLayout = QVBoxLayout()
        centralLayout.addWidget(self.newCardTextBox)
        centralLayout.addWidget(self.cardView)
        mainLayout.addLayout(centralLayout)

        self.buttonTray = ButtonTray(db)
        mainLayout.addWidget(self.buttonTray)

        self.setLayout(mainLayout)

        self.setupSidebar()
        self.setupCardView()
        self.setupNewBoardButton()
        self.setupNewCardTextBox()
        self.setupButtonTray()
        return

    def setupNewCardTextBox(self):
        self.newCardTextBox.getCurrentList.connect(self.cardModel.currentList)
        self.newCardTextBox.newCardRequested.connect(self.makeNewCard)
        self.newCardTextBox.cardAdded.connect(self.cardModel.showListCards)
        return

    def setupSidebar(self):
        self.sidebarModel = SidebarModel(db)
        self.sidebarView.setModel(self.sidebarModel)
        self.sidebarModel.rowsInserted.connect(self.sidebarView.expandAll)
        self.sidebarView.renameList.connect(self.sidebarModel.onRenameList)
        self.sidebarView.renameBoard.connect(self.sidebarModel.onRenameBoard)
        self.sidebarView.deleteList.connect(self.sidebarModel.onDeleteList)
        self.sidebarView.deleteBoard.connect(self.sidebarModel.onDeleteBoard)
        self.sidebarView.addList.connect(self.sidebarModel.onAddList)
        self.sidebarModel.willRefresh.connect(self.sidebarView.storeExpanded)
        self.sidebarModel.willRefresh.connect(
            self.sidebarView.storeScrollValue)
        self.sidebarModel.refreshed.connect(self.sidebarView.restoreExpanded)
        self.sidebarModel.refreshed.connect(
            self.sidebarView.restoreScrollValue)

        return

    def setupCardView(self):
        self.cardModel = CardModel(self.db)
        self.editDialog = CardEditWidget()
        self.cardView.setModel(self.cardModel)
        self.cardModel.willUpdateCurrentList.connect(
            self.cardView.storeScrollValue)
        self.cardModel.willUpdateCurrentList.connect(
            self.cardView.storeSelectedIndex)
        self.cardModel.updatedCurrentList.connect(
            self.cardView.restoreScrollValue)
        self.cardModel.updatedCurrentList.connect(
            self.cardView.restoreSelectedIndex)
        self.sidebarView.listClicked.connect(self.cardModel.showListCards)
        self.sidebarModel.cardChanged.connect(self.cardModel.refresh)
        self.cardView.showCard.connect(self.editDialog.showCard)
        self.editDialog.cardEdited.connect(self.cardModel.onCardEdited)
        self.sidebarView.expandAll()
        return

    def setupNewBoardButton(self):
        self.newBoardButton.pressed.connect(self.makeNewBoard)
        return

    def setupButtonTray(self):
        self.buttonTray.buttonPressed.connect(self.cardModel.refresh)
        self.buttonTray.buttonPressed.connect(self.sidebarModel.refresh)
        self.buttonTray.getCurrentList.connect(self.cardModel.currentList)
        self.buttonTray.getSelectedCards.connect(self.cardView.selectedCards)
        return

    @Slot(str, int)
    def makeNewCard(self, text, listid):
        self.db.runCommand(f'add-card "{text}":"":-1 to {listid}')
        return

    @Slot()
    def makeNewBoard(self):
        self.db.runCommand(f'add-board "New Board"')
        self.sidebarModel.refresh()
        return