mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Merge pull request #17980 from Chocobo1/model
Reserve space before appending elements
This commit is contained in:
commit
d328eeb5be
@ -882,7 +882,7 @@ void Application::createStartupProgressDialog()
|
|||||||
m_startupProgressDialog = new QProgressDialog(tr("Loading torrents..."), tr("Exit"), 0, 100);
|
m_startupProgressDialog = new QProgressDialog(tr("Loading torrents..."), tr("Exit"), 0, 100);
|
||||||
m_startupProgressDialog->setAttribute(Qt::WA_DeleteOnClose);
|
m_startupProgressDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
m_startupProgressDialog->setWindowFlag(Qt::WindowMinimizeButtonHint);
|
m_startupProgressDialog->setWindowFlag(Qt::WindowMinimizeButtonHint);
|
||||||
m_startupProgressDialog->setMinimumDuration(0); // Show dialog immediatelly by default
|
m_startupProgressDialog->setMinimumDuration(0); // Show dialog immediately by default
|
||||||
m_startupProgressDialog->setAutoReset(false);
|
m_startupProgressDialog->setAutoReset(false);
|
||||||
m_startupProgressDialog->setAutoClose(false);
|
m_startupProgressDialog->setAutoClose(false);
|
||||||
|
|
||||||
|
@ -2908,10 +2908,8 @@ void SessionImpl::generateResumeData()
|
|||||||
void SessionImpl::saveResumeData()
|
void SessionImpl::saveResumeData()
|
||||||
{
|
{
|
||||||
for (const TorrentImpl *torrent : asConst(m_torrents))
|
for (const TorrentImpl *torrent : asConst(m_torrents))
|
||||||
{
|
|
||||||
torrent->nativeHandle().save_resume_data(lt::torrent_handle::only_if_modified);
|
torrent->nativeHandle().save_resume_data(lt::torrent_handle::only_if_modified);
|
||||||
++m_numResumeData;
|
m_numResumeData += m_torrents.size();
|
||||||
}
|
|
||||||
|
|
||||||
// clear queued storage move jobs except the current ongoing one
|
// clear queued storage move jobs except the current ongoing one
|
||||||
if (m_moveStorageQueue.size() > 1)
|
if (m_moveStorageQueue.size() > 1)
|
||||||
|
@ -124,7 +124,7 @@ namespace
|
|||||||
// Spoof HTTP Referer to allow adding torrent link from Torcache/KickAssTorrents
|
// Spoof HTTP Referer to allow adding torrent link from Torcache/KickAssTorrents
|
||||||
request.setRawHeader("Referer", request.url().toEncoded().data());
|
request.setRawHeader("Referer", request.url().toEncoded().data());
|
||||||
#ifdef QT_NO_COMPRESS
|
#ifdef QT_NO_COMPRESS
|
||||||
// The macro "QT_NO_COMPRESS" defined in QT will disable the zlib releated features
|
// The macro "QT_NO_COMPRESS" defined in QT will disable the zlib related features
|
||||||
// and reply data auto-decompression in QT will also be disabled. But we can support
|
// and reply data auto-decompression in QT will also be disabled. But we can support
|
||||||
// gzip encoding and manually decompress the reply data.
|
// gzip encoding and manually decompress the reply data.
|
||||||
request.setRawHeader("Accept-Encoding", "gzip");
|
request.setRawHeader("Accept-Encoding", "gzip");
|
||||||
|
@ -48,7 +48,7 @@ StatusBar::StatusBar(QWidget *parent)
|
|||||||
{
|
{
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
// Redefining global stylesheet breaks certain elements on mac like tabs.
|
// Redefining global stylesheet breaks certain elements on mac like tabs.
|
||||||
// Qt checks whether the stylesheet class inherts("QMacStyle") and this becomes false.
|
// Qt checks whether the stylesheet class inherits("QMacStyle") and this becomes false.
|
||||||
setStyleSheet(u"QStatusBar::item { border-width: 0; }"_qs);
|
setStyleSheet(u"QStatusBar::item { border-width: 0; }"_qs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -79,25 +79,19 @@ void TorrentContentTreeView::keyPressEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
QModelIndex current = currentNameCell();
|
const QVariant value = currentNameCell().data(Qt::CheckStateRole);
|
||||||
|
|
||||||
QVariant value = current.data(Qt::CheckStateRole);
|
|
||||||
if (!value.isValid())
|
if (!value.isValid())
|
||||||
{
|
{
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
|
const Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked)
|
||||||
? Qt::Unchecked : Qt::Checked);
|
? Qt::Unchecked : Qt::Checked;
|
||||||
|
|
||||||
const QModelIndexList selection = selectionModel()->selectedRows(TorrentContentModelItem::COL_NAME);
|
const QModelIndexList selection = selectionModel()->selectedRows(TorrentContentModelItem::COL_NAME);
|
||||||
|
|
||||||
for (const QModelIndex &index : selection)
|
for (const QModelIndex &index : selection)
|
||||||
{
|
|
||||||
Q_ASSERT(index.column() == TorrentContentModelItem::COL_NAME);
|
|
||||||
model()->setData(index, state, Qt::CheckStateRole);
|
model()->setData(index, state, Qt::CheckStateRole);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentContentTreeView::renameSelectedFile(BitTorrent::AbstractFileStorage &fileStorage)
|
void TorrentContentTreeView::renameSelectedFile(BitTorrent::AbstractFileStorage &fileStorage)
|
||||||
@ -142,16 +136,16 @@ void TorrentContentTreeView::renameSelectedFile(BitTorrent::AbstractFileStorage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex TorrentContentTreeView::currentNameCell()
|
QModelIndex TorrentContentTreeView::currentNameCell() const
|
||||||
{
|
{
|
||||||
QModelIndex current = currentIndex();
|
const QModelIndex current = currentIndex();
|
||||||
if (!current.isValid())
|
if (!current.isValid())
|
||||||
{
|
{
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return model()->index(current.row(), TorrentContentModelItem::COL_NAME, current.parent());
|
return current.siblingAtColumn(TorrentContentModelItem::COL_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentContentTreeView::wheelEvent(QWheelEvent *event)
|
void TorrentContentTreeView::wheelEvent(QWheelEvent *event)
|
||||||
|
@ -49,6 +49,6 @@ public:
|
|||||||
void renameSelectedFile(BitTorrent::AbstractFileStorage &fileStorage);
|
void renameSelectedFile(BitTorrent::AbstractFileStorage &fileStorage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QModelIndex currentNameCell();
|
QModelIndex currentNameCell() const;
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
};
|
};
|
||||||
|
@ -632,9 +632,12 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
|
|
||||||
void TransferListModel::addTorrents(const QVector<BitTorrent::Torrent *> &torrents)
|
void TransferListModel::addTorrents(const QVector<BitTorrent::Torrent *> &torrents)
|
||||||
{
|
{
|
||||||
int row = m_torrentList.size();
|
qsizetype row = m_torrentList.size();
|
||||||
beginInsertRows({}, row, (row + torrents.size()));
|
const qsizetype total = row + torrents.size();
|
||||||
|
|
||||||
|
beginInsertRows({}, row, total);
|
||||||
|
|
||||||
|
m_torrentList.reserve(total);
|
||||||
for (BitTorrent::Torrent *torrent : torrents)
|
for (BitTorrent::Torrent *torrent : torrents)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_torrentMap.contains(torrent));
|
Q_ASSERT(!m_torrentMap.contains(torrent));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user