Beispiel #1
0
 def handle_alias(self):
     val = self.ui.lineedit_alias.text()  # Already validated (?)
     tw = self.ui.tablewidget_defined_species
     row = get_selected_row(tw)
     if row is None:  # No selection
         return
     #note, making a new item here, instead of changing item inplace
     item = QTableWidgetItem(val)
     set_item_noedit(item)
     tw.setItem(row, 0, item)
     defined_species = OrderedDict()
     for (key, data) in self.defined_species.items():
         if key == self.current_species:
             key = val
             data['alias'] = val
         defined_species[key] = data
     self.current_species = val
     self.defined_species = defined_species
Beispiel #2
0
    def add_defined_species_row(self, species, select=False):
        species_data = self.defined_species[species]
        ui = self.ui
        tw = ui.tablewidget_defined_species
        nrows = tw.rowCount()
        tw.setRowCount(nrows + 1)
        alias = species_data['alias']
        assert alias == species
        phase = species_data['phase']
        item = QTableWidgetItem(alias)
        set_item_noedit(item)
        tw.setItem(nrows, 0, item)
        item = QTableWidgetItem(phase)
        set_item_noedit(item)
        tw.setItem(nrows, 1, item)

        if select:
            tw.setCurrentCell(nrows, 0)  # Cause the new row to be selected
Beispiel #3
0
    def do_search(self, string):
        lineedit = self.ui.lineedit_search
        string = string.lstrip()  # Don't allow leading spaces
        if string != lineedit.text():
            lineedit.setText(string)
            return

        self.ui.tablewidget_search.clearContents()
        results = []
        match_empty = True  # Show all possibilities when no search string
        if match_empty or string:
            needle = squash(string)
            for (k, key, phase) in self.haystack:
                if (phase in self.phases
                        and (needle in k[0] or
                             (self.include_comments and needle in k[1]))):
                    results.append((key, phase))
        # Put exact matches & leading-substring matches first
        if string:
            results.sort(key=lambda x:
                         (1 - x[0][0].lower().startswith(string.lower()), x))

        tw = self.ui.tablewidget_search
        nrows = len(results)
        self.ui.tablewidget_search.clearContents()
        self.ui.tablewidget_search.setRowCount(nrows)
        self.search_results = [None] * nrows

        # http://stackoverflow.com/questions/10192579/
        tw.model().blockSignals(True)
        for (i, r) in enumerate(results):
            key, phase = r
            comment = self.comments[phase][key]
            item = QTableWidgetItem(key[0])
            item.setToolTip(comment)
            set_item_noedit(item)
            tw.setItem(i, 0, item)
            item = QTableWidgetItem(phase)
            set_item_noedit(item)
            tw.setItem(i, 1, item)
            self.search_results[i] = (key, phase)
        tw.model().blockSignals(False)
Beispiel #4
0
 def change_is_type(self, idx):
     if not self.iss_current_indices:
         return
     ui = self.ui.internal_surfaces
     row = get_selected_row(ui.tablewidget_regions)
     if row is None:
         return
     new_name = IS_NAMES[idx]
     new_type = IS_TYPES[idx]
     item = QTableWidgetItem(new_name)
     set_item_noedit(item)
     ui.tablewidget_regions.setItem(row, 1, item)
     for IS in self.iss_current_indices:
         self.update_keyword('is_type', new_type, args=[IS])
         for kw in list(self.project.keywordItems()):
             if kw.key.startswith('is_') and kw.args and kw.args[0] == IS:
                 if kw.key not in ('is_type', 'is_x_e', 'is_x_w', 'is_y_s',
                                   'is_y_n', 'is_z_b', 'is_z_t'):
                     self.unset_keyword(kw.key, args=kw.args)
     self.iss_setup_current_tab()
Beispiel #5
0
 def make_item(val):
     item = QTableWidgetItem('' if val is None else str(val))
     set_item_noedit(item)
     return item
Beispiel #6
0
 def make_item(str):
     item = QTableWidgetItem(str)
     set_item_noedit(item)
     set_item_enabled(item, False)
     return item