Пример #1
0
void ProfileTest::testRemoveFavorite()
{
	m_profile->removeFavorite(Favorite("tag_1", 20, QDateTime(QDate(2016, 9, 1), QTime(9, 23, 17))));
	m_profile->sync();

	QFile f("tests/resources/favorites.txt");
	f.open(QFile::ReadOnly | QFile::Text);
	QStringList lines = QString(f.readAll()).split("\n", QString::SkipEmptyParts);
	f.close();

	QCOMPARE(lines.count(), 1);
	QCOMPARE(lines[0], Favorite("tag_2", 100, QDateTime(QDate(2016, 10, 1), QTime(12, 23, 17))).toString());
}
Пример #2
0
void ProfileTest::init()
{
	QFile f("tests/resources/favorites.txt");
	f.open(QFile::WriteOnly | QFile::Text);
	f.write(Favorite("tag_1", 20, QDateTime(QDate(2016, 9, 1), QTime(9, 23, 17))).toString().toUtf8() + "\r\n");
	f.write(Favorite("tag_2", 100, QDateTime(QDate(2016, 10, 1), QTime(12, 23, 17))).toString().toUtf8() + "\r\n");
	f.close();

	QFile f2("tests/resources/md5s.txt");
	f2.open(QFile::WriteOnly | QFile::Text);
	f2.write(QString("5a105e8b9d40e1329780d62ea2265d8atests/resources/image_1x1.png\r\n").toUtf8());
	f2.write(QString("ad0234829205b9033196ba818f7a872btests/resources/image_1x1.png\r\n").toUtf8());
	f2.close();

	m_profile = new Profile("tests/resources/");
}
Пример #3
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = favorite;
	favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime());

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ favorite.setImage(img); }
	}
	else if (oldFav.getName() != ui->tagLineEdit->text() && QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
	{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), savePath("thumbs/" + favorite.getName(true) + ".png")); }

	QFile f(savePath("favorites.txt"));
	f.open(QIODevice::ReadOnly);
		QString favorites = f.readAll();
	f.close();

	favorites.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\r\n");
	favorites.remove(oldFav.getName() + "|" + QString::number(oldFav.getNote()) + "|" + oldFav.getLastViewed().toString(Qt::ISODate) + "\r\n");
	favorites += favorite.getName() + "|" + QString::number(favorite.getNote()) + "|" + favorite.getLastViewed().toString(Qt::ISODate) + "\r\n";

	f.open(QIODevice::WriteOnly);
		f.write(favorites.toUtf8());
	f.close();

	emit favoritesChanged();
}
Пример #4
0
void TagTest::testStylishedFavorite()
{
	m_settings->setValue("Coloring/Fonts/favorites", ",8.25,-1,5,50,0,0,0,0,0");
	Tag tag("tag_text", "artist", 123, QStringList() << "related1" << "related2" << "related3");

	QList<Favorite> favorites;
	favorites.append(Favorite("tag_text", 50, QDateTime::currentDateTime()));

	m_profile = new Profile(m_settings, favorites);
	QString actual = tag.stylished(m_profile);
	QString expected = "<a href=\"tag_text\" style=\"color:#ffc0cb; font-family:''; font-size:8pt; font-style:normal; font-weight:400; text-decoration:none;\">tag_text</a>";
	QCOMPARE(actual, expected);
}
Пример #5
0
void TVList::parse_channels_conf(Services services) {
	qDebug("TVList::parse_channels_conf");

	QString file = QDir::homePath() + "/.mplayer/channels.conf.ter";

	if (!QFile::exists(file)) {
		qDebug("VList::parse_channels_conf: %s doesn't exist", file.toUtf8().constData());
		file = QDir::homePath() + "/.mplayer/channels.conf";
	}

	QFile f( file );
	if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
		qDebug("TVList::parse_channels_conf: can't open %s", file.toUtf8().constData());
		return;
	}

	QTextStream in(&f);
	while (!in.atEnd()) {
		QString line = in.readLine();
		qDebug("TVList::parse_channels_conf: '%s'", line.toUtf8().constData());
		QString channel = line.section(':', 0, 0);
		QString video_pid = line.section(':', 10, 10);
		QString audio_pid = line.section(':', 11, 11);
		bool is_radio = (video_pid == "0" && audio_pid != "0");
		bool is_data = (video_pid == "0" && audio_pid == "0");
		bool is_tv = (!is_radio && !is_data);
		if (!channel.isEmpty()) {
			qDebug("TVList::parse_channels_conf: channel: '%s' video_pid: %s audio_pid: %s", channel.toUtf8().constData(),video_pid.toUtf8().constData(),audio_pid.toUtf8().constData());
			QString channel_id = "dvb://"+channel;
			if (findFile(channel_id) == -1) {
				if ( (services.testFlag(TVList::TV) && is_tv) || 
                     (services.testFlag(TVList::Radio) && is_radio) || 
                     (services.testFlag(TVList::Data) && is_data) )
				{
					f_list.append( Favorite(channel, channel_id) );
				}
			}
		}
	}
}
Пример #6
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = m_favorite;

	// Update monitors
	int interval = ui->spinMonitoringInterval->value() * 60;
	Site *site = m_profile->getSites().value(ui->comboMonitoringSource->currentText());
	QList<Monitor> monitors = oldFav.getMonitors();
	if (interval == 0)
	{ monitors.clear(); }
	else if (monitors.isEmpty())
	{ monitors.append(Monitor(site, interval, QDateTime::currentDateTimeUtc())); }
	else
	{
		Monitor rep(site, interval, monitors[0].lastCheck());
		monitors[0] = rep;
	}

	m_favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime(), monitors);
	m_favorite.setImagePath(savePath("thumbs/" + m_favorite.getName(true) + ".png"));

	if (oldFav.getName() != m_favorite.getName())
	{
		if (QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
		{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), m_favorite.getImagePath()); }
		m_profile->removeFavorite(oldFav);
	}

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ m_favorite.setImage(img); }
	}
	m_profile->addFavorite(m_favorite);
}
Пример #7
0
void RomInfo::SaveToDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());

    bool inserting = false;

    if (m_id == 0)
        inserting = true;

    if (inserting)
    {
        LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding %1 - %2").arg(Rompath())
            .arg(Romname()));

        query.prepare("INSERT INTO gamemetadata "
                      "(system, romname, gamename, genre, year, gametype, "
                      "rompath, country, crc_value, diskcount, display, plot, "
                      "publisher, version, fanart, boxart, screenshot) "
                      "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
                      ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, "
                      ":PUBLISHER, :VERSION, :FANART, :BOXART, :SCREENSHOT)");

        query.bindValue(":SYSTEM",System());
        query.bindValue(":ROMNAME",Romname());
        query.bindValue(":GAMENAME",Gamename());
        query.bindValue(":GENRE",Genre());
        query.bindValue(":YEAR",Year());
        query.bindValue(":GAMETYPE",GameType());
        query.bindValue(":ROMPATH",Rompath());
        query.bindValue(":COUNTRY",Country());
        query.bindValue(":CRC32", QString());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":VERSION", Version());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":SCREENSHOT", Screenshot());
    }
    else
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());
    }

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::SaveToDatabase", query);
        return;
    }
}
Пример #8
0
void RomInfo::UpdateDatabase()
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("SELECT gamename,genre,year,country,plot,publisher, "
                  "favorite,screenshot,fanart,boxart,inetref "
                  "FROM gamemetadata "
                  "WHERE gametype = :GAMETYPE "
                  "AND romname = :ROMNAME");

    query.bindValue(":GAMETYPE", GameType());
    query.bindValue(":ROMNAME", Romname());

    if (!query.exec())
    {
        MythDB::DBError("RomInfo::UpdateDatabase", query);
        return;
    }

    if (!query.next())
        return;

    QString t_gamename  = query.value(0).toString();
    QString t_genre     = query.value(1).toString();
    QString t_year      = query.value(2).toString();
    QString t_country   = query.value(3).toString();
    QString t_plot      = query.value(4).toString();
    QString t_publisher = query.value(5).toString();
    bool    t_favourite = query.value(6).toBool();
    QString t_screenshot = query.value(7).toString();
    QString t_fanart = query.value(8).toString();
    QString t_boxart = query.value(9).toString();
    QString t_inetref = query.value(10).toString();

    if ((t_gamename  != Gamename())  || (t_genre     != Genre())   ||
            (t_year      != Year())      || (t_country   != Country()) ||
            (t_plot      != Plot())      || (t_publisher != Publisher()) ||
            (t_favourite != Favorite())  || (t_screenshot != Screenshot()) ||
            (t_fanart    != Fanart())    || (t_boxart    != Boxart()) ||
            (t_inetref   != Inetref()))
    {
        query.prepare("UPDATE gamemetadata "
                      "SET version = 'CUSTOM', "
                      "    gamename = :GAMENAME,"
                      "    genre = :GENRE,"
                      "    year = :YEAR,"
                      "    country = :COUNTRY,"
                      "    plot = :PLOT,"
                      "    publisher = :PUBLISHER,"
                      "    favorite = :FAVORITE,"
                      "    screenshot = :SCREENSHOT,"
                      "    fanart = :FANART,"
                      "    boxart = :BOXART, "
                      "    inetref = :INETREF "
                      "WHERE gametype = :GAMETYPE AND "
                      "      romname  = :ROMNAME");
        query.bindValue(":GAMENAME", Gamename());
        query.bindValue(":GENRE", Genre());
        query.bindValue(":YEAR", Year());
        query.bindValue(":COUNTRY", Country());
        query.bindValue(":PLOT", Plot());
        query.bindValue(":PUBLISHER", Publisher());
        query.bindValue(":FAVORITE", Favorite());
        query.bindValue(":SCREENSHOT", Screenshot());
        query.bindValue(":FANART", Fanart());
        query.bindValue(":BOXART", Boxart());
        query.bindValue(":INETREF", Inetref());
        query.bindValue(":GAMETYPE", GameType());
        query.bindValue(":ROMNAME", Romname());

        if (!query.exec())
        {
            MythDB::DBError("RomInfo::UpdateDatabase", query);
            return;
        }
    }
}