Exemplo n.º 1
0
    def set_sample_pin_icon(self):
        it = qt.QListViewItemIterator(self.sample_list_view)
        item = it.current()

        while item:
            if self.is_mounted_sample_item(item):
                item.setSelected(True)
                item.set_mounted_style(True)
                #self.sample_list_view_selection()
            elif isinstance(item, queue_item.SampleQueueItem):
                item.set_mounted_style(False)
            if isinstance(item, queue_item.SampleQueueItem):
                if item.get_model().lims_location != (None, None):
                    item.setPixmap(0, self.ispyb_pixmap)
                    item.setText(0, item.get_model().loc_str + ' - ' \
                                 + item.get_model().get_display_name())
            elif isinstance(item, queue_item.BasketQueueItem):
                do_it = True
                child_item = item.firstChild()
                while child_item:
                    if child_item.firstChild():
                        do_it = False
                        break
                    child_item = child_item.nextSibling()
                if do_it:
                    item.setOn(False)
                item.setText(0, item.get_model().get_display_name())
            it += 1
            item = it.current()
Exemplo n.º 2
0
 def set_first_element(self):
     selected_items = self.get_selected_items()
     if len(selected_items) == 0:
         it = qt.QListViewItemIterator(self.sample_list_view)
         item = it.current()
         if item.get_model().free_pin_mode:
             self.sample_list_view.setSelected(self.sample_list_view.firstChild(), True)
Exemplo n.º 3
0
 def getValues(self):
     values = []
     iter = qt.QListViewItemIterator(self.listview)
     while True:
         item = iter.current()
         if item == None:
             break
         values.append(item.text(0).ascii())
         iter += 1
     return values
Exemplo n.º 4
0
    def items(self):
        """ items() -> generates a sequence of list view items

        """
        it = qt.QListViewItemIterator(self)
        current = it.current()
        while current:
            yield current
            current = it.current()
            it += 1
Exemplo n.º 5
0
 def getSelectedPkgs(self):
     iter = qt.QListViewItemIterator(self._treeview)
     lst = []
     while iter.current():
         item = iter.current()
         if item.isSelected():
             value = item._pkg
             if hasattr(value, "name"):
                 lst.append(value)
         iter += 1
     return lst
Exemplo n.º 6
0
    def get_item_by_model(self, parent_node):
        it = qt.QListViewItemIterator(self.sample_list_view)
        item = it.current()

        while item:
            if item.get_model() is parent_node:
                return item

            it += 1
            item = it.current()

        return self.sample_list_view
Exemplo n.º 7
0
 def removeValue(self):
     items_selected = []
     iter = qt.QListViewItemIterator(self.listview)
     while True:
         item = iter.current()
         if item == None:
             break
         if item.isSelected():
             items_selected.append(item)
         iter += 1
     for item in items_selected:
         self.listview.takeItem(item)
         del item
Exemplo n.º 8
0
 def enableDisable(self):
     iter = qt.QListViewItemIterator(self._treeview)
     while iter.current():
         item = iter.current()
         disabled = strToBool(
             sysconf.get(("channels", str(item.text(2)), "disabled")))
         if item.isOn():
             if disabled:
                 sysconf.remove(("channels", str(item.text(1)), "disabled"))
                 self._changed = True
         else:
             if not disabled:
                 sysconf.set(("channels", str(item.text(1)), "disabled"),
                             True)
                 self._changed = True
         iter += 1
Exemplo n.º 9
0
    def selectWidget(self, widget):
        """Find the widget in the list and select it."""

        iter = qt.QListViewItemIterator(self)

        found = None
        while True:
            item = iter.current()
            if item == None:
                break
            if item.widget == widget:
                found = item
                break
            iter += 1

        if found:
            self.ensureItemVisible(found)
            self.setSelected(found, True)
Exemplo n.º 10
0
    def set_sample_pin_icon(self):
        it = qt.QListViewItemIterator(self.sample_list_view)
        item = it.current()

        while item:
            if self.is_mounted_sample_item(item):
                item.setSelected(True)
                item.set_mounted_style(True)
                self.sample_list_view_selection()
            elif isinstance(item, queue_item.SampleQueueItem):
                item.set_mounted_style(False)
            if isinstance(item, queue_item.SampleQueueItem):
                if item.get_model().lims_location != (None, None):
                    item.setPixmap(0, self.ispyb_pixmap)
                    item.setText(0, item.get_model().loc_str + ' - ' \
                                 + item.get_model().get_name())

            it += 1
            item = it.current()
Exemplo n.º 11
0
    def show(self):
        self.fill()
        self._result = False
        self._window.show()
        centerWindow(self._window)
        self._window.raiseW()
        self._result = self._window.exec_loop()
        self._window.hide()

        result = []
        if self._result == qt.QDialog.Accepted:
            iter = qt.QListViewItemIterator(self._treeview)
            while iter.current():
                item = iter.current()
                if item.isOn():
                    result.append(item.text(1))
                iter += 1

        return result
Exemplo n.º 12
0
    def filter_sample_list(self, option):
        self.sample_list_view.clearSelection()
        self.beamline_setup_hwobj.set_plate_mode(False)

        if option == SC_FILTER_OPTIONS.SAMPLE_CHANGER:
            self.sample_list_view.clear()
            self.queue_model_hwobj.select_model('ispyb')
            self.set_sample_pin_icon()
        elif option == SC_FILTER_OPTIONS.MOUNTED_SAMPLE:
            loaded_sample = self.sample_changer_hwobj.\
                                 getLoadedSample()
            try:
                loaded_sample_loc = loaded_sample.getCoords()
            except:
                loaded_sample_loc = None

            it = qt.QListViewItemIterator(self.sample_list_view)
            item = it.current()

            while item:
                if isinstance(item, queue_item.SampleQueueItem):
                    if item.get_model().location == loaded_sample_loc:
                        item.setSelected(True)
                        item.setVisible(True)
                    else:
                        item.setVisible(False)

                it += 1
                item = it.current()

        elif option == SC_FILTER_OPTIONS.FREE_PIN:
            self.sample_list_view.clear()
            self.queue_model_hwobj.select_model('free-pin')
            self.set_sample_pin_icon()
        elif option == SC_FILTER_OPTIONS.PLATE:
            #self.sample_list_view.clear()
            #self.sample_list_view.setDisabled(True)
            msg = 'In plate mode, not taking crystal snapshots'
            logging.getLogger("user_level_log").warning(msg)
            self.beamline_setup_hwobj.set_plate_mode(True)

        self.sample_list_view_selection()
Exemplo n.º 13
0
    def check_for_path_collisions(self):
        conflict = False
        it = qt.QListViewItemIterator(self.sample_list_view)
        item = it.current()

        while item:
            if item.isOn():
                pt = item.get_model().get_path_template()

                if pt:
                    path_conflict = self.queue_model_hwobj.\
                               check_for_path_collisions(pt)

                    if path_conflict:
                        conflict = True
                        item.setPixmap(0, self.caution_pixmap)
                    else:
                        item.setPixmap(0, qt.QPixmap())

            it += 1
            item = it.current()

        return conflict
Exemplo n.º 14
0
    def filter_sample_list(self, option):
        if option == SC_FILTER_OPTIONS.SAMPLE_CHANGER \
          and self.beamline_setup_hwobj.diffractometer_hwobj.in_plate_mode():
            logging.getLogger("user_level_log").\
                error("Unable to use sample changer if plate manipulator used.")
            #TODO remove sample changer option if plate used
            return

        self.sample_list_view.clearSelection()
        self.beamline_setup_hwobj.set_plate_mode(False)
        self.confirm_dialog.set_plate_mode(False)

        if option == SC_FILTER_OPTIONS.SAMPLE_CHANGER:
            self.sample_list_view.clear()
            self.queue_model_hwobj.select_model('ispyb')
            self.set_sample_pin_icon()
        elif option == SC_FILTER_OPTIONS.MOUNTED_SAMPLE:
            if self.beamline_setup_hwobj.diffractometer_hwobj.in_plate_mode():
                loaded_sample = self.plate_manipulator_hwobj.\
                                     getLoadedSample()
            else:
                loaded_sample = self.sample_changer_hwobj.\
                                     getLoadedSample()
            #loaded_sample = self.sample_changer_hwobj.\
            #                     getLoadedSample()
            try:
                loaded_sample_loc = loaded_sample.getCoords()
            except:
                loaded_sample_loc = None

            it = qt.QListViewItemIterator(self.sample_list_view)
            item = it.current()
            visible_parent = None

            while item:
                if isinstance(item, queue_item.SampleQueueItem):
                    if self.beamline_setup_hwobj.diffractometer_hwobj.in_plate_mode(
                    ):
                        item_location = item.get_model().location_plate
                    else:
                        item_location = item.get_model().location
                    if item_location == loaded_sample_loc:
                        selected_item = item
                        visible_parent = item.parent()
                    else:
                        item.setVisible(False)
                        if item.parent():
                            item.parent().setEnabled(False)

                it += 1
                item = it.current()
            if visible_parent:
                visible_parent.setEnabled(True)

        elif option == SC_FILTER_OPTIONS.FREE_PIN:
            self.sample_list_view.clear()
            self.queue_model_hwobj.select_model('free-pin')
            self.set_sample_pin_icon()
        elif option == SC_FILTER_OPTIONS.PLATE:
            #self.sample_list_view.clear()
            #self.sample_list_view.setDisabled(True)
            self.beamline_setup_hwobj.set_plate_mode(True)
            self.confirm_dialog.set_plate_mode(True)
            self.sample_list_view.clear()
            self.queue_model_hwobj.select_model('plate')
            self.set_sample_pin_icon()

        self.sample_list_view_selection()
Exemplo n.º 15
0
 def collapseAll(self):
     iter = qt.QListViewItemIterator(self._treeview)
     while iter.current():
         iter.current().setOpen(False)
         iter += 1
Exemplo n.º 16
0
 def expandAll(self):
     iter = qt.QListViewItemIterator(self._treeview)
     while iter.current():
         iter.current().setOpen(True)
         iter += 1