예제 #1
0
    def fill(self):
        """fills the tree view with data
        """
        logger.debug('start filling tasks_treeView')
        logger.debug('creating a new model')
        if not self.project:
            from sqlalchemy import alias
            from stalker import Task, Project
            from stalker.db.session import DBSession
            # projects = Project.query.order_by(Project.name).all()
            inner_tasks = alias(Task.__table__)
            subquery = DBSession.query(inner_tasks.c.id).filter(
                inner_tasks.c.project_id == Project.id)
            query = DBSession\
                .query(
                    Project.id, Project.name, Project.entity_type,
                    Project.status_id,
                    subquery.exists().label('has_children')
                )
            if not self.show_completed_projects:
                from stalker import Status
                status_cmpl = \
                    Status.query.filter(Status.code == 'CMPL').first()
                query = query.filter(Project.status != status_cmpl)

            query = query.order_by(Project.name)
            projects = query.all()
        else:
            self.project.has_children = bool(self.project.tasks)
            projects = [self.project]

        logger.debug('projects: %s' % projects)

        # delete the old model if any
        if self.model() is not None:
            self.model().deleteLater()

        task_tree_model = TaskTreeModel()
        task_tree_model.populateTree(projects)
        self.setModel(task_tree_model)
        self.is_updating = False

        self.auto_fit_column()

        logger.debug('finished filling tasks_treeView')
예제 #2
0
파일: task.py 프로젝트: eoyilmaz/anima
    def fill(self):
        """fills the tree view with data
        """
        logger.debug('start filling tasks_treeView')
        logger.debug('creating a new model')
        if not self.project:
            from sqlalchemy import alias
            from stalker import Task, Project
            from stalker.db.session import DBSession
            # projects = Project.query.order_by(Project.name).all()
            inner_tasks = alias(Task.__table__)
            subquery = DBSession.query(inner_tasks.c.id).filter(
                inner_tasks.c.project_id == Project.id)
            query = DBSession\
                .query(
                    Project.id, Project.name, Project.entity_type,
                    Project.status_id,
                    subquery.exists().label('has_children')
                )
            if not self.show_completed_projects:
                from stalker import Status
                status_cmpl = \
                    Status.query.filter(Status.code == 'CMPL').first()
                query = query.filter(Project.status != status_cmpl)

            query = query.order_by(Project.name)
            projects = query.all()
        else:
            self.project.has_children = bool(self.project.tasks)
            projects = [self.project]

        logger.debug('projects: %s' % projects)

        # delete the old model if any
        if self.model() is not None:
            self.model().deleteLater()

        task_tree_model = TaskTreeModel()
        task_tree_model.populateTree(projects)
        self.setModel(task_tree_model)
        self.is_updating = False

        self.auto_fit_column()

        logger.debug('finished filling tasks_treeView')
예제 #3
0
    def setup_ui(self, dialog):
        """Sets up the dialog

        :param dialog: QtGui.QDialog instance
        :return:
        """
        dialog.setObjectName("Dialog")
        dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        dialog.resize(1200, 800)
        # layout vertical first
        self.vertical_layout = QtWidgets.QVBoxLayout(dialog)
        self.vertical_layout.setObjectName('verticalLayout1')

        self.horizontal_layout = QtWidgets.QHBoxLayout()

        self.from_task_tree_view = QtWidgets.QTreeView(dialog)
        self.from_task_tree_view.setObjectName("from_tasks_treeView")

        self.copy_push_button = QtWidgets.QPushButton(dialog)
        self.copy_push_button.setObjectName("copy_push_button")
        self.copy_push_button.setText('>')

        self.to_task_tree_view = TaskTreeView(dialog)
        self.to_task_tree_view.setObjectName("to_tasks_treeView")

        # self.horizontal_layout1.addWidget(self.from_task_tree_view)
        self.horizontal_layout.addWidget(self.from_task_tree_view)
        self.horizontal_layout.addWidget(self.copy_push_button)
        self.horizontal_layout.addWidget(self.to_task_tree_view)

        self.vertical_layout.addLayout(self.horizontal_layout)

        self.horizontal_layout_2 = QtWidgets.QHBoxLayout()
        self.horizontal_layout_2.setContentsMargins(-1, 10, -1, -1)
        self.horizontal_layout_2.setObjectName("horizontal_layout_2")

        self.vertical_layout.addLayout(self.horizontal_layout_2)

        QtCore.QMetaObject.connectSlotsByName(dialog)

        # initialize elements

        logged_in_user = self.get_logged_in_user()
        projects = Project.query.order_by(Project.name).all()

        task_tree_model = TaskTreeModel()
        task_tree_model.user = logged_in_user
        task_tree_model.populateTree(projects)

        # fit to elements
        self.from_tasks_tree_view_auto_fit_column()
        self.to_tasks_tree_view_auto_fit_column()

        self.from_task_tree_view.setModel(task_tree_model)
        self.to_task_tree_view.setModel(task_tree_model)

        # setup signals
        # tasks_treeView
        QtCore.QObject.connect(
            self.from_task_tree_view.selectionModel(),
            QtCore.SIGNAL('selectionChanged(const QItemSelection &, '
                          'const QItemSelection &)'),
            self.from_task_tree_view_changed)

        QtCore.QObject.connect(
            self.to_task_tree_view.selectionModel(),
            QtCore.SIGNAL('selectionChanged(const QItemSelection &, '
                          'const QItemSelection &)'),
            self.to_task_tree_view_changed)

        # fit column 0 on expand/collapse
        QtCore.QObject.connect(self.from_task_tree_view,
                               QtCore.SIGNAL('expanded(QModelIndex)'),
                               self.from_tasks_tree_view_auto_fit_column)

        QtCore.QObject.connect(self.to_task_tree_view,
                               QtCore.SIGNAL('expanded(QModelIndex)'),
                               self.to_tasks_tree_view_auto_fit_column)

        # copy_push_button
        QtCore.QObject.connect(self.copy_push_button,
                               QtCore.SIGNAL("clicked()"), self.copy_versions)