Exemple #1
0
// ----------------------------------------------------------------------------
// ArchiveEntryList::filterList
//
// Filters the list to only entries and directories with names matching
// [filter], and with type categories matching [category].
// ----------------------------------------------------------------------------
void ArchiveEntryList::filterList(string filter, string category)
{
	// Update variables
	filter_text = filter;
	filter_category = category;

	// Save current selection
	vector<ArchiveEntry*> selection = getSelectedEntries();
	ArchiveEntry* focus = getFocusedEntry();

	// Apply the filter
	clearSelection();
	applyFilter();

	// Restore selection (if selected entries aren't filtered)
	ArchiveEntry* entry = nullptr;
	for (int a = 0; a < GetItemCount(); a++)
	{
		entry = getEntry(a, false);
		for (unsigned b = 0; b < selection.size(); b++)
		{
			if (entry == selection[b])
			{
				selectItem(a);
				break;
			}
		}

		if (entry == focus)
		{
			focusItem(a);
			EnsureVisible(a);
		}
	}
}
Exemple #2
0
void TListBox::setData( void *rec )
{
    TListBoxRec *p = (TListBoxRec *)rec;
    newList(p->items);
    focusItem(p->selection);
    drawView();
}
Exemple #3
0
  void Scene2D::keyPressEvent(QKeyEvent *event) {
    // If we are not in a text box
    if(focusItem() == 0){
      d_->event_controller()->keyPressEvent(event);
    }

    QGraphicsScene::keyPressEvent(event);
  }
void TListViewer::focusItemNum(int item) {
   if (item < 0) item = 0;
      else
   if (item >= range && range > 0)
      item = range - 1;

   if (range !=  0)
      focusItem(item);
}
Exemple #5
0
void TDirListBox::newDirectory( const char *str )
{
    strcpy( dir, str );
    TDirCollection *dirs = new TDirCollection( 5, 5 );
    dirs->insert( new TDirEntry( drives, drives ) );
    if( strcmp( dir, drives ) == 0 )
        showDrives( dirs );
    else
        showDirs( dirs );
    newList( dirs );
    focusItem( cur );
}
Exemple #6
0
void TListBox::newList( TCollection *aList )
{
    destroy( items );
    items = aList;
    if( aList != 0 )
        setRange( aList->getCount() );
    else
        setRange(0);
    if( range > 0 )
        focusItem(0);
    drawView();
}
Exemple #7
0
/**
	Gere les enfoncements de touches du clavier
	@param e QKeyEvent decrivant l'evenement clavier
*/
void Diagram::keyPressEvent(QKeyEvent *e) {
	bool transmit_event = true;
	if (!isReadOnly()) {
		QPointF movement;
		switch(e -> key()) {
			case Qt::Key_Left:  movement = QPointF(-xGrid, 0.0); break;
			case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break;
			case Qt::Key_Up:    movement = QPointF(0.0, -yGrid); break;
			case Qt::Key_Down:  movement = QPointF(0.0, +yGrid); break;
		}
		if (!movement.isNull() && !focusItem()) {
			beginMoveElements();
			continueMoveElements(movement);
			e -> accept();
			transmit_event = false;
		}
	}
	if (transmit_event) {
		QGraphicsScene::keyPressEvent(e);
	}
}