mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 16:37:21 -06:00
Fix properties display for torrents without metadata
This commit is contained in:
@@ -237,30 +237,34 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
|||||||
clear();
|
clear();
|
||||||
h = _h;
|
h = _h;
|
||||||
if(!h.is_valid()) {
|
if(!h.is_valid()) {
|
||||||
|
qDebug("Properties: invalid handle, returning.");
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
|
PropListModel->clear();
|
||||||
try {
|
try {
|
||||||
// Save path
|
// Save path
|
||||||
updateSavePath(h);
|
updateSavePath(h);
|
||||||
changeSavePathButton->setEnabled(h.has_metadata());
|
changeSavePathButton->setEnabled(h.has_metadata());
|
||||||
// Creation date
|
|
||||||
lbl_creationDate->setText(h.creation_date());
|
|
||||||
// Hash
|
// Hash
|
||||||
hash_lbl->setText(h.hash());
|
hash_lbl->setText(h.hash());
|
||||||
|
if(h.has_metadata()) {
|
||||||
|
// Creation date
|
||||||
|
lbl_creationDate->setText(h.creation_date());
|
||||||
// Comment
|
// Comment
|
||||||
comment_text->setHtml(h.comment());
|
comment_text->setHtml(h.comment());
|
||||||
// URL seeds
|
// URL seeds
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
// List files in torrent
|
// List files in torrent
|
||||||
PropListModel->clear();
|
|
||||||
PropListModel->setupModelData(h.get_torrent_info());
|
PropListModel->setupModelData(h.get_torrent_info());
|
||||||
// Expand first item if possible
|
// Expand first item if possible
|
||||||
filesList->expand(PropListModel->index(0, 0));
|
filesList->expand(PropListModel->index(0, 0));
|
||||||
|
}
|
||||||
} catch(invalid_handle e) {
|
} catch(invalid_handle e) {
|
||||||
|
qDebug("Properties: INVALID HANDLE");
|
||||||
|
qDebug("what() == %s", e.what());
|
||||||
}
|
}
|
||||||
// Load dynamic data
|
// Load dynamic data
|
||||||
loadDynamicData();
|
loadDynamicData();
|
||||||
@@ -726,9 +730,9 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::askWebSeed(){
|
void PropertiesWidget::askWebSeed(){
|
||||||
bool ok;
|
bool ok;
|
||||||
// Ask user for a new url seed
|
// Ask user for a new url seed
|
||||||
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
|
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"),
|
||||||
@@ -745,9 +749,9 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
h.add_url_seed(url_seed);
|
h.add_url_seed(url_seed);
|
||||||
// Refresh the seeds list
|
// Refresh the seeds list
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::deleteSelectedUrlSeeds(){
|
void PropertiesWidget::deleteSelectedUrlSeeds(){
|
||||||
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
|
const QList<QListWidgetItem *> selectedItems = listWebSeeds->selectedItems();
|
||||||
bool change = false;
|
bool change = false;
|
||||||
foreach(const QListWidgetItem *item, selectedItems){
|
foreach(const QListWidgetItem *item, selectedItems){
|
||||||
@@ -759,9 +763,9 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
// Refresh list
|
// Refresh list
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertiesWidget::applyPriorities() {
|
bool PropertiesWidget::applyPriorities() {
|
||||||
qDebug("Saving pieces priorities");
|
qDebug("Saving pieces priorities");
|
||||||
const std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files());
|
const std::vector<int> priorities = PropListModel->getFilesPriorities(h.get_torrent_info().num_files());
|
||||||
bool first_last_piece_first = false;
|
bool first_last_piece_first = false;
|
||||||
@@ -775,10 +779,10 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
if(first_last_piece_first)
|
if(first_last_piece_first)
|
||||||
h.prioritize_first_last_piece(true);
|
h.prioritize_first_last_piece(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PropertiesWidget::on_changeSavePathButton_clicked() {
|
void PropertiesWidget::on_changeSavePathButton_clicked() {
|
||||||
if(!h.is_valid()) return;
|
if(!h.is_valid()) return;
|
||||||
QString new_path;
|
QString new_path;
|
||||||
if(h.has_metadata() && h.num_files() == 1) {
|
if(h.has_metadata() && h.num_files() == 1) {
|
||||||
@@ -834,10 +838,10 @@ void PropertiesWidget::renameSelectedFile() {
|
|||||||
#endif
|
#endif
|
||||||
save_path->setText(display_path);
|
save_path->setText(display_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::filteredFilesChanged() {
|
void PropertiesWidget::filteredFilesChanged() {
|
||||||
if(h.is_valid()) {
|
if(h.is_valid()) {
|
||||||
applyPriorities();
|
applyPriorities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user