void MusicListView::startDrag(Qt::DropActions supportedActions) { Q_D(MusicListView); MetaPtrList list; for (auto index : selectionModel()->selectedIndexes()) { list << d->model->meta(index); } setAutoScroll(false); ListView::startDrag(supportedActions); setAutoScroll(true); QMap<QString, int> hashIndexs; for (int i = 0; i < d->model->rowCount(); ++i) { auto index = d->model->index(i, 0); auto hash = d->model->data(index).toString(); Q_ASSERT(!hash.isEmpty()); hashIndexs.insert(hash, i); } d->model->playlist()->saveSort(hashIndexs); Q_EMIT customSort(); QItemSelection selection; for (auto meta : list) { if (!meta.isNull()) { auto index = this->findIndex(meta); selection.append(QItemSelectionRange(index)); } } if (!selection.isEmpty()) { selectionModel()->select(selection, QItemSelectionModel::Select); } }
MyListWidget::MyListWidget(QWidget* parent) : QListWidget(parent) { m_hoveredIndex =QPersistentModelIndex(); m_showHotkey=false; m_arrowHover= false; setAttribute(Qt::WA_AlwaysShowToolTips); setAlternatingRowColors(true); setAutoScroll(true); QRect r = geometry(); setAutoScrollMargin(r.height()/3); connect(this, SIGNAL(listItemAction(QString , CatItem )), (QObject*)gMainWidget, // SLOT(operateOnItem(QString , CatItem ))); connect(this, SIGNAL(showOptionsMenu(QString, QPoint)), (QObject*)gMainWidget, SLOT(listMenuEvent(QString, QPoint)), Qt::QueuedConnection); setMouseTracking(true); m_hoveStart = QTime::currentTime(); m_hovered= false; }
HierarchyTreeControl::HierarchyTreeControl(QWidget *parent) : QTreeWidget(parent) { setAcceptDrops(true); setAutoScroll(true); setDropIndicatorShown(true); }
//---------------------------------------------------------------------------------------- OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, QStringList initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) { mSelectedItems = initialSelection; mRecycleBinParent = NULL; setColumnCount(1); setHeaderHidden(true); setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionBehavior(QAbstractItemView::SelectItems); setContextMenuPolicy(Qt::CustomContextMenu); setDragDropOverwriteMode(false); setAutoScroll(true); if(capabilities & CAP_ALLOW_DROPS) setDragDropMode(QAbstractItemView::DragDrop); mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File); mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile(); mFile->addTrigger(this, OFS::_OfsBase::CLBK_CREATE, &triggerCallback); mFile->addTrigger(this, OFS::_OfsBase::CLBK_DELETE, &triggerCallback); refreshWidget(); mAddFilesThread = new AddFilesThread(); mExtractorThread = new ExtractorThread(); connect(mAddFilesThread, SIGNAL(finished()), this, SLOT(threadFinished())); connect(mExtractorThread, SIGNAL(finished()), this, SLOT(threadFinished())); }
/************************************************************************** Constructor for plr_widget **************************************************************************/ plr_widget::plr_widget(plr_report *pr): QTreeView() { plr = pr; other_player = NULL; pid = new plr_item_delegate(this); setItemDelegate(pid); list_model = new plr_model(this); filter_model = new QSortFilterProxyModel(); filter_model->setDynamicSortFilter(true); filter_model->setSourceModel(list_model); filter_model->setFilterRole(Qt::DisplayRole); setModel(filter_model); setRootIsDecorated(false); setAllColumnsShowFocus(true); setSortingEnabled(true); setSelectionMode(QAbstractItemView::SingleSelection); setItemsExpandable(false); setAutoScroll(true); header()->setContextMenuPolicy(Qt::CustomContextMenu); hide_columns(); connect(header(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(display_header_menu(const QPoint &))); connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), SLOT(nation_selected(const QItemSelection &, const QItemSelection &))); }
DirTreeView::DirTreeView(QWidget *parent) : QTreeView(parent) , popupMenu(this) { setAcceptDrops(true); setAutoScroll(true); setAutoExpandDelay(1000); }
LocalsView::LocalsView(QWidget *parent) : QTreeWidget(parent), m_allAdded(true) { QStringList headers; headers << i18n("Symbol"); headers << i18n("Value"); setHeaderLabels(headers); setAutoScroll(false); }
/** Initializes the view. */ void CBookmarkIndex::initView() { //qDebug("CBookmarkIndex::initView"); header()->hide(); setFocusPolicy(Qt::WheelFocus); //d'n'd related settings setDragEnabled( true ); setAcceptDrops( true ); setDragDropMode(QAbstractItemView::DragDrop); viewport()->setAcceptDrops(true); setAutoScroll(true); setAutoExpandDelay(800); setItemsExpandable(true); setRootIsDecorated(true); setAllColumnsShowFocus(true); setSelectionMode(QAbstractItemView::ExtendedSelection); //setup the popup menu m_popup = new QMenu(viewport()); m_popup->setTitle(tr("Bookmarks")); m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this); m_actions.changeFolder = newQAction(tr("Rename folder"),CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this); m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this); m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this); m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this); m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this); m_actions.deleteEntries = newQAction(tr("Remove selected items..."), CResMgr::mainIndex::deleteItems::icon, 0, this, SLOT(deleteEntries()), this); //fill the popup menu itself m_popup->addAction(m_actions.newFolder); m_popup->addAction(m_actions.changeFolder); QAction* separator = new QAction(this); separator->setSeparator(true); m_popup->addAction(separator); m_popup->addAction(m_actions.changeBookmark); m_popup->addAction(m_actions.importBookmarks); m_popup->addAction(m_actions.exportBookmarks); m_popup->addAction(m_actions.printBookmarks); separator = new QAction(this); separator->setSeparator(true); m_popup->addAction(separator); m_popup->addAction(m_actions.deleteEntries); //qDebug("CBookmarkIndex::initView end"); }
void MusicListView::onMusicListRemoved(const MetaPtrList metalist) { Q_D(MusicListView); setAutoScroll(false); for (auto meta : metalist) { if (meta.isNull()) { continue; } for (int i = 0; i < d->model->rowCount(); ++i) { auto index = d->model->index(i, 0); auto itemHash = d->model->data(index).toString(); if (itemHash == meta->hash) { d->model->removeRow(i); } } } updateScrollbar(); setAutoScroll(true); }
SearchEditorTreeView::SearchEditorTreeView(QWidget* parent) : QTreeView(parent) { setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::InternalMove); setAutoScroll(true); setSelectionMode(QAbstractItemView::ExtendedSelection); setSelectionBehavior(QAbstractItemView::SelectRows); setSortingEnabled(false); setTabKeyNavigation(true); }
dragTarget::dragTarget (dragSource *source, QWidget *parent ) : QTreeWidget ( parent ) { //let's initialize the dropIndicator indicator = new QWidget(viewport()); indicator -> setAutoFillBackground(true); QPalette pale = indicator -> palette(); pale.setColor(QPalette::Base, Qt::blue); indicator -> setPalette(pale); hideIndicator(); //let's initialize some pointers... sourceView = source; scrollUpTimer = new QTimer(); scrollDownTimer = new QTimer(); indicatorToRestore = NULL; //setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); //...and some list settings subLevel = false; setAcceptDrops ( true ); setDragEnabled ( true ); setAutoScroll(true); setDragDropMode ( QAbstractItemView::DragDrop ); setColumnCount ( 4 ); setHeaderLabels ( QStringList() <<tr ( "Item" ) <<tr ( "Path" ) <<tr ( "MimeType" ) <<tr ( "Size" ) ); header() -> moveSection ( 3,1 ); setColumnWidth ( 0,170 ); setDropIndicatorShown ( true ); //setAnimated ( true ); newFolder = new QAction ( tr ( "New Folder" ), this ); newFolder -> setIcon ( KIcon ( "folder-new" ) ); //newFolder -> setShortcut(QKeySequence(tr("Ctrl+A"))); //this -> addAction(newFolder); delItem = new QAction ( tr ( "Delete Item" ), this ); delItem -> setIcon ( KIcon ( "edit-delete" ) ); //delItem -> setShortcut(QKeySequence(tr("Del"))); //TODO check! //this -> addAction(delItem); //this-> setContextMenuPolicy(Qt::DefaultContextMenu); //se non imposto defaultcontextmenu non posso reimplementare la gestione del contextmenu //creo il menu menu = new QMenu ( tr ( "Options" ),this ); menu -> addAction ( newFolder ); menu -> addAction ( delItem ); connect ( newFolder, SIGNAL ( triggered() ), this, SLOT ( createNewFolder() ) ); connect ( delItem, SIGNAL ( triggered() ), this, SLOT ( deleteItem() ) ); delItem -> setEnabled ( false ); setItemsExpandable ( true ); setSelectionMode(QAbstractItemView::ExtendedSelection); //setSelectionMode(QAbstractItemView::ExtendedSelection); //inizialmente viene gestita solo la selezione singola }
cMaterialItemView::cMaterialItemView(QWidget *parent) : QAbstractItemView(parent) { updateNameHeight(); iconMargin = 10; if (horizontalScrollBar()->isVisible()) viewHeight = cMaterialWidget::previewHeight + horizontalScrollBar()->height() + iconMargin * 2 + maxNameHeight; else viewHeight = cMaterialWidget::previewHeight + iconMargin * 2 + maxNameHeight; setMinimumHeight(viewHeight); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setAutoScroll(true); }
AlbumTreeView::AlbumTreeView(QWidget* const parent, Flags flags) : AbstractCheckableAlbumTreeView(parent, flags) { setDragEnabled(true); setAcceptDrops(true); setAutoScroll(false); // Workaround for bug 400960 setRootIsDecorated(false); setDropIndicatorShown(false); setAutoExpandDelay(AUTOEXPANDDELAY); if (flags & CreateDefaultModel) { setAlbumModel(new AlbumModel(AlbumModel::IncludeRootAlbum, this)); } }
bool ScrollText::init() { bool ret = true; if (Node::init()) { auto pMask = Sprite::create("switch-mask.png"); _mLable = Label::createWithSystemFont("Title", "Arial-BoldMT", 40); _mLable->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); IF_RETURN_FALSE(!initClipper(pMask,_mLable)); scheduleUpdate(); setAutoScroll(true); return ret; } return ret; }
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); }
WLibrarySidebar::WLibrarySidebar(QWidget* parent) : QTreeView(parent), WBaseWidget(this) { //Set some properties setHeaderHidden(true); setSelectionMode(QAbstractItemView::SingleSelection); //Drag and drop setup setDragEnabled(false); setDragDropMode(QAbstractItemView::DragDrop); setDropIndicatorShown(true); setAcceptDrops(true); setAutoScroll(true); header()->setStretchLastSection(false); header()->setResizeMode(QHeaderView::ResizeToContents); header()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); }
TransferListView::TransferListView(bool place, QWidget* _p, const QString& _name) : QTreeWidget(_p), mGroupMode(None) { mName = _name; QStringList headers; headers << tr("User") << tr("File") << tr("Status") << tr("Progress") << tr("Place") << tr("Position") << tr("Size") << tr("Speed") << tr("Time Left") << tr("Path") << QString::null; setAllColumnsShowFocus(true); setHeaderLabels(headers); setSortingEnabled ( false ); sortItems(0, Qt::AscendingOrder); setDragEnabled(true); setSelectionMode(QAbstractItemView::ExtendedSelection); setAutoScroll(false); if(! place) setColumnHidden(4, true); setColumnWidth ( 0, 100 ); setColumnWidth ( 1, 250 ); setColumnWidth ( 2, 100 ); setColumnWidth ( 3, 115 ); setColumnWidth ( 4, 50 ); setColumnWidth ( 5, 75 ); setColumnWidth ( 6, 75 ); setColumnWidth ( 7, 75 ); setColumnWidth ( 8, 95 ); setColumnWidth ( 9, 230 ); setColumnWidth ( 10, 0 ); // Define the progress bar for the progress column mProgressBar = new TransferListItemProgress(this); setItemDelegateForColumn( 3, mProgressBar ); if (museeq->settings()->value("saveTransfersLayout", false).toBool()) { QString optionName = "transfers-"+mName+"_Layout"; header()->restoreState(museeq->settings()->value(optionName).toByteArray()); } setContextMenuPolicy(Qt::CustomContextMenu); connect(museeq, SIGNAL(disconnected()), SLOT(clear())); connect(museeq, SIGNAL(closingMuseeq()), this, SLOT(onClosingMuseeq())); }
CQBrowserPane::CQBrowserPane(QWidget* parent) : QTreeView(parent) { QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); setSizePolicy(sizePolicy); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setAutoScroll(true); setEditTriggers(QAbstractItemView::NoEditTriggers); setTextElideMode(Qt::ElideNone); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setUniformRowHeights(true); setSortingEnabled(true); setHeaderHidden(true); connect(this, SIGNAL(expanded(const QModelIndex &)), this, SLOT(slotUpdateScrollBar(const QModelIndex &))); connect(this, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(slotUpdateScrollBar(const QModelIndex &))); }
//! Reads attributes of the element void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { IGUIEditBox::deserializeAttributes(in,options); setOverrideColor(in->getAttributeAsColor("OverrideColor")); enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); setMax(in->getAttributeAsInt("MaxChars")); setWordWrap(in->getAttributeAsBool("WordWrap")); setMultiLine(in->getAttributeAsBool("MultiLine")); setAutoScroll(in->getAttributeAsBool("AutoScroll")); core::stringw ch = in->getAttributeAsStringW("PasswordChar"); if (!ch.size()) setPasswordBox(in->getAttributeAsBool("PasswordBox")); else setPasswordBox(in->getAttributeAsBool("PasswordBox"), ch[0]); setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); // setOverrideFont(in->getAttributeAsFont("OverrideFont")); }
RostersView::RostersView(QWidget *AParent) : QTreeView(AParent) { FRostersModel = NULL; FPressedPos = QPoint(); FPressedIndex = QModelIndex(); FPressedLabel = AdvancedDelegateItem::NullId; header()->hide(); header()->setStretchLastSection(true); setIndentation(4); setAutoScroll(true); setDragEnabled(true); setAcceptDrops(true); setRootIsDecorated(false); setDropIndicatorShown(true); setEditTriggers(NoEditTriggers); setSelectionMode(ExtendedSelection); setSelectionBehavior(SelectRows); setContextMenuPolicy(Qt::DefaultContextMenu); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); FAdvancedItemDelegate = new AdvancedItemDelegate(this); FAdvancedItemDelegate->setVertialSpacing(1); FAdvancedItemDelegate->setHorizontalSpacing(2); FAdvancedItemDelegate->setItemsRole(RDR_LABEL_ITEMS); FAdvancedItemDelegate->setDefaultBranchItemEnabled(true); FAdvancedItemDelegate->setBlinkMode(AdvancedItemDelegate::BlinkHide); connect(FAdvancedItemDelegate,SIGNAL(updateBlinkItems()),SLOT(onUpdateBlinkLabels())); setItemDelegate(FAdvancedItemDelegate); FDragExpandTimer.setSingleShot(true); FDragExpandTimer.setInterval(500); connect(&FDragExpandTimer,SIGNAL(timeout()),SLOT(onDragExpandTimer())); }
void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) { UIWidget::onStyleApply(styleName, styleNode); for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "text") { setText(node->value()); setCursorPos(m_text.length()); } else if(node->tag() == "text-hidden") setTextHidden(node->value<bool>()); else if(node->tag() == "shift-navigation") setShiftNavigation(node->value<bool>()); else if(node->tag() == "multiline") setMultiline(node->value<bool>()); else if(node->tag() == "max-length") setMaxLength(node->value<int>()); else if(node->tag() == "editable") setEditable(node->value<bool>()); else if(node->tag() == "selectable") setSelectable(node->value<bool>()); else if(node->tag() == "selection-color") setSelectionColor(node->value<Color>()); else if(node->tag() == "selection-background-color") setSelectionBackgroundColor(node->value<Color>()); else if(node->tag() == "selection") { Point selectionRange = node->value<Point>(); setSelection(selectionRange.x, selectionRange.y); } else if(node->tag() == "cursor-visible") setCursorVisible(node->value<bool>()); else if(node->tag() == "change-cursor-image") setChangeCursorImage(node->value<bool>()); else if(node->tag() == "auto-scroll") setAutoScroll(node->value<bool>()); } }
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractScrollArea::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: pressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 1: clicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 2: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 3: activated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 4: entered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 5: viewportEntered(); break; case 6: reset(); break; case 7: setRootIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 8: doItemsLayout(); break; case 9: selectAll(); break; case 10: edit((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 11: clearSelection(); break; case 12: setCurrentIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 13: scrollToTop(); break; case 14: scrollToBottom(); break; case 15: update((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 17: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 18: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 19: selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break; case 20: currentChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 21: updateEditorData(); break; case 22: updateEditorGeometries(); break; case 23: updateGeometries(); break; case 24: verticalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break; case 25: horizontalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break; case 26: verticalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 27: horizontalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 28: closeEditor((*reinterpret_cast< QWidget*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemDelegate::EndEditHint(*)>(_a[2]))); break; case 29: commitData((*reinterpret_cast< QWidget*(*)>(_a[1]))); break; case 30: editorDestroyed((*reinterpret_cast< QObject*(*)>(_a[1]))); break; case 31: d_func()->_q_columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 32: d_func()->_q_columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 33: d_func()->_q_rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 34: d_func()->_q_modelDestroyed(); break; case 35: d_func()->_q_layoutChanged(); break; case 36: d_func()->_q_fetchMore(); break; } _id -= 37; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break; case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break; case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break; case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break; case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break; case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break; case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break; case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break; case 8: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break; case 9: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break; case 10: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break; case 11: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 12: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break; case 13: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break; case 14: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break; } _id -= 15; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break; case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break; case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break; case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break; case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break; case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break; case 8: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break; case 9: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break; case 10: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break; case 11: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 12: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break; case 13: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; case 14: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; } _id -= 15; } else if (_c == QMetaObject::ResetProperty) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 15; } #endif // QT_NO_PROPERTIES return _id; }
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))); }
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractScrollArea::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 39) qt_static_metacall(this, _c, _id, _a); _id -= 39; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break; case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break; case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break; case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break; case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break; case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break; case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break; case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break; case 8: *reinterpret_cast< Qt::DropAction*>(_v) = defaultDropAction(); break; case 9: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break; case 10: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break; case 11: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break; case 12: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 13: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break; case 14: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break; case 15: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break; } _id -= 16; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break; case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break; case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break; case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break; case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break; case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break; case 8: setDefaultDropAction(*reinterpret_cast< Qt::DropAction*>(_v)); break; case 9: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break; case 10: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break; case 11: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break; case 12: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 13: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break; case 14: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; case 15: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; } _id -= 16; } else if (_c == QMetaObject::ResetProperty) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 16; } #endif // QT_NO_PROPERTIES return _id; }
// Note: the QDesktopViewWidget Class will become it's own widget // so others can easly create there own desktopsor file managers with // only a few lines of code QDesktopViewWidget::QDesktopViewWidget(QWidget *parent) : QListWidget(parent) { // This sets the QDesktopViewWidget(QListWidget) to transparent so that the // desktop wallpaper below it can be seen. Note: the color: white propertiy // needs to be moved to the desktop config file setStyleSheet("QListView {background-color: transparent; color: white;}"); // Note: Need to check if config files exist, if it doesnt we need to // create it. // In the future the below QDesktopViewWidget settings will be wrapped // in this block of code so every aspect of how the desktop looks and feels // can be configured. // Note: Needs to be moved to a class function of it's own //desktopSettings = new QSettings("chipara", "desktop"); //desktopSettings->beginGroup("desktop"); //desktopSettings->endGroup(); // Variouse settings for the QDesktopViewWidget(QListWidget) class setSelectionMode(QAbstractItemView::ExtendedSelection); setViewMode(QListView::IconMode); setSpacing(20); setFlow(QListView::TopToBottom); setMovement(QListView::Snap); setLayoutMode(QListView::Batched); setBatchSize(100); setMovement(QListView::Snap); setIconSize(QSize(48, 48)); setUniformItemSizes(true); setWrapping(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSortingEnabled(true); setLayoutDirection(Qt::LeftToRight); setSelectionRectVisible(true); setTextElideMode(Qt::ElideMiddle); setDragEnabled(true); setFrameStyle(0); setFrameShape(QFrame::NoFrame); setAutoScroll(true); setResizeMode(QListView::Adjust); // Right Click Desktop Menu menu = new QMenu(this); // Create submenu for Create Document QMenu *viewMenu = menu->addMenu(tr("&View")); QActionGroup *viewGroup = new QActionGroup(this); // Large Icons extraLargeIcons = new QAction(QIcon::fromTheme("folder"), "X-Large Icons", this); extraLargeIcons->setCheckable(true); viewGroup->addAction(extraLargeIcons); viewMenu->addAction(extraLargeIcons); connect(extraLargeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Large Icons largeIcons = new QAction(QIcon::fromTheme("folder"), "Large Icons", this); largeIcons->setCheckable(true); viewGroup->addAction(largeIcons); viewMenu->addAction(largeIcons); connect(largeIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons mediumIcons = new QAction(QIcon::fromTheme("folder"), "Medium Icons", this); mediumIcons->setCheckable(true); mediumIcons->setChecked(true); viewGroup->addAction(mediumIcons); viewMenu->addAction(mediumIcons); connect(mediumIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Medium Icons smallIcons = new QAction(QIcon::fromTheme("folder"), "Small Icons", this); smallIcons->setCheckable(true); viewGroup->addAction(smallIcons); viewMenu->addAction(smallIcons); connect(smallIcons, SIGNAL(triggered()), this, SLOT(resizeIcons())); // Add a separator to the menu viewMenu->addSeparator(); QActionGroup *layoutGroup = new QActionGroup(this); // Medium Icons leftToRight = new QAction(QIcon::fromTheme("folder"), "Left To Right", this); leftToRight->setCheckable(true); layoutGroup->addAction(leftToRight); viewMenu->addAction(leftToRight); connect(leftToRight, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Medium Icons rightToLeft = new QAction(QIcon::fromTheme("folder"), "Right To Left", this); rightToLeft->setCheckable(true); layoutGroup->addAction(rightToLeft); viewMenu->addAction(rightToLeft); connect(rightToLeft, SIGNAL(triggered()), this, SLOT(layoutDirection())); // Add a separator to the menu viewMenu->addSeparator(); // Sort By Size showIcons = new QAction(QIcon::fromTheme("folder"), "Show Desktop Icons", this); showIcons->setCheckable(true); showIcons->setChecked(true); viewMenu->addAction(showIcons); connect(showIcons, SIGNAL(triggered()), this, SLOT(showDesktopIcons())); // Create submenu for Create Document QMenu *sortMenu = menu->addMenu(tr("&Sort By")); QActionGroup *sortGroup = new QActionGroup(this); // Sort By Name QAction *nameSort = new QAction(QIcon::fromTheme("folder"), "Name", this); nameSort->setCheckable(true); nameSort->setChecked(true); sortGroup->addAction(nameSort); sortMenu->addAction(nameSort); // Sort By Size QAction *sizeSort = new QAction(QIcon::fromTheme("folder"), "Size", this); sizeSort->setCheckable(true); sizeSort->setDisabled(true); sortGroup->addAction(sizeSort); sortMenu->addAction(sizeSort); // Sort By Size QAction *typeSort = new QAction(QIcon::fromTheme("folder"), "Item Type", this); typeSort->setCheckable(true); typeSort->setDisabled(true); sortGroup->addAction(typeSort); sortMenu->addAction(typeSort); // Sort By Size QAction *dateSort = new QAction(QIcon::fromTheme("folder"), "Date Modified", this); dateSort->setCheckable(true); dateSort->setDisabled(true); sortGroup->addAction(dateSort); sortMenu->addAction(dateSort); // Refresh QAction *refresh = new QAction(QIcon::fromTheme("folder"), "Refresh", this); menu->addAction(refresh); // Add a separator to the menu menu->addSeparator(); // Paste QAction *paste = new QAction(QIcon::fromTheme("folder"), "Paste", this); paste->setEnabled(false); menu->addAction(paste); // Paste Shortcut QAction *pasteShortCut = new QAction(QIcon::fromTheme("folder"), "Paste Shortcut", this); pasteShortCut->setEnabled(false); menu->addAction(pasteShortCut); // Add a separator to the menu menu->addSeparator(); // New Menu QMenu *create = menu->addMenu(tr("&New")); // Create Folder QAction *createFolder = new QAction(QIcon::fromTheme("folder"), tr("&Folder"), this); create->addAction(createFolder); createFolder->setIconVisibleInMenu(true); connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder())); // Create Launcher QAction *createLauncher = new QAction(QIcon::fromTheme("application-x-desktop"), tr("&Launcher"), this); create->addAction(createLauncher); createLauncher->setIconVisibleInMenu(true); connect(createLauncher, SIGNAL(triggered()), this, SLOT(createLauncher())); // Create Empty File QAction *createEmptyFile = new QAction(QIcon::fromTheme("text-plain"), tr("&Empty File"), this); create->addAction(createEmptyFile); createEmptyFile->setIconVisibleInMenu(true); connect(createEmptyFile, SIGNAL(triggered()), this, SLOT(createEmptyFile())); // Add a separator to the menu menu->addSeparator(); // Paste QAction *desktopSettings = new QAction(QIcon::fromTheme("preferences-desktop"), "Desktop Settings", this); desktopSettings->setIconVisibleInMenu(true); menu->addAction(desktopSettings); connect(desktopSettings, SIGNAL(triggered()), this, SLOT(execDesktopSettings())); // Right Click Desktop Icon Menu iconMenu = new QIconMenu(this); // desktopDir = new QFileSystemWatcher; desktopDir->addPath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); // dSettings = new QSettings("chipara", "desktop"); dSettings->beginGroup("window"); if (dSettings->value("showIcons") == 1) { showIcons->setChecked(true); } else { showIcons->setChecked(false); } // if (dSettings->value("layoutDirection") == 1) { setLayoutDirection(Qt::LeftToRight); leftToRight->setChecked(true); } else { setLayoutDirection(Qt::RightToLeft); rightToLeft->setChecked(true); } // if (dSettings->value("iconSize") == 1) { this->setIconSize(QSize(128, 128)); extraLargeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 2) { this->setIconSize(QSize(64, 64)); largeIcons->setChecked(true); } else if (dSettings->value("iconSize") == 3) { this->setIconSize(QSize(48, 48)); mediumIcons->setChecked(true); } else if (dSettings->value("iconSize") == 4) { this->setIconSize(QSize(36, 36)); smallIcons->setChecked(true); } populatedDesktop(); dSettings->endGroup(); // Desktop Icon Double Click EventexecDesktopSettings connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(iconClicked(QListWidgetItem*))); connect(desktopDir, SIGNAL(directoryChanged(QString)), this, SLOT(populatedDesktop())); }
Playlist::PrettyListView::PrettyListView( QWidget* parent ) : QListView( parent ) , ViewCommon() , m_headerPressIndex( QModelIndex() ) , m_mousePressInHeader( false ) , m_skipAutoScroll( false ) , m_firstScrollToActiveTrack( true ) , m_rowsInsertedScrollItem( 0 ) , m_showOnlyMatches( false ) , m_pd( 0 ) { // QAbstractItemView basics setModel( The::playlist()->qaim() ); m_prettyDelegate = new PrettyItemDelegate( this ); connect( m_prettyDelegate, SIGNAL( redrawRequested() ), this, SLOT( redrawActive() ) ); setItemDelegate( m_prettyDelegate ); setSelectionMode( ExtendedSelection ); setDragDropMode( DragDrop ); setDropIndicatorShown( false ); // we draw our own drop indicator setEditTriggers ( SelectedClicked | EditKeyPressed ); setAutoScroll( true ); setVerticalScrollMode( ScrollPerPixel ); setMouseTracking( true ); // Rendering adjustments setFrameShape( QFrame::NoFrame ); setAlternatingRowColors( true) ; The::paletteHandler()->updateItemView( this ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(newPalette(QPalette)) ); setAutoFillBackground( false ); // Signal connections connect( this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(trackActivated(QModelIndex)) ); connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(slotSelectionChanged()) ); connect( LayoutManager::instance(), SIGNAL(activeLayoutChanged()), this, SLOT(playlistLayoutChanged()) ); connect( model(), SIGNAL(activeTrackChanged(quint64)), this, SLOT(slotPlaylistActiveTrackChanged()) ); connect( model(), SIGNAL(queueChanged()), viewport(), SLOT(update()) ); // Warning, this one doesn't connect to the normal 'model()' (i.e. '->top()'), but to '->bottom()'. connect( Playlist::ModelStack::instance()->bottom(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(bottomModelRowsInserted(QModelIndex,int,int)) ); // Timers m_proxyUpdateTimer = new QTimer( this ); m_proxyUpdateTimer->setSingleShot( true ); connect( m_proxyUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProxyTimeout()) ); m_animationTimer = new QTimer(this); connect( m_animationTimer, SIGNAL(timeout()), this, SLOT(redrawActive()) ); m_animationTimer->setInterval( 250 ); playlistLayoutChanged(); // We do the following call here to be formally correct, but note: // - It happens to be redundant, because 'playlistLayoutChanged()' already schedules // another one, via a QTimer( 0 ). // - Both that one and this one don't work right (they scroll like 'PositionAtTop', // not 'PositionAtCenter'). This is probably because MainWindow changes its // geometry in a QTimer( 0 )? As a fix, MainWindow does a 'slotShowActiveTrack()' // at the end of its QTimer slot, which will finally scroll to the right spot. slotPlaylistActiveTrackChanged(); }
TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window) : QTreeView(parent) , main_window(main_window) { setUniformRowHeights(true); // Load settings bool column_loaded = loadSettings(); // Create and apply delegate listDelegate = new TransferListDelegate(this); setItemDelegate(listDelegate); // Create transfer list model listModel = new TorrentModel(this); nameFilterModel = new TransferListSortModel(); nameFilterModel->setDynamicSortFilter(true); nameFilterModel->setSourceModel(listModel); nameFilterModel->setFilterKeyColumn(TorrentModel::TR_NAME); nameFilterModel->setFilterRole(Qt::DisplayRole); nameFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive); setModel(nameFilterModel); // Visual settings setRootIsDecorated(false); setAllColumnsShowFocus(true); setSortingEnabled(true); setSelectionMode(QAbstractItemView::ExtendedSelection); setItemsExpandable(false); setAutoScroll(true); setDragDropMode(QAbstractItemView::DragOnly); #if defined(Q_OS_MAC) setAttribute(Qt::WA_MacShowFocusRect, false); #endif header()->setStretchLastSection(false); // Default hidden columns if (!column_loaded) { setColumnHidden(TorrentModel::TR_ADD_DATE, true); setColumnHidden(TorrentModel::TR_SEED_DATE, true); setColumnHidden(TorrentModel::TR_UPLIMIT, true); setColumnHidden(TorrentModel::TR_DLLIMIT, true); setColumnHidden(TorrentModel::TR_TRACKER, true); setColumnHidden(TorrentModel::TR_AMOUNT_DOWNLOADED, true); setColumnHidden(TorrentModel::TR_AMOUNT_UPLOADED, true); setColumnHidden(TorrentModel::TR_AMOUNT_DOWNLOADED_SESSION, true); setColumnHidden(TorrentModel::TR_AMOUNT_UPLOADED_SESSION, true); setColumnHidden(TorrentModel::TR_AMOUNT_LEFT, true); setColumnHidden(TorrentModel::TR_TIME_ELAPSED, true); setColumnHidden(TorrentModel::TR_SAVE_PATH, true); setColumnHidden(TorrentModel::TR_COMPLETED, true); setColumnHidden(TorrentModel::TR_RATIO_LIMIT, true); setColumnHidden(TorrentModel::TR_SEEN_COMPLETE_DATE, true); setColumnHidden(TorrentModel::TR_LAST_ACTIVITY, true); setColumnHidden(TorrentModel::TR_TOTAL_SIZE, true); } //Ensure that at least one column is visible at all times bool atLeastOne = false; for (unsigned int i = 0; i<TorrentModel::NB_COLUMNS; i++) { if (!isColumnHidden(i)) { atLeastOne = true; break; } } if (!atLeastOne) setColumnHidden(TorrentModel::TR_NAME, false); //When adding/removing columns between versions some may //end up being size 0 when the new version is launched with //a conf file from the previous version. for (unsigned int i = 0; i<TorrentModel::NB_COLUMNS; i++) if (!columnWidth(i)) resizeColumnToContents(i); setContextMenuPolicy(Qt::CustomContextMenu); // Listen for list events connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentDoubleClicked(QModelIndex))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayListMenu(const QPoint &))); header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(header(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayDLHoSMenu(const QPoint &))); connect(header(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveSettings())); connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut); #ifdef QBT_USES_QT5 // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 QTableView unused; unused.setVerticalHeader(header()); header()->setParent(this); unused.setVerticalHeader(new QHeaderView(Qt::Horizontal)); #endif }
ListingTable::ListingTable(PartCategory* partCat, Filter* filter, QWidget* parent) : QTableView(parent), partCat(partCat), model(new PartTableModel(partCat, filter, this)), ignoreSectionResize(false) { setModel(model); QHeaderView* hheader = horizontalHeader(); verticalHeader()->hide(); hheader->setStretchLastSection(true); hheader->setCascadingSectionResizes(false); hheader->setMovable(true); setSelectionBehavior(SelectRows); setDragEnabled(true); setDragDropMode(DragOnly); setAutoScroll(true); setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); setContextMenuPolicy(Qt::CustomContextMenu); hheader->setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(partActivatedSlot(const QModelIndex&))); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenuRequested(const QPoint&))); connect(hheader, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(headerContextMenuRequested(const QPoint&))); System* sys = System::getInstance(); EditStack* editStack = sys->getEditStack(); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); connect(partCat, SIGNAL(recordEdited(unsigned int, PartCategory::DataMap)), this, SLOT(updateData())); connect(partCat, SIGNAL(recordCreated(unsigned int, PartCategory::DataMap)), this, SLOT(updateData())); connect(partCat, SIGNAL(recordsRemoved(QList<unsigned int>)), this, SLOT(updateData())); connect(editStack, SIGNAL(undone(EditCommand*)), this, SLOT(updateData())); connect(editStack, SIGNAL(redone(EditCommand*)), this, SLOT(updateData())); connect(selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(currentChanged(const QModelIndex&, const QModelIndex&))); connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&))); connect(model, SIGNAL(updateRequested()), this, SLOT(updateData())); QSettings s; s.beginGroup(QString("gui_geometry_%1").arg(partCat->getTableName())); if (!s.contains("lt_state") || !restoreState(s.value("lt_state").toByteArray())) { unsigned initialTotalWidth = 1000; int nc = model->columnCount(); for (unsigned int i = 0 ; i < nc-1 ; i++) { setColumnWidth(i, initialTotalWidth / nc); } } s.endGroup(); }