C++ (Qt)void proxyPaneWidget::showCustomMenu(const QPoint &pos){ m_currentItemIndex = m_proxyList->indexAt(pos); m_proxyMenu->addAction( m_deleteAction ); m_proxyMenu->exec( m_proxyList->mapToGlobal( pos ) ); m_currentItemIndex...; // HOW TO DO?}
C++ (Qt)void proxyPaneWidget::deleteSelectedItem(){ QModelIndex index = m_proxyList->currentIndex(); if( m_currentItemIndex.isValid() ) index = m_currentItemIndex; m_source->removeItem(m_proxyModel->mapToSource(index).row());}
C++ (Qt)void proxyPaneWidget::deleteSelectedItem(){ const QModelIndex & index = m_proxyList->currentIndex(); if ( index.isValid() ) { int row = m_proxyModel->mapToSource(index).row(); m_source->removeItem(row); }}
C++ (Qt)void proxyPaneWidget::deleteSelectedItem( QModelIndex * delIndex ) // delIndex = 0 в прототипе{ QModelIndex index = delIndex ? *delIndex : m_proxyList->currentIndex();
C++ (Qt)void proxyPaneWidget::showCustomMenu(const QPoint &pos){ QAction * m_deleteAction = new QAction( this ); m_deleteAction->setText( tr( "Delite" ) ); m_deleteAction->setShortcut( QKeySequence( QKeySequence::Delete ) ); m_deleteAction->setShortcutContext( Qt::WidgetWithChildrenShortcut ); m_proxyMenu = new QMenu( m_proxyList ); m_proxyMenu->addAction( m_deleteAction ); QModelIndex selectedItemIndex = m_proxyList->indexAt(pos); QAction *menuAct = new QAction(this); menuAct = m_proxyMenu->exec( m_proxyList->mapToGlobal( pos ) ); if( menuAct->text() == "Delite" ) deleteSelectedItem(&selectedItemIndex);}
C++ (Qt)void proxyPaneWidget::deleteSelectedItem(QModelIndex * delIndex){ m_currentItemIndex = delIndex ? *delIndex : m_proxyList->currentIndex(); m_source->removeItem( m_proxyModel->mapToSource( m_currentItemIndex ).row() );}