Beispiel #1
0
bool playlist_manager::playlist_update_content(t_size playlist, metadb_handle_list_cref content, bool bUndoBackup) {
	metadb_handle_list old;
	playlist_get_all_items(playlist, old);
	if (old.get_size() == 0) {
		if (content.get_size() == 0) return false;
		if (bUndoBackup) playlist_undo_backup(playlist);
		playlist_add_items(playlist, content, bit_array_false());
		return true;
	}
	pfc::avltree_t<metadb_handle::nnptr> itemsOld, itemsNew;

	for(t_size walk = 0; walk < old.get_size(); ++walk) itemsOld += old[walk];
	for(t_size walk = 0; walk < content.get_size(); ++walk) itemsNew += content[walk];
	bit_array_bittable removeMask(old.get_size());
	bit_array_bittable filterMask(content.get_size());
	bool gotNew = false, filterNew = false, gotRemove = false;
	for(t_size walk = 0; walk < content.get_size(); ++walk) {
		const bool state = !itemsOld.have_item(content[walk]);
		if (state) gotNew = true;
		else filterNew = true;
		filterMask.set(walk, state);
	}
	for(t_size walk = 0; walk < old.get_size(); ++walk) {
		const bool state = !itemsNew.have_item(old[walk]);
		if (state) gotRemove = true;
		removeMask.set(walk, state);
	}
	if (!gotNew && !gotRemove) return false;
	if (bUndoBackup) playlist_undo_backup(playlist);
	if (gotRemove) {
		playlist_remove_items(playlist, removeMask);
	}
	if (gotNew) {
		if (filterNew) {
			metadb_handle_list temp(content);
			temp.filter_mask(filterMask);
			playlist_add_items(playlist, temp, bit_array_false());
		} else {
			playlist_add_items(playlist, content, bit_array_false());
		}
	}

	{
		playlist_get_all_items(playlist, old);
		pfc::array_t<t_size> order;
		if (pfc::guess_reorder_pattern<pfc::list_base_const_t<metadb_handle_ptr> >(order, old, content)) {
			playlist_reorder_items(playlist, order.get_ptr(), order.get_size());
		}
	}
	return true;
}
Beispiel #2
0
App::App(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	centralWidget = new QWidget;
	centralLayout = new QVBoxLayout;

	contentWidget = new QWidget;
	contentLayout = new QGridLayout;

	elapsedTimeLabel = new QLabel("Elapsed time: 0 s");
	elapsedTimeLabel->setFixedSize(300, 15);

	sourceLabel = new QLabel;
	sourceLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	sourceLabel->setScaledContents(true);
	contentLayout->addWidget(sourceLabel, 0, 0);

	maskLabel = new QLabel;
	maskLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	maskLabel->setScaledContents(true);
	contentLayout->addWidget(maskLabel, 0, 1);

	v_disparityLabel = new QLabel;
	v_disparityLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	v_disparityLabel->setScaledContents(true);
	contentLayout->addWidget(v_disparityLabel, 0, 2);

	v_disparity_N_Label = new QLabel;
	v_disparity_N_Label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	v_disparity_N_Label->setScaledContents(true);
	contentLayout->addWidget(v_disparity_N_Label, 2, 2);

	u_disparityLabel = new QLabel;
	u_disparityLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	u_disparityLabel->setScaledContents(true);
	contentLayout->addWidget(u_disparityLabel, 2, 1);

	resultLabel = new QLabel;
	resultLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	resultLabel->setScaledContents(true);
	contentLayout->addWidget(resultLabel, 2, 0);

	contentWidget->setLayout(contentLayout);

	centralLayout->addWidget(elapsedTimeLabel);
	centralLayout->addWidget(contentWidget);
	centralWidget->setLayout(centralLayout);

	setCentralWidget(centralWidget);

	connect(ui.action_Load_default, SIGNAL(triggered()), this, SLOT(loadDefault()));
	connect(ui.action_Load_source, SIGNAL(triggered()), this, SLOT(loadSource()));
	connect(ui.action_Load_mask, SIGNAL(triggered()), this, SLOT(loadMask()));
	connect(ui.action_Remove_mask, SIGNAL(triggered()), this, SLOT(removeMask()));
	connect(ui.action_Save, SIGNAL(triggered()), this, SLOT(saveResult()));
	connect(ui.actionV_Disparity, SIGNAL(triggered()), this, SLOT(v_disparityCall()));
	connect(ui.actionU_Disparity, SIGNAL(triggered()), this, SLOT(u_disparityCall()));
	connect(ui.actionHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(houghLinesV_DispCall()));
	connect(ui.actionPHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(probabilisticHoughLinesV_DispCall()));
	connect(ui.actionCudaHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(cudaHoughLinesV_DispCall()));
	connect(ui.actionCudaPHoughLineV_Disp, SIGNAL(triggered()), this, SLOT(cudaProbabilisticHoughLinesV_DispCall()));
}
Beispiel #3
0
void ParceTask::run()
{
    Result result;
    result.download = parameters.download;

    if ( parameters.download->data().isEmpty() )
    {
        result.err = DataError;
        emit finished(result);
        return;
    }

    if ( parameters.extentions.isEmpty() )
    {
        result.err = ExtentionsError;
        emit finished(result);
        return;
    }

    QString content =
            QTextCodec::codecForHtml(
                parameters.download->data() )->toUnicode(
                parameters.download->data() );
    QStringList urlList;
    QRegExp parceMask;

    if ( parameters.extentions.contains("*") )
        parceMask.setPattern("(href=\"(https?://)?\\S+/\\d+\\.(\\S+)\")+");
    else
        parceMask.setPattern("(href=\"(https?://)?\\S+/\\d+\\.(" + Common::strFromList(parameters.extentions,
                                                                                  "|") + ")\")+");

    QRegExp removeMask("(href=|\"|src=)");
    int pos = 0;

    while ( ( pos = parceMask.indexIn(content, pos) ) != -1 )
    {
        urlList << parceMask.cap(1).remove(removeMask).replace("//", "/");
        QString &s = urlList.last();
        if (!s.contains("://"))
            s.replace(":/", "://");
        pos += parceMask.matchedLength();
    }

    urlList.removeDuplicates();

    if (parameters.download->url().contains("4chan.org"))
    {
        for (int i = 0; i < urlList.size(); ++i)
        {
            if (urlList.at(i).left(2) == "//")
                urlList[i].prepend("http:");
            else if (urlList.at(i).left(1) == "/")
                urlList[i].prepend("http:/");
        }
    }

    QStringList nameList;

    for (int i = 0; i < urlList.count(); ++i)
    {
        nameList << Common::getFileName( urlList.at(i) );
    }

    int i = nameList.count() - 1;

    while (i >= 0)
    {
        int j = i - 1;

        while (j >= 0)
        {
            if ( nameList.at(i) == nameList.at(j) )
            {
                urlList.removeAt(j);
                nameList.removeAt(j);
                --i;
            }

            --j;
        }

        --i;
    }

    QString scheme = QUrl( parameters.download->url() ).scheme();
    QString domain = Common::getHost( parameters.download->url() );

    for (int i = 0; i < urlList.count(); ++i)
    {
        if ( QUrl( urlList.at(i) ).scheme().isEmpty() )
        {
            urlList.replace( i, urlList.value(i).prepend(scheme +
                                                         QString("://") +
                                                         domain) );
        }
    }

    if (!parameters.external)
    {
        int i = urlList.count() - 1;

        while (i >= 0)
        {
            if (Common::getHost( urlList.at(i) ) != domain)
            {
                urlList.removeAt(i);
            }

            --i;
        }
    }
    if (!parameters.replace)
    {
        int i = urlList.count() - 1;
        while (i >= 0)
        {
            if ( QFileInfo( Common::getFileName(urlList.at(i),
                                                parameters.dir) ).exists() )
            {
                result.existingUrls << urlList.at(i);
                urlList.removeAt(i);
            }

            --i;
        }
    }

    if ( !urlList.isEmpty() )
    {
        QDir dir(parameters.dir);

        if ( !dir.exists() )
        {
            dir.mkpath(parameters.dir);
        }
    }

    if (parameters.savePage)
    {
        QStringList auxUrlList;
        QRegExp auxParceMask("((href|src)=\"(https?://)?\\S+\\.(\\S+)\")+");
        int pos = 0;

        while ( ( pos = auxParceMask.indexIn(content, pos) ) != -1 )
        {
            auxUrlList << auxParceMask.cap(1).remove(removeMask);;
            pos += auxParceMask.matchedLength();
        }

        auxUrlList.removeDuplicates();

        if (parameters.download->url().contains("4chan.org"))
        {
            for (int i = 0; i < auxUrlList.size(); ++i)
            {
                if (auxUrlList.at(i).left(2) == "//")
                    auxUrlList[i].prepend("http:");
                else if (auxUrlList.at(i).left(1) == "/")
                    auxUrlList[i].prepend("http:/");
            }
        }

        for (int i = 0; i < auxUrlList.count(); ++i)
        {
            if (auxUrlList.at(i).contains(".html") || auxUrlList.at(i).contains(".htm")
                    || auxUrlList.at(i).endsWith("/"))
                continue;
            QString d = Common::getHost( auxUrlList.at(i) );

            if (!urlList.contains(auxUrlList.at(i)) && (d == domain || QString() == d))
            {
                if ( QUrl( auxUrlList.at(i) ).scheme().isEmpty() )
                    auxUrlList.replace(i, auxUrlList.value(i).prepend(scheme + QString("://") + domain));
                result.auxUrls << auxUrlList.at(i);
            }
        }

        if ( !result.auxUrls.isEmpty() )
        {
            QDir dir(parameters.dir + QDir::separator() +
                     SavePageTask::AUX_FILES_DIR);

            if ( !dir.exists() )
            {
                dir.mkpath(parameters.dir + QDir::separator() +
                           SavePageTask::AUX_FILES_DIR);
            }
        }
    }

    result.newUrls << urlList;
    result.err = NoError;
    emit finished(result);
}