Beispiel #1
0
    def new_participant_requested(self):
        layout = QHBoxLayout(self.part_diag)
        self.part_diag.setMinimumWidth(600)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        self.part_widget.setStyleSheet(self.styleSheet())

        # print(self.styleSheet())
        layout.addWidget(self.part_widget)

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()
Beispiel #2
0
    def new_participant_requested(self):
        self.part_diag = QDialog()
        self.part_diag.setStyleSheet("QDialog{background-image:url(:/OpenIMU/background/dark_metal.jpg);}")
        layout = QHBoxLayout(self.part_diag)
        self.part_diag.setMinimumWidth(600)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        self.part_widget.setStyleSheet(self.styleSheet())

        #print(self.styleSheet())
        layout.addWidget(self.part_widget )

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()
Beispiel #3
0
    def show_participant(self, participant=None, base_group=None):
        self.clear_main_widgets()

        partWidget = ParticipantWindow(dbManager=self.dbMan, participant=participant, default_group=base_group)
        self.UI.frmMain.layout().addWidget(partWidget)

        partWidget.dataSaved.connect(self.dataWasSaved)
        partWidget.dataCancelled.connect(self.dataWasCancelled)
Beispiel #4
0
    def new_participant_requested(self):
        self.part_diag = QDialog()
        layout = QHBoxLayout(self.part_diag)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        layout.addWidget(self.part_widget)

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()
Beispiel #5
0
class ImportManager(QDialog):

    filename = ""
    filetype = ""
    filetype_id = -1
    participant = ""
    group = ""
    dbMan = None
    import_dirs = False
    import_stream = False
    part_widget = None
    participant_multi = False

    participant_added = pyqtSignal()

    def __init__(self, dbmanager, dirs, stream=False, parent=None):
        super(ImportManager, self).__init__(parent=parent)
        self.UI = Ui_ImportManager()
        self.UI.setupUi(self)

        self.import_dirs = dirs
        self.import_stream = stream

        self.dbMan = dbmanager

        # Load supported importers
        if not self.import_stream:
            importers = ImporterTypes()
            for i in range(0, len(importers.value_types)):
                # Ignore WIMU for now as Importers hasn't been updated yet.
                if importers.value_names[i] != 'WIMU':
                    self.UI.cmbFileType.addItem(importers.value_names[i],
                                                importers.value_types[i])
        else:
            streamers = StreamerTypes()
            for i in range(0, len(streamers.value_types)):
                self.UI.cmbFileType.addItem(streamers.value_names[i],
                                            streamers.value_types[i])

        if self.UI.cmbFileType.count() == 1:
            self.UI.cmbFileType.setCurrentIndex(0)
        else:
            self.UI.cmbFileType.setCurrentIndex(-1)

        if self.import_stream:
            self.UI.lblFileName.setText("Destination des données")
            self.UI.btnImport.setText("Transférer")
            self.import_dirs = True
            self.UI.txtFileName.setText(tempfile.gettempdir() + os.sep +
                                        "OpenIMU")

        self.UI.chkMultiParticipants.setVisible(self.import_dirs)

        # Signals / Slots connections
        self.UI.btnCancel.clicked.connect(self.cancel_clicked)
        self.UI.btnImport.clicked.connect(self.ok_clicked)
        self.UI.btnBrowse.clicked.connect(self.browse_clicked)
        self.UI.btnAddPart.clicked.connect(self.new_participant_requested)
        self.UI.cmbParticipant.currentIndexChanged.connect(
            self.current_participant_changed)
        self.UI.chkMultiParticipants.stateChanged.connect(
            self.multi_participants_check)

        # Load participants
        self.load_participants()

        self.part_diag = QDialog()
        # self.part_diag.setStyleSheet("QDialog{background-image:url(:/OpenIMU/background/dark_metal.jpg);}")
        self.part_diag.setStyleSheet(
            "QDialog{background:qlineargradient(spread:pad, x1:0.483, y1:0, x2:0.511045, y2:1,"
            " stop:0 rgba(50, 50, 50, 255), stop:1 rgba(203, 203, 203, 255));"
            "border-radius:0px;}")

    def load_participants(self):
        participants = self.dbMan.get_all_participants()
        self.UI.cmbParticipant.clear()

        for part in participants:
            self.UI.cmbParticipant.addItem(part.name, userData=part)

        self.UI.cmbParticipant.setCurrentIndex(-1)

    def validate(self):
        rval = True
        if self.UI.txtFileName.text() == '':
            self.UI.txtFileName.setStyleSheet('background-color: #ffcccc;')
            rval = False
        else:
            self.UI.txtFileName.setStyleSheet('')

        if self.UI.cmbFileType.currentText() == '':
            self.UI.cmbFileType.setStyleSheet('background-color: #ffcccc;')
            rval = False
        else:
            self.UI.cmbFileType.setStyleSheet('')

        if self.UI.frameParticipant.isVisible():
            if self.UI.cmbParticipant.currentText() == '':
                self.UI.cmbParticipant.setStyleSheet(
                    'background-color: #ffcccc;')
                rval = False
            else:
                self.UI.cmbParticipant.setStyleSheet('')

        return rval

    def set_participant(self, name):
        self.UI.cmbParticipant.setCurrentText(name)

    def set_filetype(self, format_text):
        self.UI.cmbFileType.setCurrentText(format_text)

    @pyqtSlot()
    def ok_clicked(self):
        # Validate items
        if self.validate():
            self.filename = self.UI.txtFileName.text()
            self.filetype = self.UI.cmbFileType.currentText()
            self.filetype_id = self.UI.cmbFileType.currentData()
            self.participant = self.UI.cmbParticipant.currentData()
            self.accept()

    @pyqtSlot()
    def cancel_clicked(self):
        self.reject()

    @pyqtSlot()
    def browse_clicked(self):
        if not self.import_dirs:
            file = QFileDialog().getOpenFileNames(
                caption="Sélectionnez le(s) fichier(s) à importer")
        else:
            file = QFileDialog().getExistingDirectory(
                caption="Sélectionnez le répertoire à importer")

        if len(file) > 0:
            if not self.import_dirs:
                sep = ";"
                self.UI.txtFileName.setText(sep.join(file[0]))
            else:
                self.UI.txtFileName.setText(file)

    @pyqtSlot()
    def new_participant_requested(self):

        layout = QHBoxLayout(self.part_diag)
        self.part_diag.setMinimumWidth(600)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        self.part_widget.setStyleSheet(self.styleSheet())

        # print(self.styleSheet())
        layout.addWidget(self.part_widget)

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()

    @pyqtSlot()
    def participant_cancelled(self):
        self.part_diag.reject()

    @pyqtSlot()
    def participant_saved(self):
        self.part_diag.accept()
        self.load_participants()

        self.UI.cmbParticipant.setCurrentText(
            self.part_widget.participant.name)

        self.participant_added.emit()

    @pyqtSlot()
    def current_participant_changed(self):
        if self.UI.cmbParticipant.currentIndex() == -1:
            self.UI.lblGroupName.setText("")
            return

        part = self.UI.cmbParticipant.currentData()
        if part.group is None:
            self.UI.lblGroupName.setText("Aucun")
        else:
            self.UI.lblGroupName.setText(
                self.UI.cmbParticipant.currentData().group.name)

    @pyqtSlot(int)
    def multi_participants_check(self, check_value):
        self.participant_multi = (check_value == Qt.Checked)
        self.UI.frameParticipant.setVisible(not self.participant_multi)

    def get_file_list(self):
        # Build file list
        file_list = FileManager.get_file_list(self.filename)

        file_match = {}  # Dictionary - filename and participant
        if not self.participant_multi:
            for file in file_list.keys():
                file_match[file] = self.participant
        else:
            # Multiple participant - must show dialog and match.
            matcher = ImportMatchDialog(dbmanager=self.dbMan,
                                        datas=list(set(file_list.values())),
                                        parent=self)
            if matcher.exec() == QDialog.Accepted:
                for file_name, file_dataname in file_list.items():
                    part = matcher.data_match[file_dataname]
                    file_match[file_name] = part

        return file_match
Beispiel #6
0
class ImportMatchDialog(QDialog):

    data_match = {}
    dbMan = None
    participants = None
    part_diag = None
    part_widget = None

    def __init__(self, dbmanager, datas, parent=None):
        super().__init__(parent=parent)
        self.UI = Ui_ImportMatchDialog()
        self.UI.setupUi(self)

        for data in datas:
            self.data_match[data] = ""

        self.dbMan = dbmanager

        # Load participants
        self.participants = self.dbMan.get_all_participants()

        # Fill table with datas
        for data in datas:
            row = self.UI.tableMatch.rowCount()
            self.UI.tableMatch.setRowCount(row + 1)
            item = QTableWidgetItem(data)
            self.UI.tableMatch.setItem(row, 0, item)
            item_combo = QComboBox()
            self.fill_participant_combobox(item_combo)
            item_combo.setCurrentIndex(item_combo.findText(data))
            self.UI.tableMatch.setCellWidget(row, 1, item_combo)

        # Connect signals / slots
        self.UI.btnOK.clicked.connect(self.ok_clicked)
        self.UI.btnCancel.clicked.connect(self.cancel_clicked)
        self.UI.btnAddParticipant.clicked.connect(
            self.new_participant_requested)

        # Init participant dialog
        self.part_diag = QDialog(parent=self)

    def validate(self):
        rval = True

        for i in range(0, self.UI.tableMatch.rowCount()):
            item_combo = self.UI.tableMatch.cellWidget(i, 1)
            index = item_combo.currentIndex()
            if index < 0:
                item_combo.setStyleSheet('background-color: #ffcccc;')
                rval = False
            else:
                item_combo.setStyleSheet('')

        return rval

    def fill_participant_combobox(self, combobox):
        combobox.clear()
        combobox.addItem("", -1)
        for participant in self.participants:
            combobox.addItem(participant.name, userData=participant)

    @pyqtSlot()
    def ok_clicked(self):
        # Validate items
        if self.validate():
            for i in range(0, self.UI.tableMatch.rowCount()):
                item_combo = self.UI.tableMatch.cellWidget(i, 1)
                part = item_combo.currentData()
                item_value = self.UI.tableMatch.item(i, 0).text()
                self.data_match[item_value] = part
            self.accept()

    @pyqtSlot()
    def cancel_clicked(self):
        self.reject()

    @pyqtSlot()
    def new_participant_requested(self):
        layout = QHBoxLayout(self.part_diag)
        self.part_diag.setMinimumWidth(600)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        self.part_widget.setStyleSheet(self.styleSheet())

        # print(self.styleSheet())
        layout.addWidget(self.part_widget)

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()

    @pyqtSlot()
    def participant_cancelled(self):
        self.part_diag.reject()

    @pyqtSlot()
    def participant_saved(self):
        self.part_diag.accept()
        self.participants = self.dbMan.get_all_participants()

        # Update all comboboxes in the table with the new participant
        for i in range(0, self.UI.tableMatch.rowCount()):
            item_combo = self.UI.tableMatch.cellWidget(i, 1)
            index = item_combo.currentIndex()
            self.fill_participant_combobox(item_combo)
            item_combo.setCurrentIndex(index)

    def get_files_match(self, base_path: str) -> dict:
        # Build file list
        file_list = FileManager.get_file_list(from_path=base_path)

        file_match = {}  # Dictionary - filename and participant
        for file_name, file_dataname in file_list.items():
            part = self.data_match[file_dataname]
            file_match[file_name] = part

        return file_match
Beispiel #7
0
class ImportManager(QDialog):

    filename = ""
    filetype = ""
    filetype_id = -1
    participant = ""
    group = ""
    dbMan = None
    import_dirs = False

    def __init__(self, dbManager, parent=None):
        super(QDialog, self).__init__(parent=parent)
        self.UI = Ui_ImportManager()
        self.UI.setupUi(self)

        self.dbMan = dbManager

        # Load supported importers
        importers = ImporterTypes()
        for i in range(0, len(importers.value_types)):
            # Ignore WIMU and Actigraph for now as Importers hasn't been updated yet.
            if importers.value_names[i] != 'WIMU' and importers.value_names[
                    i] != 'Actigraph':
                self.UI.cmbFileType.addItem(importers.value_names[i],
                                            importers.value_types[i])
        self.UI.cmbFileType.setCurrentIndex(-1)

        # Signals / Slots connections
        self.UI.btnCancel.clicked.connect(self.cancel_clicked)
        self.UI.btnImport.clicked.connect(self.ok_clicked)
        self.UI.btnBrowse.clicked.connect(self.browse_clicked)
        self.UI.btnAddPart.clicked.connect(self.new_participant_requested)
        self.UI.cmbParticipant.currentIndexChanged.connect(
            self.current_participant_changed)

        # Load participants
        self.load_participants()

    def load_participants(self):
        participants = self.dbMan.get_all_participants()
        self.UI.cmbParticipant.clear()

        for part in participants:
            self.UI.cmbParticipant.addItem(part.name, userData=part)

        self.UI.cmbParticipant.setCurrentIndex(-1)

    def validate(self):
        rval = True
        if self.UI.txtFileName.text() == '':
            self.UI.txtFileName.setStyleSheet('background-color: #ffcccc;')
            rval = False
        else:
            self.UI.txtFileName.setStyleSheet('')

        if self.UI.cmbFileType.currentText() == '':
            self.UI.cmbFileType.setStyleSheet('background-color: #ffcccc;')
            rval = False
        else:
            self.UI.cmbFileType.setStyleSheet('')

        if self.UI.cmbParticipant.currentText() == '':
            self.UI.cmbParticipant.setStyleSheet('background-color: #ffcccc;')
            rval = False
        else:
            self.UI.cmbParticipant.setStyleSheet('')

        return rval

    def set_participant(self, name):
        self.UI.cmbParticipant.setCurrentText(name)

    def set_filetype(self, format_text):
        self.UI.cmbFileType.setCurrentText(format_text)

    @pyqtSlot()
    def ok_clicked(self):
        # Validate items
        if self.validate():
            self.filename = self.UI.txtFileName.text()
            self.filetype = self.UI.cmbFileType.currentText()
            self.filetype_id = self.UI.cmbFileType.currentData()
            self.participant = self.UI.cmbParticipant.currentData()
            self.accept()

    @pyqtSlot()
    def cancel_clicked(self):
        self.reject()

    @pyqtSlot()
    def browse_clicked(self):
        if not self.import_dirs:
            file = QFileDialog().getOpenFileNames(
                caption="Sélectionnez le(s) fichier(s) à importer")
        else:
            file = QFileDialog().getExistingDirectory(
                caption="Sélectionnez le répertoire à importer")

        if len(file) > 0:
            if not self.import_dirs:
                sep = ";"
                self.UI.txtFileName.setText(sep.join(file[0]))
            else:
                self.UI.txtFileName.setText(file)

    @pyqtSlot()
    def new_participant_requested(self):
        self.part_diag = QDialog()
        self.part_diag.setStyleSheet(
            "QDialog{background-image:url(:/OpenIMU/background/dark_metal.jpg);}"
        )
        layout = QHBoxLayout(self.part_diag)
        self.part_diag.setMinimumWidth(600)

        self.part_widget = ParticipantWindow(dbManager=self.dbMan)
        self.part_widget.setStyleSheet(self.styleSheet())

        #print(self.styleSheet())
        layout.addWidget(self.part_widget)

        self.part_widget.dataCancelled.connect(self.participant_cancelled)
        self.part_widget.dataSaved.connect(self.participant_saved)

        self.part_diag.exec()

    @pyqtSlot()
    def participant_cancelled(self):
        self.part_diag.reject()

    @pyqtSlot()
    def participant_saved(self):
        self.part_diag.accept()
        self.load_participants()

        self.UI.cmbParticipant.setCurrentText(
            self.part_widget.participant.name)

    @pyqtSlot()
    def current_participant_changed(self):
        if self.UI.cmbParticipant.currentIndex() == -1:
            self.UI.lblGroupName.setText("")
            return

        part = self.UI.cmbParticipant.currentData()
        if part.group is None:
            self.UI.lblGroupName.setText("Aucun")
        else:
            self.UI.lblGroupName.setText(
                self.UI.cmbParticipant.currentData().group.name)