Returns items in selection as a QItemSelection object
168875
def selection(self):
        """"""
        sel = QtGui.QItemSelection()
        for index in self.selectedIndexes():
            sel.select(index, index)
        return sel
788266
def _get_selected_item(self):
        """"""
        selection = self.get_selection()
        if selection.get_mode() != gtk.SELECTION_SINGLE:
            raise AttributeError('selected_item not valid for select_multiple')
        model, selected = selection.get_selected()
        if selected is not None:
            return self._object_at_sort_iter(selected)
374721
def selected(self, sel):
        """"""
        ParameterItem.selected(self, sel)

        if self.widget is None:
            return
        if sel and self.param.writable():
            self.showEditor()
        elif self.hideWidget:
            self.hideEditor()
1331192
function getSelectionRects() {
  try {
    let selection = window.getSelection();
    let range = selection.getRangeAt(0);
    let rects = range.getClientRects();

    if (rects.length > 0 &&
        rects[0].width > 0 &&
        rects[0].height > 0) {
      return rects;
    }
  } catch (e) {}
  
  return null;
}
641242
def get_selected(self):
        
        if self.multi_select:
            return_tuples = []
            for selected in self.all_selected:
                return_tuples.append((self.options[selected], selected))
            return return_tuples
        else:
            return self.options[self.index], self.index
537208
def list_view_on_selected(self, widget, selected_item_key):
        
        self.lbl.set_text('List selection: ' + self.listView.children[selected_item_key].get_text())
831428
function _get_selected(){
    	var ret_list = [];
	var selected_strings =
	    jQuery('#'+ sul_id).sortable('toArray', {'attribute': 'value'});
    	each(selected_strings,
    	     function(in_thing){
		 if( in_thing && in_thing != '' ){
		     ret_list.push(in_thing);
		 }
	     });
	return ret_list;
    }
361883
function selectItem(editor, model, getItemRange) {
	editor.transact(() => {
		const selections = editor.getSelectedBufferRanges()
		.map(anchor => getItemRange(model, anchor) || anchor);

		editor.setSelectedBufferRanges(selections);
	});
}
1288218
def _onCompletionListItemSelected(self, index):
        
        model = self._widget.model()
        selectedWord = model.words[index]
        textToInsert = selectedWord[len(model.typedText()):]
        self._qpart.textCursor().insertText(textToInsert)
        self._closeCompletion()
1324155
def eventFilter(self, widget, event):
        """"""
        if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
            index = self.view().currentIndex().row()
            if index >= EXTERNAL_PATHS:
                # Remove item and update the view.
                self.removeItem(index)
                self.showPopup()
                # Set the view selection so that it doesn't bounce around.
                new_index = min(self.count() - 1, index)
                new_index = 0 if new_index < EXTERNAL_PATHS else new_index
                self.view().setCurrentIndex(self.model().index(new_index, 0))
                self.setCurrentIndex(new_index)
            return True
        return QComboBox.eventFilter(self, widget, event)
659144
def select(self, cursor, qstring, vals=()):
    ""
    cursor.execute(qstring, vals) # hmm; do I not want to commit at the end of this?
    return cursor.fetchall()
894313
def _selectView( self ):
        
        scene = self.uiGanttVIEW.scene()
        scene.blockSignals(True)
        scene.clearSelection()
        for item in self.uiGanttTREE.selectedItems():
            item.viewItem().setSelected(True)
        scene.blockSignals(False)
        
        curr_item = self.uiGanttTREE.currentItem()
        vitem = curr_item.viewItem()
        
        if vitem:
            self.uiGanttVIEW.centerOn(vitem)
274478
public void selectTemporary(TwinTextItem item) {
        // if we just want to clear the selection:
        if(item == null) {
            setSelection(getLastItemPosition());
            // the call is passed on to the adapter in setSelection.
            return;
        }
        PickerSpinnerAdapter adapter = (PickerSpinnerAdapter) getAdapter();
        // pass on the call to the adapter (just stores the item):
        adapter.selectTemporary(item);
        final int tempItemPosition = adapter.getCount();
        if(getSelectedItemPosition() == tempItemPosition) {
            // this is quite a hack, first reset the position to 0 but intercept the callback,
            // then redo the selection:
            setSelectionQuietly(0);
        }
        super.setSelection(tempItemPosition);
        // during initialization the system might check our selected position and reset it,
        // thus we need to check after the message queue has been settled
        if (!restoreTemporarySelection) {
            restoreTemporarySelection = true;
            post(new Runnable() {
                @Override
                public void run() {
                    if (restoreTemporarySelection) {
                        restoreTemporarySelection = false;
                        reselectTemporaryItem = false;
                        final int tempItemPosition = getAdapter().getCount();
                        if (getSelectedItemPosition() != tempItemPosition)
                            superSetSelection(tempItemPosition);
                    }
                }
            });
        }
    }
531088
def select(self, model):
    
    res = []

    def doSelect(value, pre, remaining):
      if not remaining:
        res.append((pre, value))
      else:
        # For the other selectors to work, value must be a Tuple or a list at this point.
        if not is_tuple(value) and not isinstance(value, list):
          return

        qhead, qtail = remaining[0], remaining[1:]
        if isinstance(qhead, tuple) and is_tuple(value):
          for alt in qhead:
            if alt in value:
              doSelect(value[alt], pre + [alt], qtail)
        elif qhead == '*':
          if isinstance(value, list):
            indices = range(len(value))
            reprs = [listKey(i) for i in indices]
          else:
            indices = value.keys()
            reprs = indices

          for key, rep in zip(indices, reprs):
            doSelect(value[key], pre + [rep], qtail)
        elif isinstance(qhead, int) and isinstance(value, list):
          doSelect(value[qhead], pre + [listKey(qhead)], qtail)
        elif is_tuple(value):
          if qhead in value:
            doSelect(value[qhead], pre + [qhead], qtail)

    for selector in self.selectors:
      doSelect(model, [], selector)

    return QueryResult(res)
131773
private static <T> List<T> filterSelection(Class<T> clazz,
      IStructuredSelection selection) {
    List<T> list = new ArrayList<T>();
    for (Object obj : selection.toList()) {
      if (clazz.isAssignableFrom(obj.getClass())) {
        list.add((T) obj);
      }
    }
    return list;
  }
1066289
def selectAll( self ):
        
        currLayer = self._currentLayer
        for item in self.items():
            layer = item.layer()
            if ( layer == currLayer or not layer ):
                item.setSelected(True)
1314300
def get_visible_items(self):
        """"""
        items = []
        iterator = QTreeWidgetItemIterator(self)
        while iterator.value():
            item = iterator.value()
            if not item.isHidden():
                if item.parent():
                    if item.parent().isExpanded():
                        items.append(item)
                else:
                    items.append(item)
            iterator += 1
        return items