void StatusActions::createActions() { createBasicActions(); createStatusActions(); QList<StatusType *> statusTypes = MyStatusContainer->supportedStatusTypes(); if (statusTypes.isEmpty()) return; StatusType *statusType = statusTypes.at(0); if (0 == statusType) return; StatusGroup *currentGroup = statusType->statusGroup(); bool setDescriptionAdded = false; foreach (StatusType *statusType, statusTypes) { if (0 == statusType) continue; if (!setDescriptionAdded && statusType->statusGroup() && statusType->statusGroup()->sortIndex() >= StatusGroup::StatusGroupSortIndexAfterSetDescription) { Actions.append(createSeparator()); Actions.append(ChangeDescription); } if (statusType->statusGroup() != currentGroup) { Actions.append(createSeparator()); currentGroup = statusType->statusGroup(); } Actions.append(StatusTypeActions[statusType]); } Actions.append(createSeparator()); }
void LastFmTreeView::contextMenuEvent ( QContextMenuEvent* event ) { m_currentItems.clear(); foreach ( const QModelIndex &i, selectedIndexes() ) { if ( i.isValid() ) m_currentItems << i; } if ( m_currentItems.isEmpty() ) return; QAction separator ( this ); separator.setSeparator ( true ); QActionList actions = createBasicActions( m_currentItems ); actions += &separator; KMenu menu; foreach ( QAction * action, actions ) menu.addAction ( action ); menu.exec ( event->globalPos() ); }
void LastFmTreeView::startDrag(Qt::DropActions supportedActions) { DEBUG_BLOCK //setSelectionMode( QAbstractItemView::NoSelection ); // When a parent item is dragged, startDrag() is called a bunch of times. Here we prevent that: m_dragMutex.lock(); if( m_ongoingDrag ) { m_dragMutex.unlock(); return; } m_ongoingDrag = true; m_dragMutex.unlock(); if( !m_pd ) m_pd = The::popupDropperFactory()->createPopupDropper( Context::ContextView::self() ); if( m_pd && m_pd->isHidden() ) { QModelIndexList indices = selectedIndexes(); QActionList actions = createBasicActions( indices ); QFont font; font.setPointSize( 16 ); font.setBold( true ); foreach( QAction * action, actions ) m_pd->addItem( The::popupDropperFactory()->createItem( action ) ); m_currentItems.clear(); foreach( const QModelIndex &index, indices ) { if( index.isValid() && index.internalPointer() ) m_currentItems << index; } PopupDropperItem* subItem; PopupDropper * morePud = 0; if ( actions.count() > 1 ) { morePud = The::popupDropperFactory()->createPopupDropper( 0, true ); foreach( QAction * action, actions ) morePud->addItem( The::popupDropperFactory()->createItem( action ) ); } else m_pd->addItem( The::popupDropperFactory()->createItem( actions[0] ) ); //TODO: Keep bugging i18n team about problems with 3 dots if ( actions.count() > 1 ) { subItem = m_pd->addSubmenu( &morePud, i18n( "More..." ) ); The::popupDropperFactory()->adjustItem( subItem ); } m_pd->show(); }