Ejemplo n.º 1
19
void MainWindow::showAnimePanel(int row, int column, QTableWidget *source) {
  if (column == 1) return;

  QString title = source->item(row, 0)->text();
  ProgressBox *spn = dynamic_cast<ProgressBox *>(source->cellWidget(row, 1));
  QString episodes = QString::number(spn->value());
  QString score = source->item(row, 2)->text();
  QString type = source->item(row, source->columnCount() - 1)->text();
  Anime *anime =
      User::sharedUser()->getAnimeByData(title, episodes, score, type);

  if (anime == nullptr) {
    QMessageBox::critical(this, "Shinjiru", tr("Unknown anime."));
    return;
  }

  QString old_status = anime->getMyStatus();

  AnimePanel *ap = new AnimePanel(this, anime, User::sharedUser()->scoreType());

  if (anime->needsLoad() || anime->needsCover()) {
    User::sharedUser()->loadAnimeData(anime, true);
  }

  connect(ap, &AnimePanel::accepted,
          [&, source, anime, row, old_status]() {  // NOLINT
            if (anime->getMyStatus() != old_status) {
              User::sharedUser()->removeFromList(old_status, anime);
              User::sharedUser()->addToList(anime->getMyStatus(), anime);
            }

            User::sharedUser()->animeChanged();
          });

  ap->show();
}
Ejemplo n.º 2
10
Anime *User::resolveSmartTitle(QString title) {
  for (SmartTitle *s : smart_titles) {
    if (s->contains(title)) {
      Anime *a = nullptr;

      for (int i = 0; i < this->anime_list.count(); i++) {
        if (anime_list.at(i)->getID() == s->getID()) {
          a = anime_list.at(i);
        }
      }

      if (a != nullptr) {
        a->setUpdateOffset(0);

        if (s->hasOffset()) {
          a->setUpdateOffset(s->getOffset());
        }
        return a;
      }
    }
  }

  return nullptr;
}
Ejemplo n.º 3
0
int main(void){
	int choice;
	choice = 0;
	Anime anima;
	while (choice != 5){
		choice = 0;
		cout << "1 - Add anime\n2 - Check Anime\n3 - Watched an episode\n4 - Watched several episodes\n5 - Exit" << endl;
		cin >> choice;
		cin.ignore();
		switch (choice){
		case 1:
			anima.add();
			break;
		case 2:
			anima.check();
			break;
		case 3:
			anima.aug();
			break;
		case 4:
			anima.mod();
			break;
		case 5:
			break;
		default:
			cout << "Please enter in a valid option" << endl;
		}
	}
}
Ejemplo n.º 4
0
void MainWindow::loadBrowserData() {
  QUrl url = API::sharedAPI()->sharedAniListAPI()->API_BROWSE;

  QString season = ui->comboSeason->currentText();
  QString year   = ui->comboYear->currentText();
  QString type   = ui->comboType->currentText();
  QString status = ui->comboStatus->currentText();

  // Clear the browser view
  QLayoutItem *item;

  while ((item = layout2->takeAt(0))) {
    delete item->widget();
    delete item;
  }

  if (!season.isEmpty()) {
    url = addQuery(url, "season", season);
  }

  if (!year.isEmpty()) {
    url = addQuery(url, "year", year);
  }

  if (!type.isEmpty()) {
    url = addQuery(url, "type", type);
  }

  if (!status.isEmpty()) {
    url = addQuery(url, "status", status);
  }

  QStringList genres;
  QStringList exclude;

  for (int i = 0; i < ui->genreList->count(); i++) {
    QCheckBox *w = static_cast<QCheckBox *>
        (dynamic_cast<QWidgetItem *>(ui->genreList->itemAt(i))->widget());

    if (w->checkState() == Qt::PartiallyChecked) {
      exclude.append(w->text());
    } else if (w->checkState() == Qt::Checked) {
      genres.append(w->text());
    }
  }

  if (!genres.isEmpty()) {
    url = addQuery(url, "genres", genres.join(","));
  }

  if (!exclude.isEmpty()) {
    url = addQuery(url, "genres_exclude", exclude.join(","));
  }

  // Load the results for the requested type
  QJsonArray browse_results =
      API::sharedAPI()->sharedAniListAPI()->get(url).array();

  for (int i = 0; i <= browse_results.size(); i++) {
    QJsonObject anime = browse_results.at(i).toObject();

    Anime *a = User::sharedUser()->getAnimeByTitle(
          anime.value("title_romaji").toString());

    if (a == 0) {
      a = new Anime();
      a->setID(QString::number(anime.value("id").toInt()));
      a->setMyProgress(0);
      a->setMyNotes("");
      a->setMyRewatch(0);
      a->setMyStatus("");

      if (a->getID() == "0") {
        delete a;
        continue;
      }
    }

    BrowseAnime *s = new BrowseAnime(this, User::sharedUser()->scoreType());

    if (a->needsLoad() || a->needsCover()) {
      User::sharedUser()->loadAnimeData(a, true);

      QEventLoop evt;
      connect(a, SIGNAL(finishedReloading()), &evt, SLOT(quit()));
      evt.exec();
    }

    s->setAnime(a);

    layout2->addWidget(s);

    // Do we need to keep loading?
    if (season != ui->comboSeason->currentText() ||
       year != ui->comboYear->currentText() ||
       type != ui->comboType->currentText() ||
       status != ui->comboStatus->currentText()) {
      return;
    }

    int width = layout2->geometry().width();
    int cwidth = layout2->contentsWidth();

    if (cwidth < 0) {
      width = this->width() - 2;
      cwidth = this->width() - (this->width() % 200);
    }

    layout2->setContentsMargins((width-cwidth)/2, 0, 0, 0);
  }
}
Ejemplo n.º 5
0
int User::loadNext() {
  if (queue.empty()) return 1;

  if (this->cancel) return 1;

  QMap<Anime *, bool> data = queue.front();
  queue.pop();

  Anime *anime = data.keys().first();
  bool download_cover = data.values().first();

  QString ID = anime->getID();
  QUrl ID_URL = API::sharedAPI()->sharedAniListAPI()->API_ANIME(ID);

  QJsonObject result =
      API::sharedAPI()->sharedAniListAPI()->get(ID_URL).object();

  anime->setCoverURL(QUrl(result.value("image_url_lge").toString()));

  if (download_cover) {
    QEventLoop evt;
    connect(anime, SIGNAL(new_image()), &evt, SLOT(quit()));
    anime->downloadCover();
    evt.exec();
  }

  QString description = result.value("description").toString();

  anime->setDuration(result.value("duration").toInt());
  anime->setSynopsis(description);
  anime->setRomajiTitle(result.value("title_romaji").toString());
  anime->setJapaneseTitle(result.value("title_japanese").toString());
  anime->setEnglishTitle(result.value("title_english").toString());
  anime->setType(result.value("type").toString());
  anime->setAiringStatus(result.value("airing_status").toString());
  anime->setEpisodeCount(result.value("total_episodes").toInt());
  anime->setAverageScore(result.value("average_score").toString());
  anime->setTitle(result.value(title_language).toString());

  if (anime->getAiringStatus() == "currently airing") {
    QJsonObject airing = result.value("airing").toObject();

    anime->setNextEpisode(airing.value("next_episode").toInt());
    anime->setCountdown(airing.value("countdown").toInt());

    if (anime->getCountdown() > 0) {
      anime->setAiringSchedule(true);
    } else {
      anime->setAiringSchedule(false);
    }
  }

  QJsonArray synonyms = result.value("synonyms").toArray();

  for (int j = 0; j < synonyms.count(); j++) {
    anime->addSynonym(synonyms.at(j).toString());
  }

  anime->finishReload();

  qDebug() << "Loaded extra data for anime" << anime->getTitle();
  db->saveAnime(anime);

  if (!queue.empty()) {
    async_registry.append(QtConcurrent::run([&, this]() {  // NOLINT
      loadNext();
      return 1;
    }));
  }

  return 1;
}
	virtual void update()
	{
		m_anime.update();
	}
	virtual void draw() const override
	{
		//Circle(camera.getDrawPos(m_pos), 20).draw(Palette::Red);
		m_anime.drawAt(D2Camera::I()->getDrawPos(m_pos));
	}