本文整理汇总了C++中QTableView::setVerticalHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ QTableView::setVerticalHeader方法的具体用法?C++ QTableView::setVerticalHeader怎么用?C++ QTableView::setVerticalHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTableView
的用法示例。
在下文中一共展示了QTableView::setVerticalHeader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines)
: QDialog(parent)
, supported_engines(supported_engines)
, m_updateUrl(QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (Utils::Misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/")
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(pluginsTree->header());
pluginsTree->header()->setParent(pluginsTree);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
pluginsTree->setRootIsDecorated(false);
pluginsTree->header()->resizeSection(0, 160);
pluginsTree->header()->resizeSection(1, 80);
pluginsTree->header()->resizeSection(2, 200);
pluginsTree->hideColumn(ENGINE_ID);
actionUninstall->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
connect(actionEnable, SIGNAL(toggled(bool)), this, SLOT(enableSelection(bool)));
connect(pluginsTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContextMenu(const QPoint&)));
loadSupportedSearchEngines();
connect(supported_engines, SIGNAL(newSupportedEngine(QString)), this, SLOT(addNewEngine(QString)));
connect(pluginsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(toggleEngineState(QTreeWidgetItem*, int)));
show();
}
示例2: QDialog
PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const torrent)
: QDialog(parent)
, m_torrent(torrent)
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
Preferences* const pref = Preferences::instance();
// Preview list
previewListModel = new QStandardItemModel(0, NB_COLUMNS);
previewListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
previewListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
previewListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(previewList->header());
previewList->header()->setParent(previewList);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
previewList->setModel(previewListModel);
previewList->hideColumn(FILE_INDEX);
listDelegate = new PreviewListDelegate(this);
previewList->setItemDelegate(listDelegate);
previewList->header()->resizeSection(0, 200);
previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
// Fill list in
QVector<qreal> fp = torrent->filesProgress();
int nbFiles = torrent->filesCount();
for (int i = 0; i < nbFiles; ++i) {
QString fileName = torrent->fileName(i);
if (fileName.endsWith(QB_EXT))
fileName.chop(4);
QString extension = Utils::Fs::fileExtension(fileName).toUpper();
if (Utils::Misc::isPreviewable(extension)) {
int row = previewListModel->rowCount();
previewListModel->insertRow(row);
previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
previewListModel->setData(previewListModel->index(row, SIZE), QVariant(torrent->fileSize(i)));
previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant(fp[i]));
previewListModel->setData(previewListModel->index(row, FILE_INDEX), QVariant(i));
}
}
if (!previewListModel->rowCount()) {
QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
previewListModel->sort(NAME);
previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
previewList->selectionModel()->select(previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
if (previewListModel->rowCount() == 1) {
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
on_previewButton_clicked();
}else{
qDebug("Displaying media file selection dialog for preview");
show();
}
}
示例3: QTreeView
TrackView::TrackView( QWidget* parent )
: QTreeView( parent )
, m_model( 0 )
, m_proxyModel( 0 )
, m_delegate( 0 )
, m_header( new ViewHeader( this ) )
, m_overlay( new OverlayWidget( this ) )
, m_loadingSpinner( new LoadingSpinner( this ) )
, m_resizing( false )
, m_dragging( false )
, m_alternatingRowColors( false )
, m_autoExpanding( true )
, m_contextMenu( new ContextMenu( this ) )
{
setFrameShape( QFrame::NoFrame );
setAttribute( Qt::WA_MacShowFocusRect, 0 );
setContentsMargins( 0, 0, 0, 0 );
setMouseTracking( true );
setSelectionMode( QAbstractItemView::ExtendedSelection );
setSelectionBehavior( QAbstractItemView::SelectRows );
setDragEnabled( true );
setDropIndicatorShown( false );
setDragDropMode( QAbstractItemView::InternalMove );
setDragDropOverwriteMode( false );
setAllColumnsShowFocus( true );
setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
setRootIsDecorated( false );
setUniformRowHeights( true );
setAlternatingRowColors( m_alternatingRowColors );
setAutoResize( false );
setEditTriggers( NoEditTriggers );
setHeader( m_header );
// HACK: enable moving of first column: QTBUG-33974 / https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader( header() );
header()->setParent( this );
unused.setVerticalHeader( new QHeaderView( Qt::Horizontal, &unused ) );
setSortingEnabled( true );
sortByColumn( -1 );
setContextMenuPolicy( Qt::CustomContextMenu );
m_timer.setInterval( SCROLL_TIMEOUT );
// enable those connects if you want to enable lazily loading extra information for visible items
// connect( verticalScrollBar(), SIGNAL( rangeChanged( int, int ) ), SLOT( onViewChanged() ) );
// connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), SLOT( onViewChanged() ) );
// connect( &m_timer, SIGNAL( timeout() ), SLOT( onScrollTimeout() ) );
connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) );
connect( this, SIGNAL( customContextMenuRequested( const QPoint& ) ), SLOT( onCustomContextMenu( const QPoint& ) ) );
connect( m_contextMenu, SIGNAL( triggered( int ) ), SLOT( onMenuTriggered( int ) ) );
setProxyModel( new PlayableProxyModel( this ) );
}
示例4: QTreeView
TorrentContentTreeView::TorrentContentTreeView(QWidget *parent)
: QTreeView(parent)
{
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(header());
header()->setParent(this);
header()->setStretchLastSection(false);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
}
示例5: QTreeView
TorrentContentTreeView::TorrentContentTreeView(QWidget* parent)
: QTreeView(parent)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
// 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
}
示例6: QTreeWidget
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) {
// Graphical settings
setRootIsDecorated(false);
setAllColumnsShowFocus(true);
setItemsExpandable(false);
setSelectionMode(QAbstractItemView::ExtendedSelection);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTrackerListMenu(QPoint)));
// Set header
QStringList header;
header << "#";
header << tr("URL");
header << tr("Status");
header << tr("Received");
header << tr("Seeds");
header << tr("Peers");
header << tr("Downloaded");
header << tr("Message");
setHeaderItem(new QTreeWidgetItem(header));
dht_item = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" });
insertTopLevelItem(0, dht_item);
setRowColor(0, QColor("grey"));
pex_item = new QTreeWidgetItem({ "", "** [PeX] **", "", "0", "", "", "0" });
insertTopLevelItem(1, pex_item);
setRowColor(1, QColor("grey"));
lsd_item = new QTreeWidgetItem({ "", "** [LSD] **", "", "0", "", "", "0" });
insertTopLevelItem(2, lsd_item);
setRowColor(2, QColor("grey"));
editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut);
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker()));
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(this->header());
this->header()->setParent(this);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
loadSettings();
}
示例7: QTreeView
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
}
示例8: QWidget
SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::SearchJobWidget)
, m_searchHandler(searchHandler)
{
m_ui->setupUi(this);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->resultsBrowser->header());
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
loadSettings();
m_ui->resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
header()->setStretchLastSection(false);
// Set Search results list model
m_searchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS, this);
m_searchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
m_searchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
m_searchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
m_searchListModel->setHeaderData(SearchSortModel::LEECHES, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
m_searchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
// Set columns text alignment
m_searchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
m_searchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
m_searchListModel->setHeaderData(SearchSortModel::LEECHES, Qt::Horizontal, QVariant(Qt::AlignRight | Qt::AlignVCenter), Qt::TextAlignmentRole);
m_proxyModel = new SearchSortModel(this);
m_proxyModel->setDynamicSortFilter(true);
m_proxyModel->setSourceModel(m_searchListModel);
m_proxyModel->setNameFilter(searchHandler->pattern());
m_ui->resultsBrowser->setModel(m_proxyModel);
m_searchDelegate = new SearchListDelegate(this);
m_ui->resultsBrowser->setItemDelegate(m_searchDelegate);
m_ui->resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
m_ui->resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
m_ui->resultsBrowser->setRootIsDecorated(false);
m_ui->resultsBrowser->setAllColumnsShowFocus(true);
m_ui->resultsBrowser->setSortingEnabled(true);
// Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (int i = 0; i < SearchSortModel::DL_LINK; ++i) {
if (!m_ui->resultsBrowser->isColumnHidden(i)) {
atLeastOne = true;
break;
}
}
if (!atLeastOne)
m_ui->resultsBrowser->setColumnHidden(SearchSortModel::NAME, false);
// To also mitigate the above issue, we have to resize each column when
// its size is 0, because explicitly 'showing' the column isn't enough
// in the above scenario.
for (int i = 0; i < SearchSortModel::DL_LINK; ++i)
if ((m_ui->resultsBrowser->columnWidth(i) <= 0) && !m_ui->resultsBrowser->isColumnHidden(i))
m_ui->resultsBrowser->resizeColumnToContents(i);
header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), &QWidget::customContextMenuRequested, this, &SearchJobWidget::displayToggleColumnsMenu);
connect(header(), &QHeaderView::sectionResized, this, &SearchJobWidget::saveSettings);
connect(header(), &QHeaderView::sectionMoved, this, &SearchJobWidget::saveSettings);
connect(header(), &QHeaderView::sortIndicatorChanged, this, &SearchJobWidget::saveSettings);
fillFilterComboBoxes();
updateFilter();
m_lineEditSearchResultsFilter = new LineEdit(this);
m_lineEditSearchResultsFilter->setPlaceholderText(tr("Filter search results..."));
m_lineEditSearchResultsFilter->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_lineEditSearchResultsFilter, &QWidget::customContextMenuRequested, this, &SearchJobWidget::showFilterContextMenu);
m_ui->horizontalLayout->insertWidget(0, m_lineEditSearchResultsFilter);
connect(m_lineEditSearchResultsFilter, &LineEdit::textChanged, this, &SearchJobWidget::filterSearchResults);
connect(m_ui->filterMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
connect(m_ui->minSeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->maxSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
connect(m_ui->maxSeeds, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->minSize, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
connect(m_ui->minSize, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->maxSize, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);
connect(m_ui->maxSize, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->minSizeUnit, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->maxSizeUnit, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
, this, &SearchJobWidget::updateFilter);
connect(m_ui->resultsBrowser, &QAbstractItemView::doubleClicked, this, &SearchJobWidget::onItemDoubleClicked);
//.........这里部分代码省略.........
示例9: QTreeWidget
TrackerList::TrackerList(PropertiesWidget *properties)
: QTreeWidget()
, m_properties(properties)
{
// Set header
// Must be set before calling loadSettings() otherwise the header is reset on restart
setHeaderLabels(headerLabels());
// Load settings
loadSettings();
// Graphical settings
setRootIsDecorated(false);
setAllColumnsShowFocus(true);
setItemsExpandable(false);
setSelectionMode(QAbstractItemView::ExtendedSelection);
header()->setStretchLastSection(false); // Must be set after loadSettings() in order to work
// Ensure that at least one column is visible at all times
if (visibleColumnsCount() == 0)
setColumnHidden(COL_URL, false);
// To also mitigate the above issue, we have to resize each column when
// its size is 0, because explicitly 'showing' the column isn't enough
// in the above scenario.
for (unsigned int i = 0; i < COL_COUNT; ++i)
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
resizeColumnToContents(i);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTrackerListMenu(QPoint)));
// Header context menu
header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayToggleColumnsMenu(const QPoint&)));
// Set DHT, PeX, LSD items
m_DHTItem = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" });
insertTopLevelItem(0, m_DHTItem);
setRowColor(0, QColor("grey"));
m_PEXItem = new QTreeWidgetItem({ "", "** [PeX] **", "", "0", "", "", "0" });
insertTopLevelItem(1, m_PEXItem);
setRowColor(1, QColor("grey"));
m_LSDItem = new QTreeWidgetItem({ "", "** [LSD] **", "", "0", "", "", "0" });
insertTopLevelItem(2, m_LSDItem);
setRowColor(2, QColor("grey"));
// Set static items alignment
m_DHTItem->setTextAlignment(COL_RECEIVED, (Qt::AlignRight | Qt::AlignVCenter));
m_PEXItem->setTextAlignment(COL_RECEIVED, (Qt::AlignRight | Qt::AlignVCenter));
m_LSDItem->setTextAlignment(COL_RECEIVED, (Qt::AlignRight | Qt::AlignVCenter));
m_DHTItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter));
m_PEXItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter));
m_LSDItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter));
m_DHTItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter));
m_PEXItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter));
m_LSDItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter));
m_DHTItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
m_PEXItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
m_LSDItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
// Set header alignment
headerItem()->setTextAlignment(COL_TIER, (Qt::AlignRight | Qt::AlignVCenter));
headerItem()->setTextAlignment(COL_RECEIVED, (Qt::AlignRight | Qt::AlignVCenter));
headerItem()->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter));
headerItem()->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter));
headerItem()->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
// Set hotkeys
m_editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut);
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker()));
m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
// 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));
}
示例10: QWidget
SearchTab::SearchTab(SearchWidget *parent)
: QWidget(parent)
, m_ui(new Ui::SearchTab())
, m_parent(parent)
{
m_ui->setupUi(this);
#ifdef QBT_USES_QT5
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(m_ui->resultsBrowser->header());
m_ui->resultsBrowser->header()->setParent(m_ui->resultsBrowser);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
#endif
m_ui->resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
// Set Search results list model
m_searchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS, this);
m_searchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
m_searchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
m_searchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
m_searchListModel->setHeaderData(SearchSortModel::LEECHES, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
m_searchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
m_proxyModel = new SearchSortModel(this);
m_proxyModel->setDynamicSortFilter(true);
m_proxyModel->setSourceModel(m_searchListModel);
m_ui->resultsBrowser->setModel(m_proxyModel);
m_searchDelegate = new SearchListDelegate(this);
m_ui->resultsBrowser->setItemDelegate(m_searchDelegate);
m_ui->resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
m_ui->resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
m_ui->resultsBrowser->setRootIsDecorated(false);
m_ui->resultsBrowser->setAllColumnsShowFocus(true);
m_ui->resultsBrowser->setSortingEnabled(true);
// Connect signals to slots (search part)
connect(m_ui->resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadItem(const QModelIndex&)));
// Load last columns width for search results list
if (!loadColWidthResultsList())
m_ui->resultsBrowser->header()->resizeSection(0, 275);
// Sort by Seeds
m_ui->resultsBrowser->sortByColumn(SearchSortModel::SEEDS, Qt::DescendingOrder);
fillFilterComboBoxes();
updateFilter();
connect(m_ui->filterMode, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFilter()));
connect(m_ui->minSeeds, SIGNAL(editingFinished()), this, SLOT(updateFilter()));
connect(m_ui->minSeeds, SIGNAL(valueChanged(int)), this, SLOT(updateFilter()));
connect(m_ui->maxSeeds, SIGNAL(editingFinished()), this, SLOT(updateFilter()));
connect(m_ui->maxSeeds, SIGNAL(valueChanged(int)), this, SLOT(updateFilter()));
connect(m_ui->minSize, SIGNAL(editingFinished()), this, SLOT(updateFilter()));
connect(m_ui->minSize, SIGNAL(valueChanged(double)), this, SLOT(updateFilter()));
connect(m_ui->maxSize, SIGNAL(editingFinished()), this, SLOT(updateFilter()));
connect(m_ui->maxSize, SIGNAL(valueChanged(double)), this, SLOT(updateFilter()));
connect(m_ui->minSizeUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFilter()));
connect(m_ui->maxSizeUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(updateFilter()));
}