You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

69 lines
2.0 KiB

  1. #include "overwrite_check.h"
  2. #include "ui_overwrite_check.h"
  3. overwrite_check::overwrite_check(QVector<episode_t> _alreadyExisting,QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::overwrite_check)
  6. {
  7. ui->setupUi(this);
  8. alreadyExisting = _alreadyExisting;
  9. for(auto e:alreadyExisting){
  10. ui->unavailable_eps->insertRow(ui->unavailable_eps->rowCount());
  11. collection_t c = e.collection;
  12. for(int i = 0; i < 7;i++){
  13. QTableWidgetItem* item = new QTableWidgetItem();
  14. switch (i) {
  15. case 0:
  16. item->setText(c.name);
  17. break;
  18. case 1:
  19. item->setText("Season " + c.season);
  20. break;
  21. case 2:
  22. item->setText("E"+QString::number(e.number));
  23. break;
  24. case 3:
  25. item->setText(e.name);
  26. break;
  27. case 4:
  28. item->setText(e.premium_only ? "true" : "false");
  29. break;
  30. case 5:
  31. item->setText(e.available ? "true" : "false");
  32. break;
  33. }
  34. ui->unavailable_eps->setItem(ui->unavailable_eps->rowCount()-1,i,item);
  35. }
  36. }
  37. ui->unavailable_eps->horizontalHeader()->resizeSection(0,200);
  38. ui->unavailable_eps->horizontalHeader()->resizeSection(1,75);
  39. ui->unavailable_eps->horizontalHeader()->resizeSection(2,50);
  40. ui->unavailable_eps->horizontalHeader()->resizeSection(3,200);
  41. ui->unavailable_eps->horizontalHeader()->resizeSection(4,90);
  42. ui->unavailable_eps->horizontalHeader()->resizeSection(5,75);
  43. }
  44. overwrite_check::~overwrite_check()
  45. {
  46. delete ui;
  47. }
  48. QVector<episode_t> overwrite_check::getSelection(){
  49. QVector<int> rows;
  50. auto selectedItems = ui->unavailable_eps->selectedItems();
  51. for(auto item:selectedItems){
  52. if(!rows.contains(item->row()))
  53. rows.append(item->row());
  54. }
  55. QVector<episode_t> sel;
  56. for(int row:rows){
  57. sel.push_back(alreadyExisting.at(row));
  58. }
  59. return sel;
  60. }