FilmsViewList::FilmsViewList( QWidget* parent ) : QTableView( parent ) { // Appearance setAlternatingRowColors( true ); setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionMode( QAbstractItemView::ExtendedSelection ); setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); setEditTriggers( QAbstractItemView::NoEditTriggers ); setContextMenuPolicy( Qt::CustomContextMenu ); setSortingEnabled( true ); setShowGrid( false ); verticalHeader()->setVisible( false ); horizontalHeader()->setSectionsMovable( true ); horizontalHeader()->setHighlightSections( false ); horizontalHeader()->setStretchLastSection( true ); horizontalHeader()->setDefaultSectionSize( 50 ); horizontalHeader()->setMinimumSectionSize( 20 ); horizontalHeader()->setContextMenuPolicy( Qt::CustomContextMenu ); // Signals connect( horizontalHeader(), &QHeaderView::customContextMenuRequested, this, &FilmsViewList::ShowHeaderContextMenu ); connect( this, SIGNAL(activated(QModelIndex)), this, SIGNAL(CurrentActivated(QModelIndex)) ); connect( this, &QTableView::customContextMenuRequested, this, [this] (const QPoint& pos) { if( currentIndex().isValid() ) { emit ContextMenuRequested( pos, selectionModel()->currentIndex() ); } }); }
QMwStructuresWidget::QMwStructuresWidget(QWidget *parent) : QTreeWidget(parent) { this->contextMenu = new QMenu(this); QAction *deleteAction = new QAction("Delete", this); QObject::connect(deleteAction, SIGNAL(triggered()), this, SLOT(ContextMenuDeleteTriggered())); this->contextMenu->addAction(deleteAction); QAction *wrapInEntitySetAction = new QAction("Wrap in Entity set", this); QObject::connect(wrapInEntitySetAction, SIGNAL(triggered()), this, SLOT(ContextMenuWrapInEntitySetTriggered())); this->contextMenu->addAction(wrapInEntitySetAction); QObject::connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(CurrentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); this->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(this, SIGNAL(customContextMenuRequested(QPoint)), SLOT(ContextMenuRequested(QPoint))); this->dragMode = QMwStructuresWidget::DragMode_None; }