diff --git a/src/GUI.cpp b/src/GUI.cpp index 33dd57575..70a33acda 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -393,7 +393,8 @@ void GUI::previewFile(const QString& filePath){ void GUI::selectGivenRow(const QModelIndex& index){ int row = index.row(); - for(int i=0; icolumnCount(); ++i){ + unsigned int nbColumns = DLListModel->columnCount(); + for(unsigned int i=0; iselectionModel()->select(DLListModel->index(row, i), QItemSelectionModel::Select); } } @@ -435,7 +436,8 @@ void GUI::updateDlList(bool force){ // browse handles std::vector handles = BTSession.getTorrentHandles(); QStringList finishedSHAs = finishedTorrentTab->getFinishedSHAs(); - for(unsigned int i=0; i > lines; // insertion sorting - for(int i=0; irowCount(); ++i){ + unsigned int nbRows = DLListModel->rowCount(); + for(unsigned int i=0; i(i, DLListModel->data(DLListModel->index(i, index)).toDouble()), sortOrder); } // Insert items in new model, in correct order - int nbRows_old = lines.size(); - for(int row=0; rowinsertRow(DLListModel->rowCount()); - int sourceRow = lines[row].first; - for(int col=0; colcolumnCount(); ++col){ + unsigned int sourceRow = lines[row].first; + unsigned int nbColumns = DLListModel->columnCount(); + for(unsigned int col=0; colsetData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col))); DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole); DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole); @@ -535,15 +539,17 @@ void GUI::sortDownloadListFloat(int index, Qt::SortOrder sortOrder){ void GUI::sortDownloadListString(int index, Qt::SortOrder sortOrder){ QList > lines; // Insertion sorting - for(int i=0; irowCount(); ++i){ + unsigned int nbRows = DLListModel->rowCount(); + for(unsigned int i=0; i(i, DLListModel->data(DLListModel->index(i, index)).toString()), sortOrder); } // Insert items in new model, in correct order - int nbRows_old = lines.size(); - for(int row=0; rowinsertRow(DLListModel->rowCount()); - int sourceRow = lines[row].first; - for(int col=0; colcolumnCount(); ++col){ + unsigned int sourceRow = lines[row].first; + unsigned int nbColumns = DLListModel->columnCount(); + for(unsigned int col=0; colsetData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col))); DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole); DLListModel->setData(DLListModel->index(nbRows_old+row, col), DLListModel->data(DLListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole); @@ -618,7 +624,8 @@ void GUI::saveColWidthDLList() const{ qDebug("Saving columns width in download list"); QSettings settings("qBittorrent", "qBittorrent"); QStringList width_list; - for(int i=0; icolumnCount(); ++i){ + unsigned int nbColumns = DLListModel->columnCount(); + for(unsigned int i=0; icolumnWidth(i)).c_str()); } settings.setValue("DownloadListColsWidth", width_list.join(" ")); @@ -636,7 +643,8 @@ bool GUI::loadColWidthDLList(){ QStringList width_list = line.split(' '); if(width_list.size() != DLListModel->columnCount()) return false; - for(int i=0; iheader()->resizeSection(i, width_list.at(i).toInt()); } qDebug("Download list columns width loaded"); @@ -748,7 +756,8 @@ void GUI::on_actionOpen_triggered(){ if(!pathsList.empty()){ QSettings settings("qBittorrent", "qBittorrent"); bool useTorrentAdditionDialog = settings.value("Options/Misc/TorrentAdditionDialog/Enabled", true).toBool(); - for(int i=0; irowCount(); ++i){ + unsigned int nbRows = DLListModel->rowCount(); + for(unsigned int i=0; idata(DLListModel->index(i, HASH)).toString(); // Create .paused file QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused"); @@ -1168,7 +1178,8 @@ void GUI::on_actionStart_All_triggered(){ // Pause all torrents BTSession.resumeAllTorrents(); // update download list - for(int i=0; irowCount(); ++i){ + unsigned int nbRows = DLListModel->rowCount(); + for(unsigned int i=0; idata(DLListModel->index(i, HASH)).toString(); // Remove .paused file QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused"); @@ -1343,7 +1354,8 @@ void GUI::checkConnectionStatus(){ // Set the color of a row in data model void GUI::setRowColor(int row, const QString& color){ - for(int i=0; icolumnCount(); ++i){ + unsigned int nbColumns = DLListModel->columnCount(); + for(unsigned int i=0; isetData(DLListModel->index(row, i), QVariant(QColor(color)), Qt::TextColorRole); } } @@ -1351,7 +1363,8 @@ void GUI::setRowColor(int row, const QString& color){ // return the row of in data model // corresponding to the given the filehash int GUI::getRowFromHash(const QString& hash) const{ - for(int i=0; irowCount(); ++i){ + unsigned int nbRows = DLListModel->rowCount(); + for(unsigned int i=0; idata(DLListModel->index(i, HASH)) == hash){ return i; }