Пример #1
0
		dtn::data::Number Clock::__getExpireTime(const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime)
		{
			// if our own clock or the bundles timestamp is invalid use the current timestamp
			if ((getRating() == 0.0) || timestamp == 0) return getTime() + lifetime;

			return timestamp + lifetime;
		}
Пример #2
0
void PublicHubsFrame::updateList()
{
	//CLockRedraw<> l_lock_draw(m_ctrlHubs);
	m_ctrlHubs.DeleteAllItems();
	users = 0;
	visibleHubs = 0;
	
	double size = -1;
	FilterModes mode = NONE;
	
	int sel = ctrlFilterSel.GetCurSel();
	
	bool doSizeCompare = parseFilter(mode, size);
	
	auto cnt = m_ctrlHubs.GetItemCount();
	for (auto i = m_hubs.cbegin(); i != m_hubs.cend(); ++i)
	{
		if (matchFilter(*i, sel, doSizeCompare, mode, size))
		{
			TStringList l;
			l.resize(COLUMN_LAST);
			l[COLUMN_NAME] = Text::toT(i->getName());
			string l_description = i->getDescription();
			boost::replace_all(l_description, ".px.", "");
			l[COLUMN_DESCRIPTION] = Text::toT(l_description);
			l[COLUMN_USERS] = Util::toStringW(i->getUsers());
			l[COLUMN_SERVER] = Text::toT(i->getServer());
			l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); // !SMT!-IP
			l[COLUMN_SHARED] = Util::formatBytesW(i->getShared());
			l[COLUMN_MINSHARE] = Util::formatBytesW(i->getMinShare());
			l[COLUMN_MINSLOTS] = Util::toStringW(i->getMinSlots());
			l[COLUMN_MAXHUBS] = Util::toStringW(i->getMaxHubs());
			l[COLUMN_MAXUSERS] = Util::toStringW(i->getMaxUsers());
			l[COLUMN_RELIABILITY] = Util::toStringW(i->getReliability());
			l[COLUMN_RATING] = Text::toT(i->getRating());
			const auto l_country = i->getCountry();
			dcassert(!l_country.empty());
			const auto l_index_country = WinUtil::getFlagIndexByName(l_country.c_str());
			//const auto l_index =
			m_ctrlHubs.insert(cnt++, l, l_index_country); // !SMT!-IP
			
			/*
			LVITEM lvItem = { 0 };
			        lvItem.mask = LVIF_IMAGE;
			        lvItem.iItem = l_index;
			        lvItem.iImage = isOnline(i->getServer()) ? 0 : 1;
			        m_ctrlHubs.SetItem(&lvItem);
			*/
			visibleHubs++;
			users += i->getUsers();
		}
	}
	
	m_ctrlHubs.resort();
	
	updateStatus();
}
Пример #3
0
		bool Clock::isExpired(const dtn::data::Timestamp &timestamp, const dtn::data::Number &lifetime)
		{
			// can not check invalid timestamp
			// assume bundle has an age block and trust on later checks
			if (timestamp == 0) return false;

			// disable expiration if clock rating is too bad
			if (getRating() == 0.0) return false;

			return Clock::getTime() > __getExpireTime(timestamp, lifetime);
		}
Пример #4
0
bool Movie::equals(const Movie&mv) const{
    if(getId() == mv.getId() &&
       getTitle() == mv.getTitle() &&
       getFile() == mv.getFile() &&
       getThumbsFile() == mv.getThumbsFile() &&
       getDescr() == mv.getDescr() &&
       getPosterFile() == mv.getPosterFile() &&
       getYear() == mv.getYear() &&
       getRating() == mv.getRating())
        return true;
    else
        return false;
}
    //-------------------------------------------------------------------------
    //! @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;
    }
Пример #6
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());
}
Пример #7
0
bool Mechanoid::hasRating(float r, RatingType type) const
{
    return getRating(type) >= r;
}
Пример #8
0
int Mechanoid::getRatingLevel(RatingType type) const
{
    return _getRatingLevel(getRating(type));
}