Exemplo n.º 1
0
void Image::preload(const Filename &filename)
{
	if (!filename.needExactTags(m_parentSite))
		return;

	QEventLoop loop;
	QObject::connect(this, &Image::finishedLoadingTags, &loop, &QEventLoop::quit);
	loadDetails();
	loop.exec();
}
Exemplo n.º 2
0
void Image::parseDetails()
{
	m_loadingDetails = false;

	// Aborted
	if (m_loadDetails->error() == QNetworkReply::OperationCanceledError)
	{
		m_loadDetails->deleteLater();
		m_loadDetails = nullptr;
		return;
	}

	// Check redirection
	QUrl redir = m_loadDetails->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
	if (!redir.isEmpty())
	{
		m_pageUrl = redir;
		loadDetails();
		return;
	}

	int statusCode = m_loadDetails->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
	if (statusCode == 429)
	{
		log(QStringLiteral("Details limit reached (429). New try."));
		loadDetails(true);
		return;
	}

	QString source = QString::fromUtf8(m_loadDetails->readAll());

	// Get an api able to parse details
	Api *api = m_parentSite->detailsApi();
	if (api == Q_NULLPTR)
		return;

	// Parse source
	ParsedDetails ret = api->parseDetails(source, m_parentSite);
	if (!ret.error.isEmpty())
	{
		log(QStringLiteral("[%1][%2] %3").arg(m_parentSite->url(), api->getName(), ret.error), Logger::Warning);
		emit finishedLoadingTags();
		return;
	}

	// Fill data from parsing result
	if (!ret.pools.isEmpty())
	{ m_pools = ret.pools; }
	if (!ret.tags.isEmpty())
	{ m_tags = ret.tags; }
	if (ret.createdAt.isValid())
	{ m_createdAt = ret.createdAt; }

	// Image url
	if (!ret.imageUrl.isEmpty())
	{
		QString before = m_url;

		QUrl newUrl = m_parentSite->fixUrl(ret.imageUrl, before);
		m_url = newUrl.toString();
		m_fileUrl = newUrl;

		if (before != m_url)
		{
			delete m_extensionRotator;
			m_extensionRotator = nullptr;
			setFileSize(0);
			emit urlChanged(before, m_url);
		}
	}

	// Get rating from tags
	if (m_rating.isEmpty())
	{
		int ratingTagIndex = -1;
		for (int it = 0; it < m_tags.count(); ++it)
		{
			if (m_tags[it].type().name() == "rating")
			{
				m_rating = m_tags[it].text();
				ratingTagIndex = it;
				break;
			}
		}
		if (ratingTagIndex != -1)
		{ m_tags.removeAt(ratingTagIndex); }
	}

	m_loadDetails->deleteLater();
	m_loadDetails = nullptr;
	m_loadedDetails = true;

	refreshTokens();

	emit finishedLoadingTags();
}
Exemplo n.º 3
0
void HAnalyze_a::getData()
{


    ID= ui->cbProdotti->model()->index(ui->cbProdotti->currentIndex(),0).data(0).toString();
    QString what;
    QString d =" and lotdef.data BETWEEN '" + ui->dateDal->date().toString("yyyy-MM-dd") + "' AND '" + ui->dateAl->date().toString("yyyy-MM-dd")+"'";
    QString condiz1;
    QString from="FROM lotdef where";
    QString group=" group by lotdef.lot ";
    QString idProdotto;

// "tipi prodotto"

    if (ui->rbProdotti->isChecked())
    {
        condiz1= " prodotto=" + ID + d + " ";
    }
    else
    {
       condiz1=" anagrafica="+ID+ d +" and lotdef.EAN IS  NOT NULL and lotdef.EAN !=''";
    }

    if(ui->rbAll->isChecked())
    {
        filter="";
    }
    else if (ui->rbMateriePrime->isChecked())
    {
        filter = " and lotdef.tipo=0 ";

    }
    else if (ui->rbSemilavorati->isChecked())
    {
        filter= " and lotdef.tipo=1 ";
    }
    else if (ui->rbProdottiFiniti->isChecked())
    {
        filter=" and lotdef.tipo=2";
    }
    else if (ui->rbPackage->isChecked())
    {
        filter=" and lotdef.tipo=3 ";
        from="FROM lotdef where";
    }

 // filtra per prodotto selezionato

    if(ui->pbFilter->isChecked())
    {
        idProdotto=ui->lvWhat->model()->index(ui->lvWhat->currentIndex().row(), 0).data(0).toString();
    }
    else
    {
        idProdotto="";
    }


 //lotto interno o lotto esterno?
    if (ui->rbLin->isChecked())
    {
        what="SELECT lotdef.ID,lotdef.lot,prodotti.descrizione ";
        from=" FROM lotdef,prodotti where ";
        condiz1=" anagrafica="+ID+" and lotdef.EAN IS NOT NULL and prodotti.ID=lotdef.prodotto and lotdef.tipo=2 ";
    }
    else if (ui->rbLes->isChecked())
    {
        what ="select lotdef.ID,lotdef.EAN,lotdef.lot,prodotti.descrizione";
        from=" FROM lotdef, prodotti where";
        condiz1=" anagrafica="+ID+" and lotdef.EAN IS NOT NULL and prodotti.ID=lotdef.prodotto";

        if(ui->pbFilter->isChecked())
        {
             condiz1=" anagrafica="+ID+" and lotdef.EAN IS NOT NULL and prodotti.ID=lotdef.prodotto and lotdef.prodotto="+idProdotto;
        }
         getProductsForClientsInRange();
    }


    QSqlQuery q(db);
    QString query = what + from + condiz1 + filter + d + group + "order by data desc" ;
    q.exec(query);

    qmMain->setQuery(q);
    ui->tvMain->setModel(qmMain);



    //// qDebug()<<"QUERYYYY:"<<query<<q.lastError().text();
  //  ui->tvMain->setModelColumn(0);

    ui->tvMain->resizeColumnsToContents();
    ui->tvMain->horizontalHeader()->resizeSections(QHeaderView::Stretch);
    ui->tvMain->horizontalHeader()->stretchLastSection();



    if(ui->rbLes->isChecked())
    {
        lot=ui->tvMain->model()->index(ui->tvMain->currentIndex().row(),1).data(0).toString();
    }
    else
    {
        lot=ui->tvMain->model()->index(ui->tvMain->currentIndex().row(),0).data(0).toString();
    }

    loadDetails(lot);

}
Exemplo n.º 4
0
void HAnalyze_a::setConnectionName(QString conn)
{
    sConn=conn;
    //qui inizializzo la form
     ui->dateDal->setDate(QDate::currentDate().addMonths(-6));
     ui->dateAl->setDate(QDate::currentDate());
     zeromodel=new QSqlQueryModel();
     ui->lvWhat->setVisible(false);
    // ui->pbFilter->setVisible(false);

    db=QSqlDatabase::database(sConn);

    tmProdotti=new QSqlTableModel(0,db);

    tmProdotti->setTable("prodotti");
    tmProdotti->setSort(1,Qt::AscendingOrder);


    tmProdotti->select();
    tmProdotti->setFilter("tipo=1");

    tmAnagrafica=new QSqlTableModel(0,db);
    tmAnagrafica->setTable("anagrafica");
    tmAnagrafica->setFilter("cliente=1");
    tmAnagrafica->setSort(1,Qt::AscendingOrder);
    tmAnagrafica->select();

    qmMain=new QSqlQueryModel();

//    connect(ui->cbProdotti,SIGNAL(currentIndexChanged(QString)),this,SLOT(requestData()));

    connect(ui->rbMateriePrime,SIGNAL(toggled(bool)),this,SLOT(radioToggled()));
    connect(ui->rbSemilavorati,SIGNAL(toggled(bool)),this,SLOT(radioToggled()));
    connect(ui->rbProdottiFiniti,SIGNAL(toggled(bool)),this,SLOT(radioToggled()));
    connect(ui->rbAll,SIGNAL(toggled(bool)),this,SLOT(radioToggled()));
    connect(ui->rbPackage,SIGNAL(toggled(bool)),this,SLOT(radioToggled()));

    connect(ui->rbProdotti,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbAnagrafica,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbAnagrafica,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbProdotti,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbAnagrafica,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbLes,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->rbLin,SIGNAL(toggled(bool)),this,SLOT(requestData()));
    connect(ui->pbFilter,SIGNAL(toggled(bool)),this,SLOT(requestData()));


    ui->cbProdotti->setModel(tmAnagrafica);
    ui->cbProdotti->setModelColumn(1);

    ui->cbProdotti->setCurrentIndex(0);

    connect(ui->cbProdotti,SIGNAL(currentIndexChanged(QString)),this,SLOT(getData()));
    connect(ui->tvMain->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),SLOT(getData()));
    connect(ui->tableView->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(loadDetails(QString)));


}
Exemplo n.º 5
0
void Clock::Timer::load(const QSettings& game) {
	m_time = qMax(0, game.value("TimerDetails/Time", m_time).toInt()) + 1;
	loadDetails(game);
}