void ChannelTreeWidget::expandChannel(const QString &channel) { if (!channels.contains(channel)) return; CHANNELITEM channelitem = channels.value(channel); expandItem(channelitem.widgetitem); }
void TreeWidget::expandCurrentConnection() { QTreeWidgetItem* item = currentItem(); if (item && item->parent()) item = item->parent(); if (item) expandItem(item); }
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QTreeWidget( p ), p_intf(_p_intf) { /* Properties */ setFrameStyle( QFrame::NoFrame ); setAttribute( Qt::WA_MacShowFocusRect, false ); viewport()->setAutoFillBackground( false ); setIconSize( QSize( 24,24 ) ); setIndentation( 12 ); setHeaderHidden( true ); setRootIsDecorated( true ); setAlternatingRowColors( false ); /* drops */ viewport()->setAcceptDrops(true); setDropIndicatorShown(true); invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled ); #ifdef Q_OS_MAC setAutoFillBackground( true ); QPalette palette; palette.setColor( QPalette::Window, QColor(209,215,226) ); setPalette( palette ); #endif setMinimumHeight( 120 ); /* Podcasts */ podcastsParent = NULL; podcastsParentId = -1; /* Podcast connects */ CONNECT( THEMIM, playlistItemAppended( int, int ), this, plItemAdded( int, int ) ); CONNECT( THEMIM, playlistItemRemoved( int ), this, plItemRemoved( int ) ); DCONNECT( THEMIM->getIM(), metaChanged( input_item_t *), this, inputItemUpdate( input_item_t * ) ); createItems(); setRootIsDecorated( false ); setIndentation( 5 ); /* Expand at least to show level 2 */ for ( int i = 0; i < topLevelItemCount(); i++ ) expandItem( topLevelItem( i ) ); /*** * We need to react to both clicks and activation (enter-key) here. * We use curItem to avoid rebuilding twice. * See QStyle::SH_ItemView_ActivateItemOnSingleClick ***/ curItem = NULL; CONNECT( this, itemActivated( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); CONNECT( this, itemClicked( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); }
//---------------------------------------------------------------------------------------- OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, std::string initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) { mSelected = initialSelection; setColumnCount(1); setHeaderHidden(true); setSelectionMode(QAbstractItemView::SingleSelection); setSelectionBehavior(QAbstractItemView::SelectItems); setContextMenuPolicy(Qt::CustomContextMenu); setDragDropOverwriteMode(false); if(capabilities & CAP_ALLOW_DROPS) setDragDropMode(QAbstractItemView::DropOnly); mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File); mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile(); QTreeWidgetItem* item = 0; QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Project"))); pItem->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder)); pItem->setTextColor(0, Qt::black); QFont fnt = pItem->font(0); fnt.setBold(true); pItem->setFont(0, fnt); pItem->setWhatsThis(0, QString("/")); addTopLevelItem(pItem); fillTree(pItem, "/"); if(capabilities & CAP_SHOW_FILES) fillTreeFiles(pItem, "/"); expandItem(pItem); if(mSelected == "/") setItemSelected(pItem, true); else { NameTreeWidgetMap::iterator it = mItemMap.find(mSelected); if(it != mItemMap.end()) { clearSelection(); scrollToItem(it->second); setItemSelected(it->second, true); } } connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged())); if(capabilities & CAP_SHOW_FILES) { connect(this, SIGNAL(itemCollapsed( QTreeWidgetItem * )), this, SLOT(onItemCollapsed( QTreeWidgetItem * ))); connect(this, SIGNAL(itemExpanded( QTreeWidgetItem * )), this, SLOT(onItemExpanded( QTreeWidgetItem * ))); }
// \todo Optimize this so we don't have to linear search through the whole model to find out which header was clicked void AMVerticalStackWidget::onHeaderButtonClicked() { QObject* s = sender(); for(int i=0; i<count(); i++) { if(model_.data(model_.index(i,0), AM::WidgetRole).value<AMHeaderButton*>() == s) { if(itemCollapsable(i)) itemIsCollapsed(i) ? expandItem(i) : collapseItem(i); return; } } }
void ItemBoxTreeWidget::setCategoryExpanded(int cat_idx, bool expand) { QTreeWidgetItem *cat_item = topLevelItem(cat_idx); if(expand) { expandItem(cat_item); } else { collapseItem(cat_item); } }
bool pcl::modeler::SceneTree::openPointCloud(const QString& filename) { QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems(); for (auto &selected_render_window_item : selected_render_window_items) { if(!selected_render_window_item->openPointCloud(filename)) return (false); expandItem(selected_render_window_item); } emit fileOpened(filename); return (true); }
void VDirectoryTree::expandSubTree(QTreeWidgetItem *p_item) { if (!p_item) { return; } VDirectory *dir = getVDirectory(p_item); int nrChild = p_item->childCount(); for (int i = 0; i < nrChild; ++i) { expandSubTree(p_item->child(i)); } if (dir->isExpanded()) { Q_ASSERT(nrChild > 0); expandItem(p_item); } }
bool pcl::modeler::SceneTree::openPointCloud(const QString& filename) { QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems(); for (QList<RenderWindowItem*>::iterator selected_render_window_items_it = selected_render_window_items.begin(); selected_render_window_items_it != selected_render_window_items.end(); ++ selected_render_window_items_it) { if(!(*selected_render_window_items_it)->openPointCloud(filename)) return (false); expandItem(*selected_render_window_items_it); } emit fileOpened(filename); return (true); }
void VDirectoryTree::buildSubTree(QTreeWidgetItem *p_parent, int p_depth) { if (p_depth == 0) { return; } Q_ASSERT(p_parent); VDirectory *dir = getVDirectory(p_parent); if (!dir->open()) { VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to open folder <span style=\"%1\">%2</span>.") .arg(g_config->c_dataTextStyle) .arg(dir->getName()), tr("Please check if directory <span style=\"%1\">%2</span> exists.") .arg(g_config->c_dataTextStyle) .arg(dir->fetchPath()), QMessageBox::Ok, QMessageBox::Ok, this); return; } if (p_parent->childCount() > 0) { // This directory has been built before. Try its children directly. int cnt = p_parent->childCount(); for (int i = 0; i < cnt; ++i) { buildSubTree(p_parent->child(i), p_depth -1); } } else { const QVector<VDirectory *> &subDirs = dir->getSubDirs(); for (int i = 0; i < subDirs.size(); ++i) { VDirectory *subDir = subDirs[i]; QTreeWidgetItem *item = new QTreeWidgetItem(p_parent); fillTreeItem(item, subDir); buildSubTree(item, p_depth - 1); } } if (dir->isExpanded()) { expandItem(p_parent); } }
void GpxTreeWidget::buildTree() { clear(); removeAction->setEnabled(false); mergeAction->setEnabled(false); splitAction->setEnabled(false); if (_gpx==0) return; root = new QTreeWidgetItem(this); for (int i=0; i<_gpx->segmentCount(); ++i) { new QTreeWidgetItem(root); } expandItem(root); recompute(); removeAction->setEnabled(true); mergeAction->setEnabled(true); splitAction->setEnabled(true); }
void pcl::modeler::SceneTree::slotICPRegistration() { QList<CloudMeshItem*> selected_cloud_mesh_items = selectedTypeItems<CloudMeshItem>(); CloudMesh::PointCloudPtr result(new CloudMesh::PointCloud()); AbstractWorker* worker = new ICPRegistrationWorker(result, selected_cloud_mesh_items,&MainWindow::getInstance()); ThreadController* thread_controller = new ThreadController(); QList<RenderWindowItem*> selected_render_window_items = selectedRenderWindowItems(); for (auto &selected_render_window_item : selected_render_window_items) { CloudMeshItem* cloud_mesh_item = selected_render_window_item->addPointCloud(result); expandItem(selected_render_window_item); connect(worker, SIGNAL(finished()), new CloudMeshItemUpdater(cloud_mesh_item), SLOT(updateCloudMeshItem())); } thread_controller->runWorker(worker); return; }
void QCSTreeWidget::expandAll() { for (int i=0;i<topLevelItemCount();++i) expandItem(topLevelItem(i)); }
/********************************************************************* * The Tree *********************************************************************/ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : QTreeWidget( _parent ), p_intf( _p_intf ) { b_show_only_loaded = false; /* General Qt options */ setAlternatingRowColors( true ); setHeaderHidden( true ); setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) ); setTextElideMode( Qt::ElideNone ); setUniformRowHeights( true ); CONNECT( this, itemExpanded(QTreeWidgetItem*), this, resizeColumns() ); /* Nice icons */ #define BI( a,b) QIcon a##_icon = QIcon( b ) BI( audio, ":/prefsmenu/advanced/audio" ); BI( video, ":/prefsmenu/advanced/video" ); BI( input, ":/prefsmenu/advanced/codec" ); BI( sout, ":/prefsmenu/advanced/sout" ); BI( advanced, ":/prefsmenu/advanced/extended" ); BI( playlist, ":/prefsmenu/advanced/playlist" ); BI( interface, ":/prefsmenu/advanced/intf" ); #undef BI /* Build the tree for the main module */ module_t *p_module = module_get_main(); /* Initialisation and get the confsize */ PrefsItemData *data = NULL; PrefsItemData *data_sub = NULL; QTreeWidgetItem *current_item = NULL; unsigned confsize; module_config_t *const p_config = module_config_get (p_module, &confsize); /* Go through the list of conf */ for( size_t i = 0; i < confsize; i++ ) { const char *psz_help; QIcon icon; /* Work on a new item */ module_config_t *p_item = p_config + i; switch( p_item->i_type ) { /* This is a category */ case CONFIG_CATEGORY: if( p_item->value.i == -1 ) break; /* PrefsItemData Init */ data = new PrefsItemData(); data->name = qtr( config_CategoryNameGet( p_item->value.i ) ); psz_help = config_CategoryHelpGet( p_item->value.i ); if( psz_help ) data->help = qtr( psz_help ); else data->help.clear(); data->i_type = PrefsItemData::TYPE_CATEGORY; data->i_object_id = p_item->value.i; /* This is a category, put a nice icon */ switch( p_item->value.i ) { #define CI(a,b) case a: icon = b##_icon;break CI( CAT_AUDIO, audio ); CI( CAT_VIDEO, video ); CI( CAT_INPUT, input ); CI( CAT_SOUT, sout ); CI( CAT_ADVANCED, advanced ); CI( CAT_PLAYLIST, playlist ); CI( CAT_INTERFACE, interface ); } #undef CI /* Create a new QTreeItem to display it in the tree at top level */ current_item = new QTreeWidgetItem(); current_item->setText( 0, data->name ); current_item->setIcon( 0 , icon ); //current_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) ); current_item->setData( 0, Qt::UserRole, qVariantFromValue( data ) ); addTopLevelItem( current_item ); expandItem( current_item ); break; /* This is a subcategory */ case CONFIG_SUBCATEGORY: if( p_item->value.i == -1 ) break; /* Special cases: move the main subcategories to the parent cat*/ if( data && ( p_item->value.i == SUBCAT_VIDEO_GENERAL || p_item->value.i == SUBCAT_ADVANCED_MISC || p_item->value.i == SUBCAT_INPUT_GENERAL || p_item->value.i == SUBCAT_INTERFACE_GENERAL || p_item->value.i == SUBCAT_SOUT_GENERAL|| p_item->value.i == SUBCAT_PLAYLIST_GENERAL|| p_item->value.i == SUBCAT_AUDIO_GENERAL ) ) { /* Data still contains the correct thing */ data->i_type = PrefsItemData::TYPE_CATSUBCAT; data->i_subcat_id = p_item->value.i; data->name = qtr( config_CategoryNameGet( p_item->value.i ) ); psz_help = config_CategoryHelpGet( p_item->value.i ); if( psz_help ) data->help = qtr( psz_help ); else data->help.clear(); current_item->setData( 0, Qt::UserRole, QVariant::fromValue( data ) ); continue; } /* Normal Subcategories */ /* Process the Data */ data_sub = new PrefsItemData(); data_sub->name = qtr( config_CategoryNameGet( p_item->value.i) ); psz_help = config_CategoryHelpGet( p_item->value.i ); if( psz_help ) data_sub->help = qtr( psz_help ); else data_sub->help.clear(); data_sub->i_type = PrefsItemData::TYPE_SUBCATEGORY; data_sub->i_object_id = p_item->value.i; /* Create a new TreeWidget */ QTreeWidgetItem *subcat_item = new QTreeWidgetItem(); subcat_item->setText( 0, data_sub->name ); subcat_item->setData( 0, Qt::UserRole, qVariantFromValue( data_sub ) ); //subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) ); /* Add it to the parent */ assert( current_item ); current_item->addChild( subcat_item ); break; /* Other items don't need yet a place on the tree */ } } module_config_free( p_config ); size_t count; module_t **p_list = module_list_get( &count ); /* Build the tree of plugins */ for( size_t i = 0; i < count; i++ ) { p_module = p_list[i]; // Main module excluded if( module_is_main( p_module) ) continue; unsigned confsize; int i_subcategory = 0, i_category = 0; bool b_options = false; module_config_t *const p_config = module_config_get (p_module, &confsize); /* Loop through the configurations items */ for (size_t i = 0; i < confsize; i++) { const module_config_t *p_item = p_config + i; if( p_item->i_type == CONFIG_CATEGORY ) i_category = p_item->value.i; else if( p_item->i_type == CONFIG_SUBCATEGORY ) i_subcategory = p_item->value.i; if( CONFIG_ITEM(p_item->i_type) ) b_options = true; if( b_options && i_category && i_subcategory ) break; } module_config_free (p_config); /* Dummy item, please proceed */ if( !b_options || i_category == 0 || i_subcategory == 0 ) continue; // Locate the category item; QTreeWidgetItem *subcat_item = NULL; bool b_found = false; for( int i_cat_index = 0 ; i_cat_index < topLevelItemCount(); i_cat_index++ ) { /* Get the treeWidgetItem that correspond to the category */ QTreeWidgetItem *cat_item = topLevelItem( i_cat_index ); PrefsItemData *data = cat_item->data( 0, Qt::UserRole ). value<PrefsItemData *>(); /* If we match the good category */ if( data->i_object_id == i_category ) { for( int i_sc_index = 0; i_sc_index < cat_item->childCount(); i_sc_index++ ) { subcat_item = cat_item->child( i_sc_index ); PrefsItemData *sc_data = subcat_item->data(0, Qt::UserRole). value<PrefsItemData *>(); if( sc_data && sc_data->i_object_id == i_subcategory ) { b_found = true; break; } } if( !b_found ) { subcat_item = cat_item; b_found = true; } break; } } if( !b_found ) continue; PrefsItemData *module_data = new PrefsItemData(); module_data->i_type = PrefsItemData::TYPE_MODULE; module_data->psz_shortcut = strdup( module_get_object( p_module ) ); module_data->name = qtr( module_get_name( p_module, false ) ); module_data->help.clear(); const char *psz_help = module_get_help( p_module ); if ( psz_help ) module_data->help = qtr( psz_help ); QTreeWidgetItem *module_item = new QTreeWidgetItem(); module_item->setText( 0, module_data->name ); module_item->setData( 0, Qt::UserRole, QVariant::fromValue( module_data) ); //module_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) ); subcat_item->addChild( module_item ); } /* We got everything, just sort a bit */ sortItems( 0, Qt::AscendingOrder ); module_list_free( p_list ); resizeColumnToContents( 0 ); }
SensorBrowserTreeWidget::SensorBrowserTreeWidget( QWidget* parent, KSGRD::SensorManager* sm ) : QTreeView( parent ), mSensorManager( sm ) { mSortFilterProxyModel.setSourceModel(&mSensorBrowserModel); mSortFilterProxyModel.setShowAllChildren(true); setModel(&mSortFilterProxyModel); connect( mSensorManager, SIGNAL(update()), &mSensorBrowserModel, SLOT(update()) ); connect( mSensorManager, SIGNAL(hostAdded(KSGRD::SensorAgent*,QString)), &mSensorBrowserModel, SLOT(hostAdded(KSGRD::SensorAgent*,QString)) ); connect( mSensorManager, SIGNAL(hostConnectionLost(QString)), &mSensorBrowserModel, SLOT(hostRemoved(QString)) ); // connect( mSensorManager, SIGNAL(hostAdded(KSGRD::SensorAgent*,QString)), SLOT(updateView()) ); // connect( mSensorManager, SIGNAL(hostConnectionLost(QString)), SLOT(updateView()) ); connect( &mSortFilterProxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(updateView()) ); setDragDropMode(QAbstractItemView::DragOnly); setUniformRowHeights(true); //setMinimumWidth( 1 ); retranslateUi(); connect( &mSensorBrowserModel, SIGNAL(sensorsAddedToHost(QModelIndex)), this, SLOT(expandItem(QModelIndex))); KSGRD::SensorManagerIterator it( mSensorManager ); while ( it.hasNext() ) { KSGRD::SensorAgent* sensorAgent = it.next().value(); QString hostName = mSensorManager->hostName( sensorAgent ); mSensorBrowserModel.addHost(sensorAgent, hostName); } updateView(); }
int QTreeWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QTreeView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: itemPressed((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 1: itemClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 2: itemDoubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 3: itemActivated((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 4: itemEntered((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 5: itemChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 6: itemExpanded((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; case 7: itemCollapsed((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; case 8: currentItemChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break; case 9: itemSelectionChanged(); break; case 10: scrollToItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemView::ScrollHint(*)>(_a[2]))); break; case 11: scrollToItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 12: expandItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 13: collapseItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 14: clear(); break; case 15: d_func()->_q_emitItemPressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: d_func()->_q_emitItemClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 17: d_func()->_q_emitItemDoubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 18: d_func()->_q_emitItemActivated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 19: d_func()->_q_emitItemEntered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 20: d_func()->_q_emitItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 21: d_func()->_q_emitItemExpanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 22: d_func()->_q_emitItemCollapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 23: d_func()->_q_emitCurrentItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 24: d_func()->_q_sort(); break; case 25: d_func()->_q_dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 26: d_func()->_q_itemsSorted(); break; case 27: d_func()->_q_selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break; } _id -= 28; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = columnCount(); break; case 1: *reinterpret_cast< int*>(_v) = topLevelItemCount(); break; } _id -= 2; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setColumnCount(*reinterpret_cast< int*>(_v)); break; } _id -= 2; } else if (_c == QMetaObject::ResetProperty) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 2; } #endif // QT_NO_PROPERTIES return _id; }