ProcessListView::ProcessListView(QWidget *parent) : QTreeView(parent) { queueMode = false; //Model model = new ProcessListModel(this); proxyModel = new QSortFilterProxyModel(); proxyModel->setDynamicSortFilter(true); proxyModel->setSourceModel(model); proxyModel->setFilterKeyColumn(Name); proxyModel->setFilterRole(Qt::DisplayRole); setModel(proxyModel); delegate = new ProcessListDelegate(this, model); setItemDelegate(delegate); //View Settings setRootIsDecorated(false); setAllColumnsShowFocus(true); setSortingEnabled(false); setSelectionMode(QAbstractItemView::SingleSelection); setItemsExpandable(false); setAutoScroll(true); setContextMenuPolicy(Qt::CustomContextMenu); setAcceptDrops(true); // setDragDropOverwriteMode(true); setDropIndicatorShown(true); // setDragEnabled(true); setDragEnabled(true); // setDragDropMode(QAbstractItemView::DragDrop); //Actions actionRemove = new QAction(this); actionRemove->setText(tr("&Remove")); actionStart = new QAction(this); actionStart->setText(tr("&Start")); actionCancel = new QAction(this); actionCancel->setText(tr("&Cancel")); actionResult = new QAction(this); actionResult->setText(tr("show R&esult")); //Connections //context menu connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); //start selected process connect(actionStart, SIGNAL(triggered(bool)), this, SLOT(start())); //remove selected process connect(actionRemove, SIGNAL(triggered(bool)), this, SLOT(remove())); connect(actionCancel, SIGNAL(triggered(bool)), this, SLOT(cancel())); connect(actionResult, SIGNAL(triggered(bool)), this, SLOT(showResult())); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(showProcessTooltip(QModelIndex))); connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(showResult(QModelIndex))); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(displaySelected(QModelIndex))); }
DragDropListWidget::DragDropListWidget(QWidget *parent) : QListWidget(parent) { setAcceptDrops(true); setDropIndicatorShown(true); }
Playlist::Playlist(QWidget* parent) : QTreeWidget( parent ) , m_marker( 0 ) , m_CurrentTrackColor(QColor( 255,100,100 )) , m_NextTrackColor(QColor( 200,200,255 )) , m_PlaylistMode( Playlist::Playlist_Single ) , nextPlaylistItem (0) , previousPlaylistItem(0) , currentPlaylistItem(0) , newPlaylistItem(0) , m_alternateMax(0) , showDropHighlighter(false) , autoClearOn(false) , m_isPlaying(false) , m_isInternDrop(false) , m_dragLocked(false) , isChangeSignalEnabled(true) { setSortingEnabled( false ); setAcceptDrops( true ); setDragEnabled( true ); setAllColumnsShowFocus( false ); setDropIndicatorShown(true); setAcceptDrops(true); setDragEnabled(true); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); setDragDropMode(QAbstractItemView::InternalMove); setAttribute(Qt::WA_MacShowFocusRect, false); setUniformRowHeights(true); QStringList headers; headers << tr("Url")<<tr("No")<<tr("Played")<<tr("Artist")<<tr("Title"); headers <<tr("Album")<<tr("Year")<<tr("Genre")<<tr("Track"); headers <<tr("Length")<<tr("Rate"); QTreeWidgetItem *headeritem = new QTreeWidgetItem(headers); setHeaderItem(headeritem); setHeaderLabels(headers); header()->setResizeMode(QHeaderView::Interactive); header()->hideSection(PlaylistItem::Column_Url); // prevent click event if doubleclicked ignoreNextRelease = false; timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(emitClicked())); timerDragLock = new QTimer(this); timerDragLock->setInterval(300); connect(timerDragLock, SIGNAL(timeout()), this, SLOT(timeoutDragLock())); connect( this, SIGNAL(itemClicked(QTreeWidgetItem*,int)) , this, SLOT(slotItemClicked(QTreeWidgetItem*,int))); connect( this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)) , this, SLOT(slotItemDoubleClicked(QTreeWidgetItem*,int))); connect( this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); }
KNMusicTreeViewBase::KNMusicTreeViewBase(QWidget *parent, KNMusicTab *tab) : QTreeView(parent), m_musicTab(tab), m_mouseAnime(new QTimeLine(200, this)), m_proxyModel(nullptr), m_hScrollBar(new QScrollBar(Qt::Horizontal, this)), m_vScrollBar(new QScrollBar(Qt::Vertical, this)), m_dragMoveRow(-1), m_dragIndicatorPos(QAbstractItemView::OnViewport), m_initialLoad(true), m_pressed(false), m_notAcceptDragMove(false) { //Set properties. setAllColumnsShowFocus(true); setAlternatingRowColors(false); //We will use our own alternating drawing. setContentsMargins(0, 0, 0, 0); setDragDropMode(QAbstractItemView::InternalMove); setDragEnabled(true); setDropIndicatorShown(true); setFrameShape(QFrame::NoFrame); setIndentation(0); setMouseTracking(true); setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); setUniformRowHeights(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //Set scroll bar policies. horizontalScrollBar()->setSingleStep(5); horizontalScrollBar()->setPageStep(5); verticalScrollBar()->setSingleStep(4); verticalScrollBar()->setPageStep(4); //Configure the horizontal scroll bar. m_hScrollBar->setObjectName("MusicScrollBar"); m_hScrollBar->setStyle(KNSaoStyle::instance()); m_hScrollBar->hide(); m_hScrollBar->setFixedHeight(ScrollBarWidth); knTheme->registerWidget(m_hScrollBar); setHorizontalScrollBar(m_hScrollBar); //Configure the vertical scroll bar. m_vScrollBar->setObjectName("MusicScrollBar"); m_vScrollBar->setStyle(KNSaoStyle::instance()); m_vScrollBar->hide(); knTheme->registerWidget(m_vScrollBar); connect(verticalScrollBar(), &QScrollBar::rangeChanged, [=](int min, int max) { //Update the range first. m_vScrollBar->setRange(min, max); //Check whether the scroll bar is still valid. m_vScrollBar->setVisible(min!=max); //Update scrollbar state parameters. m_vScrollBar->setPageStep(verticalScrollBar()->pageStep()); m_vScrollBar->setSingleStep(verticalScrollBar()->singleStep()); //Update the geometry. updateVerticalScrollBarGeometry(); }); connect(verticalScrollBar(), &QScrollBar::valueChanged, [=](int value) { //Block the signal. m_vScrollBar->blockSignals(true); //Reset the value. m_vScrollBar->setValue(value); //Release the block m_vScrollBar->blockSignals(false); }); connect(m_vScrollBar, &QScrollBar::valueChanged, verticalScrollBar(), &QScrollBar::setValue); //Configure the time line. m_mouseAnime->setEasingCurve(QEasingCurve::OutCubic); m_mouseAnime->setUpdateInterval(10); //Link the time line. connect(m_mouseAnime, &QTimeLine::frameChanged, this, &KNMusicTreeViewBase::onActionMouseInOut); //Generate the music tree view animation header. KNMusicTreeViewHeader *header=new KNMusicTreeViewHeader(this); //Link the reqirement. connect(header, &KNMusicTreeViewHeader::requireResizeColumnToContents, this, &KNMusicTreeViewBase::resizeColumnToContents); //Set the header view. setHeader(header); //Set the rating delegate for Rating and AlbumRating row. setItemDelegateForColumn(Rating, new KNMusicRatingDelegate(this)); setItemDelegateForColumn(AlbumRating, new KNMusicRatingDelegate(this)); //Set the search shortcut. QAction *searchAction=new QAction(this); searchAction->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_F)); searchAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(searchAction, &QAction::triggered, [=] { //Check whether the search plugin is loaded. if(knMusicGlobal->search()) { knMusicGlobal->search()->onActionSearchShortcut(this); } }); addAction(searchAction); //Link the tree view signal and slot. connect(this, &KNMusicTreeViewBase::activated, this, &KNMusicTreeViewBase::onActionActivate); //Link with theme manager. connect(knTheme, &KNThemeManager::themeChange, this, &KNMusicTreeViewBase::onActionThemeUpdate); }
FavoritesView::FavoritesView(QWidget *parent) : QTreeWidget(parent) { setAcceptDrops(true); setDragEnabled(true); setDropIndicatorShown(true); setSelectionMode(QAbstractItemView::SingleSelection); dataStore.clear(); targetStore.clear(); this->setFont(global.getGuiFont(font())); filterPosition = -1; maxCount = 0; // Highest count of any notebook. Used in calculating column width // setup options this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setSelectionBehavior(QAbstractItemView::SelectRows); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setDragDropMode(QAbstractItemView::InternalMove); this->setRootIsDecorated(true); this->setSortingEnabled(true); this->header()->setVisible(false); this->setStyleSheet("QTreeView {border-image:none; image:none;} "); root = new FavoritesViewItem(0); root->setData(NAME_POSITION, Qt::UserRole, "root"); root->setData(NAME_POSITION, Qt::DisplayRole, tr("Shortcuts")); QFont rootFont = root->font(NAME_POSITION); rootFont.setBold(true); root->setFont(NAME_POSITION, rootFont); root->setIcon(NAME_POSITION, global.getIconResource(":favoritesIcon")); root->setRootColor(false); expandedImage = new QImage(":expandedIcon"); collapsedImage = new QImage(":collapsedIcon"); this->setAcceptDrops(true); this->setItemDelegate(new FavoritesViewDelegate()); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); this->setFrameShape(QFrame::NoFrame); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setMinimumHeight(1); this->addTopLevelItem(root); this->rebuildFavoritesTreeNeeded = true; this->loadData(); context.addSeparator(); deleteAction = context.addAction(tr("Remove from shortcuts")); deleteAction->setShortcut(QKeySequence(Qt::Key_Delete)); deleteShortcut = new QShortcut(this); deleteShortcut->setKey(QKeySequence(Qt::Key_Delete)); deleteShortcut->setContext(Qt::WidgetShortcut); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested())); connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection())); connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested())); root->setExpanded(true); resetSize(); }
LibraryTreeWidget::LibraryTreeWidget(QWidget *parent) : QTreeWidget(parent) { setSelectionMode(QAbstractItemView::ExtendedSelection); setDragEnabled(true); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::InternalMove); invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled); setHeaderHidden(true); setEditTriggers(QAbstractItemView::EditKeyPressed | QAbstractItemView::SelectedClicked); addNewFileAction_ = new QAction(tr("Add New File..."), this); connect(addNewFileAction_, SIGNAL(triggered()), this, SLOT(addNewFile())); importToLibraryAction_ = new QAction(tr("Add Existing Files..."), this); connect(importToLibraryAction_, SIGNAL(triggered()), this, SLOT(importToLibrary())); // newFontAction_ = new QAction(tr("New Font..."), this); // connect(newFontAction_, SIGNAL(triggered()), this, SLOT(newFont())); newFolderAction_ = new QAction(tr("New Folder"), this); connect(newFolderAction_, SIGNAL(triggered()), this, SLOT(newFolder())); removeAction_ = new QAction(tr("Remove"), this); connect(removeAction_, SIGNAL(triggered()), this, SLOT(remove())); renameAction_ = new QAction(tr("Rename"), this); //renameAction_->setShortcut(Qt::Key_F2); connect(renameAction_, SIGNAL(triggered()), this, SLOT(rename())); sortAction_ = new QAction(tr("Sort"), this); connect(sortAction_, SIGNAL(triggered()), this, SLOT(sort())); codeDependenciesAction_ = new QAction(tr("Code Dependencies..."), this); connect(codeDependenciesAction_, SIGNAL(triggered()), this, SLOT(codeDependencies())); insertIntoDocumentAction_ = new QAction(tr("Insert Into Document"), this); connect(insertIntoDocumentAction_, SIGNAL(triggered()), this, SLOT(insertIntoDocument())); projectPropertiesAction_ = new QAction(tr("Properties..."), this); connect(projectPropertiesAction_, SIGNAL(triggered()), this, SLOT(projectProperties())); automaticDownsizingAction_ = new QAction(tr("Automatic Downsizing"), this); automaticDownsizingAction_->setCheckable(true); connect(automaticDownsizingAction_, SIGNAL(triggered(bool)), this, SLOT(automaticDownsizing(bool))); excludeFromExecutionAction_ = new QAction(tr("Exclude from Execution"), this); excludeFromExecutionAction_->setCheckable(true); connect(excludeFromExecutionAction_, SIGNAL(triggered(bool)), this, SLOT(excludeFromExecution(bool))); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested (const QPoint&)), this, SLOT (onCustomContextMenuRequested(const QPoint&))); connect(this, SIGNAL(itemDoubleClicked (QTreeWidgetItem*, int)), this, SLOT (onItemDoubleClicked(QTreeWidgetItem*, int))); connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT (onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); isModifed_ = false; xmlString_ = toXml().toString(); QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(checkModification())); timer->start(500); }