KateCompletionTree::KateCompletionTree(KateCompletionWidget *parent) : ExpandingTree(parent) { m_scrollingEnabled = true; header()->hide(); setRootIsDecorated(false); setIndentation(0); setFrameStyle(QFrame::NoFrame); setAllColumnsShowFocus(true); setAlternatingRowColors(true); //We need ScrollPerItem, because ScrollPerPixel is too slow with a very large competion-list(see KDevelop). setVerticalScrollMode(QAbstractItemView::ScrollPerItem); m_resizeTimer = new QTimer(this); m_resizeTimer->setSingleShot(true); connect(m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeColumnsSlot())); // Provide custom highlighting to completion entries setItemDelegate(new KateCompletionDelegate(widget()->model(), widget())); // make sure we adapt to size changes when the model got reset // this is important for delayed creation of groups, without this // the first column would never get resized to the correct size connect(widget()->model(), &QAbstractItemModel::modelReset, this, &KateCompletionTree::scheduleUpdate); // Prevent user from expanding / collapsing with the mouse setItemsExpandable(false); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); }
//! [init part1] void FreezeTableWidget::init() { frozenTableView->setModel(model()); frozenTableView->setFocusPolicy(Qt::NoFocus); frozenTableView->verticalHeader()->hide(); frozenTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed); viewport()->stackUnder(frozenTableView); //! [init part1] //! [init part2] frozenTableView->setStyleSheet("QTableView { border: none;" "background-color: #8EDE21;" "selection-background-color: #999}"); //for demo purposes frozenTableView->setSelectionModel(selectionModel()); for(int col=1; col<model()->columnCount(); col++) frozenTableView->setColumnHidden(col, true); frozenTableView->setColumnWidth(0, columnWidth(0) ); frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); frozenTableView->show(); updateFrozenTableGeometry(); setHorizontalScrollMode(ScrollPerPixel); setVerticalScrollMode(ScrollPerPixel); frozenTableView->setVerticalScrollMode(ScrollPerPixel); }
void FreezeTableWidget::init() { frozenTableView->setFocusPolicy(Qt::NoFocus); frozenTableView->verticalHeader()->hide(); frozenTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); viewport()->stackUnder(frozenTableView); frozenTableView->setSelectionModel(selectionModel()); frozenTableView->setColumnWidth(0, columnWidth(0)); frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); frozenTableView->show(); updateFrozenTableGeometry(); for (int col = 1; col < model()->columnCount(); ++col) frozenTableView->setColumnHidden(col, true); //should hide more when inserted setHorizontalScrollMode(ScrollPerPixel); setVerticalScrollMode(ScrollPerPixel); frozenTableView->setVerticalScrollMode(ScrollPerPixel); // frozenTableView->setEditTriggers(QTableView::DoubleClicked|QTableView::AnyKeyPressed); }
game_list_grid::game_list_grid(const QSize& icon_size, const QColor& icon_color, const qreal& margin_factor, const qreal& text_factor, const bool& showText) : game_list(), m_icon_size(icon_size), m_icon_color(icon_color), m_margin_factor(margin_factor), m_text_factor(text_factor), m_text_enabled(showText) { QSize item_size; if (m_text_enabled) { item_size = m_icon_size + QSize(m_icon_size.width() * m_margin_factor * 2, m_icon_size.height() * m_margin_factor * (m_text_factor + 1)); } else { item_size = m_icon_size + m_icon_size * m_margin_factor * 2; } // font by stylesheet QLabel font_dummy; font_dummy.setObjectName("gamegrid_font"); font_dummy.ensurePolished(); QFont font = font_dummy.font(); QColor font_color = font_dummy.palette().color(QPalette::Foreground); grid_item_delegate = new game_list_grid_delegate(item_size, m_margin_factor, m_text_factor, font, font_color, this); setItemDelegate(grid_item_delegate); setSelectionBehavior(QAbstractItemView::SelectItems); setSelectionMode(QAbstractItemView::SingleSelection); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setContextMenuPolicy(Qt::CustomContextMenu); verticalHeader()->setVisible(false); horizontalHeader()->setVisible(false); setShowGrid(false); }
ScrobblesListWidget::ScrobblesListWidget( QWidget* parent ) :QListWidget( parent ), m_trackItem( 0 ) { setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); #ifdef Q_OS_MAC connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) ); #endif setAttribute( Qt::WA_MacNoClickThrough ); setAttribute( Qt::WA_MacShowFocusRect, false ); setUniformItemSizes( false ); setSortingEnabled( false ); setSelectionMode( QAbstractItemView::NoSelection ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); connect( qApp, SIGNAL( sessionChanged( unicorn::Session* )), SLOT(onSessionChanged( unicorn::Session* ))); connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(trackStarted(Track,Track)), SLOT(onTrackStarted(Track,Track))); connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused())); connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed())); connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped())); onSessionChanged( lastfm::ws::Username ); }
TransfersView::TransfersView(QWidget * parent) : QTreeView(parent) { // setItemsExpandable(false); setRootIsDecorated(false); setAnimated(true); setAllColumnsShowFocus(true); header()->setDefaultAlignment(Qt::AlignCenter); header()->setMinimumSectionSize(80); header()->setContextMenuPolicy(Qt::CustomContextMenu); header()->setClickable(true); m_headerMenu = new KMenu(header()); setSelectionMode(QAbstractItemView::ExtendedSelection); setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setEditTriggers(QAbstractItemView::NoEditTriggers); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); connect(header(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotShowHeaderMenu(QPoint))); connect(header(), SIGNAL(sectionCountChanged(int,int)), this, SLOT(populateHeaderActions())); connect(header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(slotSectionMoved(int,int,int))); connect(header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(slotSaveHeader())); connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotItemActivated(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(slotItemCollapsed(QModelIndex))); connect(KGet::model(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(closeExpandableDetails(QModelIndex,int,int))); }
ServiceCollectionTreeView::ServiceCollectionTreeView( QWidget *parent ) : CollectionTreeView( parent ) , m_playableTracks( true ) //per default, act just like a normal CollectionTreeView { setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); // Enable smooth scrolling setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); // Enable smooth scrolling }
QCollapsibleToolbox::QCollapsibleToolbox(QWidget * parent =0) : QTreeWidget(parent) { setRootIsDecorated(false); setIndentation(0); viewport()->setBackgroundRole(QPalette::Background); setBackgroundRole(QPalette::Window); setAutoFillBackground(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); }
KNMusicTreeViewBase::KNMusicTreeViewBase(QWidget *parent) : QTreeView(parent) { //Set properties. setAllColumnsShowFocus(true); setAlternatingRowColors(true); setContentsMargins(0,0,0,0); setDragDropMode(QAbstractItemView::DragOnly); setDropIndicatorShown(true); setFrameShape(QFrame::NoFrame); setIndentation(0); setMouseTracking(true); setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); setUniformRowHeights(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); //Set scroll bar properties. horizontalScrollBar()->setSingleStep(5); horizontalScrollBar()->setPageStep(5); verticalScrollBar()->setSingleStep(4); verticalScrollBar()->setPageStep(4); //Using frame updater to set palette. onActionMouseInOut(0); //Set animation header. KNMusicTreeViewHeader *header=new KNMusicTreeViewHeader(this); connect(header, &KNMusicTreeViewHeader::requireResizeColumnToContents, this, &KNMusicTreeViewBase::resizeColumnToContents); setHeader(header); //Set delegate. setItemDelegateForColumn(Rating, new KNMusicRatingDelegate(this)); setItemDelegateForColumn(AlbumRating, new KNMusicRatingDelegate(this)); //Initial menu connections. m_soloConnections=new KNConnectionHandler(this); m_multiConnections=new KNConnectionHandler(this); //Initial mouse sense animation. m_mouseIn=new QTimeLine(200, this); configureTimeLine(m_mouseIn); m_mouseIn->setEndFrame(m_maxOpacity); m_mouseOut=new QTimeLine(200, this); configureTimeLine(m_mouseOut); m_mouseOut->setEndFrame(0); //Initial reacts. connect(this, &KNMusicTreeViewBase::activated, this, &KNMusicTreeViewBase::playIndex); //Initial actions. initialActions(); }
CodeCompleterListView::CodeCompleterListView(QWidget *parent) : QListView(parent) { setVerticalScrollMode(QAbstractItemView::ScrollPerItem); m_infoFrame = new CodeCompleterInfo(this); m_infoTimer.setInterval(100); m_infoTimer.setSingleShot(true); connect(&m_infoTimer, SIGNAL(timeout()), SLOT(maybeShowInfoTip())); }
PlaylistView::PlaylistView(QWidget *parent) : QTreeView(parent), style_(new PlaylistProxyStyle(style())), playlist_(NULL), header_(new PlaylistHeader(Qt::Horizontal, this)), setting_initial_header_layout_(false), upgrading_from_qheaderview_(false), read_only_settings_(true), glow_enabled_(true), currently_glowing_(false), glow_intensity_step_(0), rating_delegate_(NULL), inhibit_autoscroll_timer_(new QTimer(this)), inhibit_autoscroll_(false), currently_autoscrolling_(false), row_height_(-1), currenttrack_play_(":currenttrack_play.png"), currenttrack_pause_(":currenttrack_pause.png"), cached_current_row_row_(-1), drop_indicator_row_(-1), drag_over_(false), dynamic_controls_(new DynamicPlaylistControls(this)) { setHeader(header_); header_->setMovable(true); setStyle(style_); setMouseTracking(true); connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(SaveGeometry())); connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(SaveGeometry())); connect(header_, SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), SLOT(SaveGeometry())); connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(SaveGeometry())); connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(InvalidateCachedCurrentPixmap())); connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(InvalidateCachedCurrentPixmap())); connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(InvalidateCachedCurrentPixmap())); connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(SaveSettings())); connect(header_, SIGNAL(ColumnAlignmentChanged()), SLOT(SaveSettings())); connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(StretchChanged(bool))); connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut())); inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000); inhibit_autoscroll_timer_->setSingleShot(true); connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout())); horizontalScrollBar()->installEventFilter(this); verticalScrollBar()->installEventFilter(this); setAlternatingRowColors(true); setAttribute(Qt::WA_MacShowFocusRect, false); dynamic_controls_->hide(); #ifdef Q_OS_DARWIN setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); #endif }
IconPickerDialog::IconPickerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::IconPickerDialog) { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); setWindowModality(Qt::WindowModal); auto contentsWidget = ui->iconView; contentsWidget->setViewMode(QListView::IconMode); contentsWidget->setFlow(QListView::LeftToRight); contentsWidget->setIconSize(QSize(48, 48)); contentsWidget->setMovement(QListView::Static); contentsWidget->setResizeMode(QListView::Adjust); contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); contentsWidget->setSpacing(5); contentsWidget->setWordWrap(false); contentsWidget->setWrapping(true); contentsWidget->setUniformItemSizes(true); contentsWidget->setTextElideMode(Qt::ElideRight); contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); contentsWidget->setItemDelegate(new ListViewDelegate()); //contentsWidget->setAcceptDrops(true); contentsWidget->setDropIndicatorShown(true); contentsWidget->viewport()->setAcceptDrops(true); contentsWidget->setDragDropMode(QAbstractItemView::DropOnly); contentsWidget->setDefaultDropAction(Qt::CopyAction); contentsWidget->installEventFilter(this); contentsWidget->setModel(MMC->icons().get()); auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole); auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole); connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon())); connect(buttonRemove,SIGNAL(clicked(bool)),SLOT(removeSelectedIcon())); connect ( contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex)) ); connect ( contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged(QItemSelection,QItemSelection)) ); }
CategorizedTreeWidget::CategorizedTreeWidget(QWidget *parent) : QTreeWidget(parent) { setItemDelegate(new KateColorTreeDelegate(this)); setHeaderHidden(true); setRootIsDecorated(false); setIndentation(25); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerItem); }
JobHistoryView::JobHistoryView( QWidget * parent ) : RecordTreeView ( parent ) , mModel( 0 ) { setAlternatingRowColors(false); setVerticalScrollMode( ScrollPerPixel ); setHorizontalScrollMode( ScrollPerPixel ); options.mErrorColors->apply(this); }
bool TreeViewTouch::event(QEvent *event) { #if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) { #else if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) { #endif // Register that we may be scrolling, set the scroll mode to scroll-per-pixel // and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel _touchScrollInProgress = true; setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); return true; } if (event->type() == QEvent::TouchUpdate && _touchScrollInProgress) { QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0); if (!_firstTouchUpdateHappened) { // After the first movement of a Touch-Point, calculate the distance in both axis // and if the point moved more horizontally abort scroll. double dx = qAbs(p.lastPos().x() - p.pos().x()); double dy = qAbs(p.lastPos().y() - p.pos().y()); if (dx > dy) { _touchScrollInProgress = false; } _firstTouchUpdateHappened = true; } // Apply touch movement to scrollbar verticalScrollBar()->setValue(verticalScrollBar()->value() - (p.pos().y() - p.lastPos().y())); return true; } #if QT_VERSION >= 0x050000 if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) { #else if (event->type() == QEvent::TouchEnd) { #endif // End scroll and reset variables _touchScrollInProgress = false; _firstTouchUpdateHappened = false; return true; } return QTreeView::event(event); } void TreeViewTouch::mousePressEvent(QMouseEvent *event) { if (!_touchScrollInProgress) QTreeView::mousePressEvent(event); } void TreeViewTouch::mouseMoveEvent(QMouseEvent *event) { if (!_touchScrollInProgress) QTreeView::mouseMoveEvent(event); };
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FilterListWidget::FilterListWidget(QWidget* parent) : QListWidget(parent) { setAcceptDrops(false); setDragEnabled(true); setDragDropMode(QAbstractItemView::DragOnly); setAlternatingRowColors(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setUniformItemSizes(true); }
StackedDocumentTreeView::StackedDocumentTreeView( QWidget* parent ) : QTreeView( parent ), mStacker( 0 ) { setEditTriggers( QAbstractItemView::NoEditTriggers ); setAlternatingRowColors( false ); setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); setRootIsDecorated( false ); setUniformRowHeights( true ); setHeaderHidden( true ); }
ChannelView::ChannelView(QWidget *parent) : QListView(parent), showUpdated(false), sortBy(SortByName) { setItemDelegate(new ChannelItemDelegate(this)); setSelectionMode(QAbstractItemView::NoSelection); // layout setSpacing(15); setFlow(QListView::LeftToRight); setWrapping(true); setResizeMode(QListView::Adjust); setMovement(QListView::Static); setUniformItemSizes(true); // cosmetics setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setFrameShape(QFrame::NoFrame); setAttribute(Qt::WA_MacShowFocusRect, false); QPalette p = palette(); /* p.setColor(QPalette::Base, p.window().color()); p.setColor(QPalette::Text, p.windowText().color()); */ p.setColor(QPalette::Disabled, QPalette::Base, p.base().color()); p.setColor(QPalette::Disabled, QPalette::Text, p.text().color()); setPalette(p); verticalScrollBar()->setPageStep(3); verticalScrollBar()->setSingleStep(1); setMouseTracking(true); connect(this, SIGNAL(clicked(const QModelIndex &)), SLOT(itemActivated(const QModelIndex &))); connect(this, SIGNAL(entered(const QModelIndex &)), SLOT(itemEntered(const QModelIndex &))); channelsModel = new ChannelModel(this); setModel(channelsModel); connect(this, SIGNAL(viewportEntered()), channelsModel, SLOT(clearHover())); setupActions(); connect(ChannelAggregator::instance(), SIGNAL(channelChanged(YTChannel*)), channelsModel, SLOT(updateChannel(YTChannel*))); connect(ChannelAggregator::instance(), SIGNAL(unwatchedCountChanged(int)), SLOT(unwatchedCountChanged(int))); unwatchedCountChanged(ChannelAggregator::instance()->getUnwatchedCount()); }
DBView::DBView(QWidget * parent) : QTableView(parent) { QTableView::setItemDelegate(new DBDelegate(this)); setWordWrap(true); setTextElideMode(Qt::ElideRight); CheckboxHeader* header = new CheckboxHeader(Qt::Vertical, this); setVerticalHeader(header); horizontalHeader()->setMinimumSectionSize(fontInfo().pixelSize()+2); //13=11+2 for margins horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); }
QmlConsoleView::QmlConsoleView(QWidget *parent) : Utils::TreeView(parent) { setFrameStyle(QFrame::NoFrame); setHeaderHidden(true); setRootIsDecorated(false); setUniformRowHeights(true); setEditTriggers(QAbstractItemView::AllEditTriggers); setStyleSheet(QLatin1String("QTreeView::branch:has-siblings:!adjoins-item {" "border-image: none;" "image: none; }" "QTreeView::branch:has-siblings:adjoins-item {" "border-image: none;" "image: none; }" "QTreeView::branch:!has-children:!has-siblings:adjoins-item {" "border-image: none;" "image: none; }" "QTreeView::branch:has-children:!has-siblings:closed," "QTreeView::branch:closed:has-children:has-siblings {" "border-image: none;" "image: none; }" "QTreeView::branch:open:has-children:!has-siblings," "QTreeView::branch:open:has-children:has-siblings {" "border-image: none;" "image: none; }")); QString baseName = QApplication::style()->objectName(); if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost() && baseName == QLatin1String("windows")) { // Sometimes we get the standard windows 95 style as a fallback if (QStyleFactory::keys().contains(QLatin1String("Fusion"))) { baseName = QLatin1String("fusion"); // Qt5 } else { // Qt4 // e.g. if we are running on a KDE4 desktop QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION"); if (desktopEnvironment == "kde") baseName = QLatin1String("plastique"); else baseName = QLatin1String("cleanlooks"); } } QmlConsoleViewStyle *style = new QmlConsoleViewStyle(baseName); setStyle(style); style->setParent(this); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); horizontalScrollBar()->setSingleStep(20); verticalScrollBar()->setSingleStep(20); connect(this, SIGNAL(activated(QModelIndex)), SLOT(onRowActivated(QModelIndex))); }
UIInformationView::UIInformationView(QWidget *pParent) : QListView(pParent) { /* Create a dummy textEdit for copying rich-text as, * manual copying to clipboard is not working: */ m_pTextEdit = new QTextEdit(this); /* Hide textedit: */ m_pTextEdit->setVisible(false); /* Set selection mode: */ setSelectionMode(QAbstractItemView::ExtendedSelection); /* Set scrolling mode to per pixel: */ setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); }
ScTreeWidget::ScTreeWidget(QWidget* pa) : QTreeWidget(pa) { setFocusPolicy(Qt::NoFocus); setColumnCount(1); setItemDelegate(new ScTreeWidgetDelegate(this, this)); setRootIsDecorated(false); setIndentation(0); header()->hide(); header()->setSectionResizeMode(QHeaderView::Stretch); viewport()->setBackgroundRole(QPalette::Window); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); m_toolbox_mode = false; connect(this, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(handleMousePress(QTreeWidgetItem*))); }
KNMusicCategoryList::KNMusicCategoryList(QWidget *parent) : QListView(parent) { //Set viewport properties. viewport()->setContentsMargins(0,0,0,0); viewport()->installEventFilter(this); //Set listview properties. setAutoFillBackground(true); setContentsMargins(0,0,0,0); setFrameShape(QFrame::NoFrame); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setIconSize(QSize(40, 40)); setLineWidth(0); setLayoutMode(QListView::Batched); setMinimumWidth(200); setSelectionMode(QAbstractItemView::SingleSelection); setSpacing(2); setUniformItemSizes(true); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); //Set scroll bar properties. verticalScrollBar()->setSingleStep(8); verticalScrollBar()->setPageStep(8); //Set palette. m_backgroundColor=QColor(m_minGrey, m_minGrey, m_minGrey); m_palette=palette(); m_palette.setColor(QPalette::Base, m_backgroundColor); m_palette.setColor(QPalette::Window, QColor(0x30, 0x30, 0x30)); m_palette.setColor(QPalette::Button, QColor(0x30, 0x30, 0x30)); m_palette.setColor(QPalette::Text, QColor(0x8f, 0x8f, 0x8f, 0xaf)); m_palette.setColor(QPalette::Highlight, QColor(0x60, 0x60, 0x60)); m_palette.setColor(QPalette::HighlightedText, QColor(0xf7, 0xcf, 0x3d)); setPalette(m_palette); //Set mouse sensative animation time line. m_mouseIn=new QTimeLine(200, this); m_mouseIn->setUpdateInterval(5); m_mouseIn->setEndFrame(0x50); connect(m_mouseIn, &QTimeLine::frameChanged, this, &KNMusicCategoryList::changeBackground); m_mouseOut=new QTimeLine(200, this); m_mouseOut->setUpdateInterval(5); m_mouseOut->setEndFrame(m_minGrey); connect(m_mouseOut, &QTimeLine::frameChanged, this, &KNMusicCategoryList::changeBackground); }
ToolBarList::ToolBarList(QWidget* parent) : QListWidget(parent) { m_toolbar = new QToolBar(this); m_toolbar->setFloatable(false); m_toolbar->setMovable(false); m_toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); m_toolbar->setStyleSheet("QToolBar { border-top: 1px solid palette(mid); }"); m_toolbar->hide(); setContextMenuPolicy(Qt::ActionsContextMenu); setMovement(QListView::Static); setResizeMode(QListView::Adjust); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); }
TrackPane::TrackPane(int cs, QWidget *parent) : QTableView(parent) { setBackgroundRole(QPalette::Light); setFocusPolicy(Qt::StrongFocus); horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); horizontalHeader()->setDefaultSectionSize(cs); verticalHeader()->setDefaultSectionSize(cs); setVerticalScrollMode(ScrollPerPixel); setHorizontalScrollMode(ScrollPerPixel); setItemDelegate( new TrackPaneDelegate( this ) ); }
ListView::ListView(QWidget* parent) : QListView(parent) { setFocusPolicy(Qt::NoFocus); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #ifdef Q_OS_MAC setVerticalScrollMode(ScrollPerPixel); #endif setItemDelegate(new ListDelegate(this)); d.model = new IrcUserModel(this); d.model->setSortMethod(Irc::SortByTitle); setModel(d.model); connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex))); }
NShortcutEditorWidget::NShortcutEditorWidget(QWidget *parent) : QTableWidget(parent) { setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setColumnCount(4); setHorizontalHeaderLabels(QStringList() << tr("Action") << tr("Description") << tr("Shortcut") << tr("Global Shortcut")); verticalHeader()->setVisible(false); setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionMode(QAbstractItemView::SingleSelection); setStyleSheet("QTableView::item:disabled { color: black; }"); m_init = false; }
MusicListView::MusicListView(QWidget *parent) : ListView(parent), d_ptr(new MusicListViewPrivate(this)) { Q_D(MusicListView); DThemeManager::instance()->registerWidget(this); setObjectName("MusicListView"); d->model = new MusiclistModel(0, 1, this); setModel(d->model); d->delegate = new MusicItemDelegate; setItemDelegate(d->delegate); setDragEnabled(true); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); setDragDropOverwriteMode(false); setVerticalScrollMode(QAbstractItemView::ScrollPerItem); setHorizontalScrollMode(QAbstractItemView::ScrollPerItem); setDefaultDropAction(Qt::MoveAction); setDragDropMode(QAbstractItemView::InternalMove); setMovement(QListView::Free); setSelectionMode(QListView::ExtendedSelection); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionBehavior(QAbstractItemView::SelectRows); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &MusicListView::customContextMenuRequested, this, &MusicListView::requestCustomContextMenu); connect(this, &MusicListView::doubleClicked, this, [ = ](const QModelIndex & index) { MetaPtr meta = d->model->meta(index); Q_EMIT playMedia(meta); }); // For debug // connect(selectionModel(), &QItemSelectionModel::selectionChanged, // this, [ = ](const QItemSelection & /*selected*/, const QItemSelection & deselected) { // if (!deselected.isEmpty()) { // qDebug() << "cancel" << deselected; // } // }); }
LocationCompleterView::LocationCompleterView() : QListView(0) , m_ignoreNextMouseMove(false) { setWindowFlags(Qt::Popup); setUniformItemSizes(true); setEditTriggers(QAbstractItemView::NoEditTriggers); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::SingleSelection); setMouseTracking(true); installEventFilter(this); }
void TracksView::initMainView() { horizontalHeader()->setSectionsMovable(false); verticalHeader()->setSectionsMovable(true); setHorizontalScrollMode(ScrollPerPixel); setVerticalScrollMode(ScrollPerPixel); setSelectionBehavior(SelectItems); setSelectionMode(SingleSelection); setAutoScroll(false); setFocusPolicy(Qt::StrongFocus); horizontalScrollBar()->setFocusPolicy(Qt::NoFocus); verticalScrollBar()->setFocusPolicy(Qt::NoFocus); viewport()->stackUnder(_frozenHTableView); }