Пример #1
0
void RatingComboBoxWidget::setRatingValue(RatingComboBox::RatingValue value)
{
    if (m_value == value)
    {
        return;
    }

    m_value = value;

    // sync with base class
    blockSignals(true);

    if (m_value >= RatingComboBox::Rating0)
    {
        setRating(value);
    }
    else
    {
        setRating(0);
    }

    blockSignals(false);

    update();
    emit ratingValueChanged(m_value);
}
Пример #2
0
void RatingFilterWidget::mousePressEvent(QMouseEvent* e)
{
    // This method must be re-implemented to handle which mouse button is pressed
    // and show the rating filter settings pop-up menu with right mouse button.
    // NOTE: Left and Middle Mouse buttons continue to change rating filter value.

    d->dirty = false;

    if ( e->button() == Qt::LeftButton || e->button() == Qt::MidButton )
    {
        d->dirty = true;
        int pos  = e->x() / regPixmapWidth() +1;

        if (rating() == pos)
        {
            setRating(rating()-1);
        }
        else
        {
            setRating(pos);
        }

        updateRatingTooltip();
    }
}
Пример #3
0
bool Media::setValueForRole(int role, const QVariant& value)
{
    switch (role) {
        case MediaCenter::MediaTypeRole:
            return setType(value.toString());
        case Qt::DisplayRole:
            return setTitle(value.toString());
        case MediaCenter::MediaUrlRole:
            if (d->url != value.toString()) {
                qDebug() << d->url << value.toString();
                qFatal("Media URLs CANNOT be changed");
            }
            return false;
        case Qt::DecorationRole:
            return thumbnail().isEmpty() ? setThumbnail(value.toString()) : false;
        case MediaCenter::CreatedAtRole:
            return setCreatedAt(value.toDateTime());
        case MediaCenter::GenreRole:
            return setGenre(value.toString());
        case MediaCenter::DurationRole :
            return setDuration(value.toInt());
        case MediaCenter::RatingRole :
            return setRating(value.toInt());
        default:
            //qWarning() << "Unknown role " << role << " for value " << value;
            return false;
    }
}
Пример #4
0
bool EPGItem::setData( vlc_epg_event_t *data )
{
    QDateTime newtime = QDateTime::fromTime_t( data->i_start );
    QString newname = qfu( data->psz_name );
    QString newdesc = qfu( data->psz_description );
    QString newshortdesc = qfu( data->psz_short_description );

    if ( m_start != newtime ||
         m_name != newname ||
         m_description != newdesc ||
         m_shortDescription != newshortdesc ||
         m_duration != data->i_duration )
    {
        m_start = newtime;
        m_name = newname;
        setToolTip( newname );
        m_description = newdesc;
        m_shortDescription = newshortdesc;
        setDuration( data->i_duration );
        setRating( data->i_rating );
        update();
        return true;
    }
    return false;
}
Пример #5
0
ViRatingWidget::ViRatingWidget(QWidget *parent)
	: ViWidget(parent)
{
	mNormalWidget = new QWidget(this);
	mNormalLayout = new QHBoxLayout(mNormalWidget);
	mNormalLayout->setContentsMargins(0, 0, 0, 0);
	mNormalLayout->setSpacing(0);
	for(int i = 0; i < NUMBER_OF_STARS; ++i)
	{
		ViRatingItem *star = new ViRatingItem(this);
		mNormalStars.append(star);
		mNormalLayout->addWidget(star);
	}

	mGrayWidget = new QWidget(this);
	mGrayLayout = new QHBoxLayout(mGrayWidget);
	mGrayLayout->setContentsMargins(0, 0, 0, 0);
	mGrayLayout->setSpacing(0);
	for(int i = 0; i < NUMBER_OF_STARS; ++i)
	{
		ViRatingItem *star = new ViRatingItem(this, true);
		mGrayStars.append(star);
		mGrayLayout->addWidget(star);
	}

	mSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
	mLayout = new QHBoxLayout(this);
	mLayout->setContentsMargins(0, 0, 0, 0);
	mLayout->setSpacing(0);
	mLayout->addWidget(mNormalWidget);
	mLayout->addWidget(mGrayWidget);
	mLayout->addSpacerItem(mSpacer);

	setRating(0);
}
Пример #6
0
bool EPGItem::setData( const vlc_epg_event_t *data )
{
    QDateTime newtime = QDateTime::fromTime_t( data->i_start );
    QString newname = qfu( data->psz_name );
    QString newdesc = qfu( data->psz_description );
    QString newshortdesc = qfu( data->psz_short_description );

    if ( m_start != newtime ||
         m_name != newname ||
         m_description != newdesc ||
         m_shortDescription != newshortdesc ||
         m_duration != data->i_duration )
    {
        m_start = newtime;
        m_name = newname;
        setToolTip( newname );
        m_description = newdesc;
        m_shortDescription = newshortdesc;
        setDuration( data->i_duration );
        setRating( data->i_rating );
        m_descitems.clear();
        for( int i=0; i<data->i_description_items; i++ )
        {
            m_descitems.append(QPair<QString, QString>(
                                  QString(data->description_items[i].psz_key),
                                  QString(data->description_items[i].psz_value)));
        }
        updatePos();
        prepareGeometryChange();
        return true;
    }
    return false;
}
Пример #7
0
TierRatingButton::TierRatingButton(const QString &tier, int rating)
    : ui(new Ui::TierRatingButton)
{
    ui->setupUi(this);

    setTier(tier);
    setRating(rating);
}
Пример #8
0
RatingWidget::RatingWidget() {
	//setMouseTracking(true);
	setFixedSize(120, 20);
	image = QImage(":/images/ratingImage.png");
	starOn = QImage(":/images/star_on.png");
	starOff = QImage(":/images/star_off.png");
	setRating(0);
}
Пример #9
0
void
OSDWidget::ratingChanged( const short rating )
{
    m_text = '\n' + i18n( "Rating changed" );
    setRating( rating ); //Checks isEnabled() before doing anything

    show();
}
Пример #10
0
void
Amarok::OSD::paused()
{
    setImage( QImage( KIconLoader::global()->iconPath( "amarok", -KIconLoader::SizeHuge ) ) );
    setRating( 0 ); // otherwise stars from last rating change are visible
    OSDWidget::show( i18n( "Paused" ) );
    setPaused(true);
}
Пример #11
0
winery::winery(const winery& aWinery) :name(NULL), location(NULL), year(DEFAULT_YEAR), acres(0), rating(0.0)
{
    setName(aWinery.name);
    setLocation(aWinery.location);
    setYear(aWinery.year);
    setAcres(aWinery.acres);
    setRating(aWinery.rating);
}
Пример #12
0
//copy constructor for the text object
text::text(const text &textSource){

    //copy all of the items over from the source to the
    //current object
    setTitle(textSource.getTitle());
    setAuthor(textSource.getAuthor());
    setRating(textSource.getRating());
    setKeyword(textSource.getKeyword());
    strcpy(response, textSource.getResponse());
   
}
Пример #13
0
Movie::Movie(int id, QString title, QString file, QString thumbnailsFile, QString descr, QString posterFile, int rating, QString year){
    setId(id);
    setTitle(title);
    setFile(file);
    setThumbsFile(thumbnailsFile);
    setDescr(descr);
    setPosterFile(posterFile);
    setRating(rating);
    setYear(year);
    setChanged(false);
}
Пример #14
0
Movie::Movie(){
    setId(0);
    setTitle("");
    setFile("");
    setThumbsFile("");
    setDescr("");
    setPosterFile("posterFile");
    setRating(0);
    setYear("year");
    setChanged(false);
}
Пример #15
0
void
Amarok::OSD::show( Meta::TrackPtr track ) //slot
{
    setAlignment( static_cast<OSDWidget::Alignment>( AmarokConfig::osdAlignment() ) );
    setOffset( AmarokConfig::osdYOffset() );

    QString text;
    if( !track || track->playableUrl().isEmpty() )
    {
        text = i18n( "No track playing" );
        setRating( 0 ); // otherwise stars from last rating change are visible
    }
    else
    {
        setRating( track->rating() );
        text = track->prettyName();
        if( track->artist() && !track->artist()->prettyName().isEmpty() )
            text = track->artist()->prettyName() + " - " + text;
        if( track->album() && !track->album()->prettyName().isEmpty() )
            text += "\n (" + track->album()->prettyName() + ") ";
        else
            text += '\n';
        if( track->length() > 0 )
            text += Meta::msToPrettyTime( track->length() );
    }

    if( text.isEmpty() )
        text =  track->playableUrl().fileName();

    if( text.startsWith( "- " ) ) //When we only have a title tag, _something_ prepends a f*****g hyphen. Remove that.
        text = text.mid( 2 );

    if( text.isEmpty() ) //still
        text = i18n("No information available for this track");

    QImage image;
    if( track && track->album() )
        image = The::svgHandler()->imageWithBorder( track->album(), 100, 5 ).toImage();

    OSDWidget::show( text, image );
}
Пример #16
0
void RatingFilterWidget::mouseMoveEvent(QMouseEvent* e)
{
    // This method have been re-implemented to display and update the famous TipTracker contents.

    if ( d->dirty )
    {
        int pos = e->x() / regPixmapWidth() +1;

        if (rating() != pos)
        {
            setRating(pos);
        }

        updateRatingTooltip();
    }
}
Пример #17
0
Book::Book(const string& aName,
           int aCode,
           double aPrice,
           int aRating,
           const string& aComment,
           const string& aAuthor,
           const string& aTitle,
           const string& aIsbn) :
author(aAuthor), title(aTitle), isbn(aIsbn) // eigene Attribute 
{
  setName(aName);            // Attribute der Basisklasse
  setCode(aCode);
  setPrice(aPrice);
  setRating(aRating);
  setComment(aComment);
}
    //-------------------------------------------------------------------------
    //! @brief Factory method to create a Simplealue model and assign it to
    //! retrieve the path to the next photo to display.
    //! @returns a shared pointer to the SimpleValue.
    //-------------------------------------------------------------------------
    static std::shared_ptr< IModel > const createRatingStar( unsigned int _rating )
    {
        auto photo_mgr = Factory< IPhotoManager >::get( "PhotoManager" );

        std::function< void() > command_fn( [=](){ photo_mgr->setRating( _rating ); } );
        std::function< bool() > retrieve_fn( [=](){ return ( _rating <= photo_mgr->getRating() ); } );

        std::shared_ptr< IModel > model( new Toggle( String( "buttons/modern/star/full.png" )
                                                   , String( "buttons/modern/star/empty.png" )
                                                   , retrieve_fn
                                                   , command_fn
                                                   , photo_mgr->getSignal()
                                                   , std::static_pointer_cast< ITech >( photo_mgr ) ) );

        return model;
    }
Пример #19
0
const winery& winery::operator=(const winery& aWinery)
{
    //if it is a self copy don't do anything
    if(this == &aWinery)
        return *this;
    //make current object *this a copy of the passed in winery
    else
    {
        setName(aWinery.name);
        setLocation(aWinery.location);
        setYear(aWinery.year);
        setAcres(aWinery.acres);
        setRating(aWinery.rating);
        return *this;
    }
}
Пример #20
0
void LibFile::setProperty(fwk::PropertyIndex idx, int32_t v)
{
    switch(idx) {
    case NpTiffOrientationProp:
        setOrientation(v);
        break;
    case NpXmpRatingProp:
        setRating(v);
        break;
    case NpXmpLabelProp:
        setLabel(v);
        break;
    case NpNiepceFlagProp:
        setFlag(v);
        break;
    default:
        ERR_OUT("set property %u not handled", idx);
        break;
    }
}
Пример #21
0
void RatingWidget::mousePressEvent(QMouseEvent *event) {
	QPoint point = event->pos();
	if (point.x() < 20) {
		setRating(0);
	} else if (point.x() < 40) {
		setRating(1);
	} else if (point.x() < 60) {
		setRating(2);
	} else if (point.x() < 80) {
		setRating(3);
	} else if (point.x() < 100) {
		setRating(4);
	} else if (point.x() < 120) {
		setRating(5);
	}
	((ImageWidget*) parent())->updateRating(getRating());
}
Пример #22
0
void ImportMusicDialog::showMenu()
{
    if (m_popupMenu)
        return;

    if (m_tracks->size() == 0)
        return;

    MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

    MythDialogBox *menu = new MythDialogBox("", popupStack, "importmusicmenu");

    if (menu->Create())
        popupStack->AddScreen(menu);
    else
    {
        delete menu;
        return;
    }

    menu->SetReturnEvent(this, "menu");
    menu->AddButton(tr("Save Defaults"), SLOT(saveDefaults()));

    if (m_haveDefaults)
    {
        menu->AddButton(tr("Change Compilation Flag"), SLOT(setCompilation()));
        menu->AddButton(tr("Change Compilation Artist"),
                                SLOT(setCompilationArtist()));
        menu->AddButton(tr("Change Artist"), SLOT(setArtist()));
        menu->AddButton(tr("Change Album"), SLOT(setAlbum()));
        menu->AddButton(tr("Change Genre"), SLOT(setGenre()));
        menu->AddButton(tr("Change Year"), SLOT(setYear()));
        menu->AddButton(tr("Change Rating"), SLOT(setRating()));
    }

    menu->AddButton(tr("Cancel"));
}
Пример #23
0
void Mechanoid::setRatingLevel(int level, RatingType type)
{
    setRating(_setRatingLevel(level), type);
}
Пример #24
0
Player::Player()
{
  setRating(Initial_Rating);
  setRd(Initial_Diviation);
  volatility = Initial_Volatility;
}
Пример #25
0
Player::Player(float R, float RD, float Vol)
{
  setRating(R);
  setRd(RD);
  volatility = Vol;
}
Пример #26
0
bool ImportMusicDialog::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
        {
            m_prevButton->Push();
        }
        else if (action == "RIGHT")
        {
            m_nextButton->Push();
        }
        else if (action == "EDIT")
        {
            showEditMetadataDialog();
        }
        else if (action == "MENU")
        {
            showMenu();
        }
        else if (action == "1")
        {
            setCompilation();
        }
        else if (action == "2")
        {
            setCompilationArtist();
        }
        else if (action == "3")
        {
            setArtist();
        }
        else if (action == "4")
        {
            setAlbum();
        }
        else if (action == "5")
        {
            setGenre();
        }
        else if (action == "6")
        {
            setYear();
        }
        else if (action == "7")
        {
            setRating();
        }
        else if (action == "8")
        {
            setTitleWordCaps();
        }
        else if (action == "9")
        {
            setTitleInitialCap();
        }
        else if (action == "0")
        {
            setTrack();
        }
        else
            handled = false;
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}
Пример #27
0
	void RatingView::mousePressEvent(QMouseEvent *event) {
		setRating((event->x() / star_width) + 1);
	}
Пример #28
0
Image::Image(Site *site, QMap<QString, QString> details, Profile *profile, Page* parent)
	: m_profile(profile), m_id(0), m_parentSite(site), m_extensionRotator(nullptr)
{
	m_settings = m_profile->getSettings();

	// Parents
	if (m_parentSite == nullptr)
	{
		log(QStringLiteral("Image has nullptr parent, aborting creation."));
		return;
	}

	// Other details
	m_isGallery = details.contains("type") && details["type"] == "gallery";
	m_md5 = details.contains("md5") ? details["md5"] : "";
	m_author = details.contains("author") ? details["author"] : "";
	m_name = details.contains("name") ? details["name"] : "";
	m_status = details.contains("status") ? details["status"] : "";
	m_search = parent != nullptr ? parent->search() : (details.contains("search") ? details["search"].split(' ') : QStringList());
	m_id = details.contains("id") ? details["id"].toULongLong() : 0;
	m_score = details.contains("score") ? details["score"].toInt() : 0;
	m_hasScore = details.contains("score");
	m_parentId = details.contains("parent_id") ? details["parent_id"].toInt() : 0;
	m_fileSize = details.contains("file_size") ? details["file_size"].toInt() : 0;
	m_authorId = details.contains("creator_id") ? details["creator_id"].toInt() : 0;
	m_hasChildren = details.contains("has_children") && details["has_children"] == "true";
	m_hasNote = details.contains("has_note") && details["has_note"] == "true";
	m_hasComments = details.contains("has_comments") && details["has_comments"] == "true";
	m_fileUrl = details.contains("file_url") ? m_parentSite->fixUrl(details["file_url"]) : QUrl();
	m_sampleUrl = details.contains("sample_url") ? m_parentSite->fixUrl(details["sample_url"]) : QUrl();
	m_previewUrl = details.contains("preview_url") ? m_parentSite->fixUrl(details["preview_url"]) : QUrl();
	m_size = QSize(details.contains("width") ? details["width"].toInt() : 0, details.contains("height") ? details["height"].toInt() : 0);
	m_source = details.contains("source") ? details["source"] : "";

	// Page url
	if (details.contains("page_url"))
	{ m_pageUrl = details["page_url"]; }
	else
	{
		Api *api = m_parentSite->detailsApi();
		if (api != Q_NULLPTR)
		{ m_pageUrl = api->detailsUrl(m_id, m_md5, m_parentSite).url; }
	}
	m_pageUrl = site->fixUrl(m_pageUrl).toString();

	// Rating
	setRating(details.contains("rating") ? details["rating"] : "");

	// Tags
	QStringList types = QStringList() << "general" << "artist" << "character" << "copyright" << "model" << "species" << "meta";
	for (const QString &typ : types)
	{
		QString key = "tags_" + typ;
		if (!details.contains(key))
			continue;

		TagType ttype(typ);
		QStringList t = details[key].split(' ', QString::SkipEmptyParts);
		for (QString tg : t)
		{
			tg.replace("&amp;", "&");
			m_tags.append(Tag(tg, ttype));
		}
	}
	if (m_tags.isEmpty() && details.contains("tags"))
	{
		QString tgs = QString(details["tags"]).replace(QRegularExpression("[\r\n\t]+"), " ");

		// Automatically find tag separator and split the list
		int commas = tgs.count(", ");
		int spaces = tgs.count(" ");
		const QStringList &t = commas >= 10 || (commas > 0 && (spaces - commas) / commas < 2)
			? tgs.split(", ", QString::SkipEmptyParts)
			: tgs.split(" ", QString::SkipEmptyParts);

		for (QString tg : t)
		{
			tg.replace("&amp;", "&");

			int colon = tg.indexOf(':');
			if (colon != -1)
			{
				QString tp = tg.left(colon).toLower();
				if (tp == "user")
				{ m_author = tg.mid(colon + 1); }
				else if (tp == "score")
				{ m_score = tg.midRef(colon + 1).toInt(); }
				else if (tp == "size")
				{
					QStringList size = tg.mid(colon + 1).split('x');
					if (size.size() == 2)
						m_size = QSize(size[0].toInt(), size[1].toInt());
				}
				else if (tp == "rating")
				{ setRating(tg.mid(colon + 1)); }
				else
				{ m_tags.append(Tag(tg)); }
			}
			else
			{ m_tags.append(Tag(tg)); }
		}
	}

	// Complete missing tag type information
	m_parentSite->tagDatabase()->load();
	QStringList unknownTags;
	for (Tag const &tag : qAsConst(m_tags))
		if (tag.type().name() == "unknown")
			unknownTags.append(tag.text());
	QMap<QString, TagType> dbTypes = m_parentSite->tagDatabase()->getTagTypes(unknownTags);
	for (Tag &tag : m_tags)
		if (dbTypes.contains(tag.text()))
			tag.setType(dbTypes[tag.text()]);

	// Get file url and try to improve it to save bandwidth
	m_url = m_fileUrl.toString();
	QString ext = getExtension(m_url);
	if (details.contains("ext") && !details["ext"].isEmpty())
	{
		QString realExt = details["ext"];
		if (ext != realExt)
		{ setFileExtension(realExt); }
	}
	else if (ext == QLatin1String("jpg") && !m_previewUrl.isEmpty())
	{
		bool fixed = false;
		QString previewExt = getExtension(details["preview_url"]);
		if (!m_sampleUrl.isEmpty())
		{
			// Guess extension from sample url
			QString sampleExt = getExtension(details["sample_url"]);
			if (sampleExt != QLatin1String("jpg") && sampleExt != QLatin1String("png") && sampleExt != ext && previewExt == ext)
			{
				m_url = setExtension(m_url, sampleExt);
				fixed = true;
			}
		}

		// Guess the extension from the tags
		if (!fixed)
		{
			if ((hasTag(QStringLiteral("swf")) || hasTag(QStringLiteral("flash"))) && ext != QLatin1String("swf"))
			{ setFileExtension(QStringLiteral("swf")); }
			else if ((hasTag(QStringLiteral("gif")) || hasTag(QStringLiteral("animated_gif"))) && ext != QLatin1String("webm") && ext != QLatin1String("mp4"))
			{ setFileExtension(QStringLiteral("gif")); }
			else if (hasTag(QStringLiteral("mp4")) && ext != QLatin1String("gif") && ext != QLatin1String("webm"))
			{ setFileExtension(QStringLiteral("mp4")); }
			else if (hasTag(QStringLiteral("animated_png")) && ext != QLatin1String("webm") && ext != QLatin1String("mp4"))
			{ setFileExtension(QStringLiteral("png")); }
			else if ((hasTag(QStringLiteral("webm")) || hasTag(QStringLiteral("animated"))) && ext != QLatin1String("gif") && ext != QLatin1String("mp4"))
			{ setFileExtension(QStringLiteral("webm")); }
		}
	}
	else if (details.contains("image") && details["image"].contains("MB // gif\" height=\"") && !m_url.endsWith(".gif", Qt::CaseInsensitive))
	{ m_url = setExtension(m_url, QStringLiteral("gif")); }

	// Remove ? in urls
	m_url = removeCacheUrl(m_url);
	m_fileUrl = removeCacheUrl(m_fileUrl.toString());
	m_sampleUrl = removeCacheUrl(m_sampleUrl.toString());
	m_previewUrl = removeCacheUrl(m_previewUrl.toString());

	// We use the sample URL as the URL for zip files (ugoira) or if the setting is set
	bool downloadOriginals = m_settings->value("Save/downloadoriginals", true).toBool();
	if (!m_sampleUrl.isEmpty() && (getExtension(m_url) == "zip" || !downloadOriginals))
		m_url = m_sampleUrl.toString();

	// Creation date
	m_createdAt = QDateTime();
	if (details.contains("created_at"))
	{ m_createdAt = qDateTimeFromString(details["created_at"]); }
	else if (details.contains("date"))
	{ m_createdAt = QDateTime::fromString(details["date"], Qt::ISODate); }

	// Setup extension rotator
	bool animated = hasTag("gif") || hasTag("animated_gif") || hasTag("mp4") || hasTag("animated_png") || hasTag("webm") || hasTag("animated");
	QStringList extensions = animated
		? QStringList() << "webm" << "mp4" << "gif" << "jpg" << "png" << "jpeg" << "swf"
		: QStringList() << "jpg" << "png" << "gif" << "jpeg" << "webm" << "swf" << "mp4";
	m_extensionRotator = new ExtensionRotator(getExtension(m_url), extensions, this);

	// Tech details
	m_parent = parent;
	m_loadDetails = nullptr;
	m_loadImage = nullptr;
	m_loadingPreview = false;
	m_loadingDetails = false;
	m_loadedDetails = false;
	m_loadedImage = false;
	m_loadingImage = false;
	m_tryingSample = false;
	m_pools = QList<Pool>();
}