KFindTreeView::KFindTreeView( QWidget *parent, KfindDlg * findDialog ) : QTreeView( parent ) , m_contextMenu(0), m_kfindDialog(findDialog) { //Configure model and proxy model m_model = new KFindItemModel( this ); m_proxyModel = new KFindSortFilterProxyModel(); m_proxyModel->setSourceModel( m_model ); setModel( m_proxyModel ); //Configure QTreeView setRootIsDecorated( false ); setSelectionMode( QAbstractItemView::ExtendedSelection ); setSortingEnabled( true ); setDragEnabled( true ); setContextMenuPolicy( Qt::CustomContextMenu ); connect( this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); //Mouse single/double click settings connect( KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, SLOT(reconfigureMouseSettings()) ); reconfigureMouseSettings(); // TODO: this is a workaround until Qt-issue 176832 has been fixed (from Dolphin) connect(this, SIGNAL(pressed(QModelIndex)), this, SLOT(updateMouseButtons())); //Generate popup menu actions m_actionCollection = new KActionCollection( this ); m_actionCollection->addAssociatedWidget(this); KAction * open = KStandardAction::open(this, SLOT(slotExecuteSelected()), this); m_actionCollection->addAction( "file_open", open ); KAction * copy = KStandardAction::copy(this, SLOT(copySelection()), this); m_actionCollection->addAction( "edit_copy", copy ); KAction * openFolder = new KAction( KIcon("window-new"), i18n("&Open containing folder(s)"), this ); connect( openFolder, SIGNAL(triggered()), this, SLOT(openContainingFolder()) ); m_actionCollection->addAction( "openfolder", openFolder ); KAction * del = new KAction( KIcon("edit-delete"), i18n("&Delete"), this ); connect( del, SIGNAL(triggered()), this, SLOT(deleteSelectedFiles()) ); del->setShortcut(Qt::SHIFT + Qt::Key_Delete); m_actionCollection->addAction( "del", del ); KAction * trash = new KAction( KIcon("user-trash"), i18n("&Move to Trash"), this ); connect( trash, SIGNAL(triggered()), this, SLOT(moveToTrashSelectedFiles()) ); trash->setShortcut(Qt::Key_Delete); m_actionCollection->addAction( "trash", trash ); header()->setStretchLastSection( true ); sortByColumn( 0, Qt::AscendingOrder ); }
PlaylistView::PlaylistView(QWidget *parent) : QTableView(parent), contextMenu(new QMenu(this)) { this->setAcceptDrops(true); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setDragEnabled(true); this->setDragDropOverwriteMode(false); this->setDragDropMode(QAbstractItemView::DragDrop); this->setDefaultDropAction(Qt::MoveAction); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setShowGrid(false); #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) this->contextMenu->addAction(QIcon::fromTheme("help-contents"), "Details", this, &PlaylistView::showInspector); this->contextMenu->addAction(QIcon::fromTheme("system-file-manager"), "Open containing folder", this, &PlaylistView::openContainingFolder); #else this->contextMenu->addAction(QIcon::fromTheme("help-contents"), "Details", this, SLOT(showInspector())); this->contextMenu->addAction(QIcon::fromTheme("system-file-manager"), "Open containing folder", this, SLOT(openContainingFolder())); #endif }