コード例 #1
0
ファイル: OSMWay.cpp プロジェクト: Tisseo/synthese
		bool Way::isBikable() 
		{
			bool isBikable(true);

			if(hasTag(TAG_HIGHWAY))
			{
				std::string highway = getTag(TAG_HIGHWAY);
				if(highway == "motorway" || highway == "motorway_link")
					isBikable = false;
				else if(highwayTypes.find(highway) == highwayTypes.end())
					isBikable = false;
			}

			if(hasTag(TAG_ACCESS))
			{
				std::string access = getTag(TAG_ACCESS);
				if(access == "no" || access == "private")
					isBikable = false;
			}

			if(hasTag(TAG_BICYCLE))
			{
				std::string access = getTag(TAG_BICYCLE);
				if(access == "no")
					isBikable = false;
				else if(access == "yes")
					isBikable = true;
			}

			return isBikable;
		}
コード例 #2
0
ファイル: image.cpp プロジェクト: cubbu/imgbrd-grabber
QString Image::isAnimated() const
{
	QString ext = getExtension(m_url).toLower();

	if (ext == "gif" || ext == "apng")
		return ext;

	if (ext == "png" && (hasTag(QStringLiteral("animated")) || hasTag(QStringLiteral("animated_png"))))
		return QStringLiteral("apng");

	return QString();
}
コード例 #3
0
ファイル: Task.cpp プロジェクト: nigeil/task
float Task::urgency_next () const
{
  if (hasTag ("next"))
    return 1.0;

  return 0.0;
}
コード例 #4
0
ファイル: OSMWay.cpp プロジェクト: Tisseo/synthese
		double Way::getAssociatedSpeed()
		{
			double maxSpeed = 0;
			if(hasTag("maxspeed"))
			{
				std::string maxSpeedTag(getTag("maxspeed"));
				if(implicitSpeed.find(maxSpeedTag) != implicitSpeed.end())
				{
					maxSpeed = implicitSpeed.find(maxSpeedTag)->second;
				}
				else
				{
					try
					{
						maxSpeed = boost::lexical_cast<double>(maxSpeedTag) / 3.6;
					}
					catch(boost::bad_lexical_cast &)
					{
					}
				}
			}

			if(!maxSpeed)
			{
				Road::RoadType type = getAssociatedRoadType();
				std::map<Road::RoadType, double>::iterator it = defaultSpeed.find(type);

				if(it != defaultSpeed.end())
					maxSpeed = it->second;
				else
					maxSpeed = 50 / 3.6;
			}

			return maxSpeed;
		}
コード例 #5
0
ファイル: hastags.cpp プロジェクト: jrharshath/hisaab
void HasTags::addTag(QString tag) {
	tag = tag.trimmed();
	if( hasTag(tag) ) return;
	if( tag[0]==TAG_STARTER )
		tags.append(tag);
	else
		tags.append(TAG_STARTER+tag);
}
コード例 #6
0
ファイル: tagable.hpp プロジェクト: andrey-nakin/nettcl2d
	bool hasTags(const TagContainer& c) const {
		for (TagContainer::const_iterator i = c.begin(), last = c.end(); i != last; ++i) {
			if (hasTag(*i)) {
				return true;
			}
		}
		return false;
	}
コード例 #7
0
ファイル: image.cpp プロジェクト: cubbu/imgbrd-grabber
/**
 * Try to guess the size of the image in pixels for sorting.
 * @return The guessed number of pixels in the image.
 */
int Image::value() const
{
	// Get from image size
	if (!m_size.isEmpty())
		return m_size.width() * m_size.height();

	// Get from tags
	if (hasTag("incredibly_absurdres"))
		return 10000 * 10000;
	else if (hasTag("absurdres"))
		return 3200 * 2400;
	else if (hasTag("highres"))
		return 1600 * 1200;
	else if (hasTag("lowres"))
		return 500 * 500;

	return 1200 * 900;
}
コード例 #8
0
bool Tags::hasTag(const QString & tag )
{
    QStringList::iterator it;
    for (it = _tagFiles.begin(); it != _tagFiles.end() ; it++) {
        if (hasTag((*it).ascii(), tag))
            return true;
    }

    return false;
}
コード例 #9
0
ファイル: RaceTags.cpp プロジェクト: arijitvt/EventRacer
std::string RaceTags::tagsToString(RaceTagSet tags) {
	std::string r;
	for (int t = 0; t < static_cast<int>(NUM_RACE_TAGS); ++t) {
		if (hasTag(tags, static_cast<RaceTag>(t))) {
			if (!r.empty()) r += " ";
			r += tagName(static_cast<RaceTag>(t));
		}
	}
	return r;
}
コード例 #10
0
ファイル: generator.c プロジェクト: ericklucena/dfsa-sim
void generator()
{
	int i;
	int numFile;
	int numTags;
	int tagsInserted;
	char file[256];
	char subfolder[256];
	char *tag;
	char *insertedTags[GENERATOR_NUM_TAGS];

	//Init insertedTags DB
	for ( i = 0; i<GENERATOR_NUM_TAGS; i++)
	{
		insertedTags[i]=NULL;
	}

	createFolderIfNotExists(GENERATOR_FOLDER);

	for ( numTags=100; numTags <= GENERATOR_NUM_TAGS; numTags+=100)
	{
		sprintf(subfolder, "%s/%d", GENERATOR_FOLDER, numTags);
		createFolderIfNotExists(subfolder);

		for ( numFile = 0; numFile < GENERATOR_NUM_TAGS; numFile++) 
		{
			tagsInserted = 0;

			while (tagsInserted != numTags)
			{
				//fprintf(stderr, "%d-%d\n", numTags,tagsInserted);
				tag = createTag();

				if (!hasTag(insertedTags, tag))
				{
					insertedTags[tagsInserted++] = tag;
				}
				else
				{
					free(tag);
				}
			}
			sprintf(file, "%s/%04d.txt", subfolder, numFile+1);
			writeTagsOnFile(insertedTags, numTags, file);

			for ( i = 0; i<GENERATOR_NUM_TAGS && (insertedTags[i]!= NULL); i++)
			{
				free(insertedTags[i]);
				insertedTags[i]=NULL;
			}

		}
	}
}
コード例 #11
0
ファイル: BlockFS.cpp プロジェクト: G-Node/nix
std::shared_ptr<base::ITag> BlockFS::createTag(const std::string &name, const std::string &type,
        const std::vector<double> &position) {
    if (name.empty()) {
        throw EmptyString("Block::createTag empty name provided!");
    }
    if (hasTag(name)) {
        throw DuplicateName("Block::createTag: an entity with the same name already exists!");
    }
    std::string id = util::createId();
    return std::make_shared<TagFS>(file(), block(), tag_dir.location(), id, type, name, position);
}
コード例 #12
0
ファイル: OSMWay.cpp プロジェクト: Tisseo/synthese
		bool Way::isDrivable()
		{
			bool isDrivable(true);

			if(hasTag(TAG_HIGHWAY))
			{
				std::string highway = getTag(TAG_HIGHWAY);
				if(highway == "track" || highway == "pedestrian" || highway == "path" || highway == "cycleway" || highway == "footway" || highway == "bridleway" || highway == "steps")
					isDrivable = false;
				else if(highwayTypes.find(highway) == highwayTypes.end())
					isDrivable = false;
			}

			if(hasTag(TAG_ACCESS))
			{
				std::string access = getTag(TAG_ACCESS);
				if(access == "no" || access == "private")
					isDrivable = false;
			}

			if(hasTag(TAG_MOTOR_VEHICLE))
			{
				std::string access = getTag(TAG_MOTOR_VEHICLE);
				if(access == "no")
					isDrivable = false;
				else if(access == "yes")
					isDrivable = true;
			}

			if(hasTag(TAG_MOTORCAR))
			{
				std::string access = getTag(TAG_MOTORCAR);
				if(access == "no")
					isDrivable = false;
				else if(access == "yes")
					isDrivable = true;
			}

			return isDrivable;
		}
コード例 #13
0
 TestCaseInfo::TestCaseInfo( ITestCase* testCase,
                             const char* name,
                             const char* description,
                             const SourceLineInfo& lineInfo )
 :   m_test( testCase ),
     m_name( name ),
     m_description( description ),
     m_lineInfo( lineInfo ),
     m_isHidden( startsWith( name, "./" ) )
 {
     extractTags( m_description, m_tags );
     if( hasTag( "hide" ) )
         m_isHidden = true;
 }
コード例 #14
0
ファイル: OSMWay.cpp プロジェクト: Tisseo/synthese
		Road::RoadType Way::getAssociatedRoadType()
		{
			Road::RoadType type = Road::ROAD_TYPE_UNKNOWN;

			if(hasTag(TAG_HIGHWAY))
			{
				std::string highway = getTag(TAG_HIGHWAY);
				std::map<std::string, Road::RoadType>::iterator it = highwayTypes.find(highway);

				if(it != highwayTypes.end())
					type = it->second;
			}

			return type;
		}
コード例 #15
0
ファイル: player.cpp プロジェクト: vidarn/mgrl
bool
Player::walk(int dx, int dy)
{
    int tmpX = m_x + dx;
    int tmpY = m_y + dy;
    if(m_level->isWalkable(tmpX,tmpY)) {
        if(!hasTag(STATUS_HELD)) {
            m_x = tmpX;
            m_y = tmpY;
            act();
            return true;
        }
        else {
            m_level->m_messages->showMessage("You cannot walk", MESSAGE_ACTION);
            return false;
        }
    }
    else {
        std::vector<int> tags;
        tags.push_back(TAG_ATTACKABLE);
        std::vector<Actor *> actors = m_level->getActors(tmpX, tmpY,tags);
        if(actors.size()>0) {
            attack(actors[0],ATTACK_MELEE);
            act();
            return true;
        }
        else {
            std::vector<int> tags;
            tags.push_back(ITEM_DOOR);
            std::vector<Actor *> actors = m_level->getActors(tmpX, tmpY,tags);
            if(actors.size()>0) {
                actors[0]->open(this);
                act(0.6);
                return true;
            }
        }
    }
    return false;
}
コード例 #16
0
ファイル: pc.C プロジェクト: Methuselas/btbuilder
bool BTPc::hasTag(const std::string &t) const
{
 BTGame *game = BTGame::getGame();
 if (t[0] == '!')
  return !hasTag(t.c_str() + 1);
 bool answer = (std::find<>(tag.begin(), tag.end(), t) != tag.end());
 if (answer)
  return answer;
 if (monster != BTMONSTER_NONE)
 {
  BTFactory<BTMonster> &monList = game->getMonsterList();
  return monList[monster].hasTag(t);
 }
 else
 {
  if (0 == t.compare(genderNames[gender]))
   return true;
  if (0 == t.compare(game->getRaceList()[race]->name))
   return true;
  if (0 == t.compare(game->getJobList()[job]->name))
   return true;
 }
 return false;
}
コード例 #17
0
ファイル: tagable.hpp プロジェクト: andrey-nakin/nettcl2d
	bool hasTag(const char* const tag) const {
		return hasTag(std::string(tag));
	}
コード例 #18
0
 bool MetaData::has(const QString & key, const QString & tag) const {
     return hasTag(tag) and _tags[tag].contains(key);
 }
コード例 #19
0
 QStringList MetaData::fields(const QString & tag) const {
     return hasTag(tag) ? _tags.value(tag).keys() : QStringList();
 }
コード例 #20
0
ファイル: Task.cpp プロジェクト: nigeil/task
////////////////////////////////////////////////////////////////////////////////
// Urgency is defined as a polynomial, the value of which is calculated in this
// function, according to:
//
//   U = A.t  + B.t  + C.t  ...
//          a      b      c
//
//   U       = urgency
//   A       = coefficient for term a
//   t sub a = numeric scale from 0 -> 1, with 1 being the highest
//             urgency, derived from one task attribute and mapped
//             to the numeric scale
//
// See rfc31-urgency.txt for full details.
//
float Task::urgency_c () const
{
  float value = 0.0;
  value += fabsf (urgencyPriorityCoefficient)    > epsilon ? (urgency_priority ()    * urgencyPriorityCoefficient)    : 0.0;
  value += fabsf (urgencyProjectCoefficient)     > epsilon ? (urgency_project ()     * urgencyProjectCoefficient)     : 0.0;
  value += fabsf (urgencyActiveCoefficient)      > epsilon ? (urgency_active ()      * urgencyActiveCoefficient)      : 0.0;
  value += fabsf (urgencyScheduledCoefficient)   > epsilon ? (urgency_scheduled ()   * urgencyScheduledCoefficient)   : 0.0;
  value += fabsf (urgencyWaitingCoefficient)     > epsilon ? (urgency_waiting ()     * urgencyWaitingCoefficient)     : 0.0;
  value += fabsf (urgencyBlockedCoefficient)     > epsilon ? (urgency_blocked ()     * urgencyBlockedCoefficient)     : 0.0;
  value += fabsf (urgencyAnnotationsCoefficient) > epsilon ? (urgency_annotations () * urgencyAnnotationsCoefficient) : 0.0;
  value += fabsf (urgencyTagsCoefficient)        > epsilon ? (urgency_tags ()        * urgencyTagsCoefficient)        : 0.0;
  value += fabsf (urgencyNextCoefficient)        > epsilon ? (urgency_next ()        * urgencyNextCoefficient)        : 0.0;
  value += fabsf (urgencyDueCoefficient)         > epsilon ? (urgency_due ()         * urgencyDueCoefficient)         : 0.0;
  value += fabsf (urgencyBlockingCoefficient)    > epsilon ? (urgency_blocking ()    * urgencyBlockingCoefficient)    : 0.0;
  value += fabsf (urgencyAgeCoefficient)         > epsilon ? (urgency_age ()         * urgencyAgeCoefficient)         : 0.0;

/* 
  // Very useful for debugging urgency problems.
  std::cout << "# Urgency for " << get ("uuid") << ":\n"
          << "#     pri " << (urgency_priority ()    * urgencyPriorityCoefficient)    << "\n"
          << "#     pro " << (urgency_project ()     * urgencyProjectCoefficient)     << "\n"
          << "#     act " << (urgency_active ()      * urgencyActiveCoefficient)      << "\n"
          << "#     sch " << (urgency_scheduled ()   * urgencyScheduledCoefficient)   << "\n"
          << "#     wai " << (urgency_waiting ()     * urgencyWaitingCoefficient)     << "\n"
          << "#     blk " << (urgency_blocked ()     * urgencyBlockedCoefficient)     << "\n"
          << "#     ann " << (urgency_annotations () * urgencyAnnotationsCoefficient) << "\n"
          << "#     tag " << (urgency_tags ()        * urgencyTagsCoefficient)        << "\n"
          << "#     nex " << (urgency_next ()        * urgencyNextCoefficient)        << "\n"
          << "#     due " << (urgency_due ()         * urgencyDueCoefficient)         << "\n"
          << "#     bkg " << (urgency_blocking ()    * urgencyBlockingCoefficient)    << "\n"
          << "#     age " << (urgency_age ()         * urgencyAgeCoefficient)         << "\n";
*/

  // Tag- and project-specific coefficients.
  std::map <std::string, float>::iterator var;
  for (var = coefficients.begin (); var != coefficients.end (); ++var)
  {
    if (fabs (var->second) > epsilon)
    {
      if (var->first.substr (0, 13) == "urgency.user.")
      {
        // urgency.user.project.<project>.coefficient
        std::string::size_type end = std::string::npos;
        if (var->first.substr (13, 8) == "project." &&
            (end = var->first.find (".coefficient")) != std::string::npos)
        {
          std::string project = var->first.substr (21, end - 21);

          if (get ("project").find (project) == 0)
            value += var->second;
        }

        // urgency.user.tag.<tag>.coefficient
        if (var->first.substr (13, 4) == "tag." &&
            (end = var->first.find (".coefficient")) != std::string::npos)
        {
          std::string tag = var->first.substr (17, end - 17);

          if (hasTag (tag))
            value += var->second;
        }
      }
      else if (var->first.substr (0, 12) == "urgency.uda.")
      {
        // urgency.uda.<name>.coefficient
        std::string::size_type end = var->first.find (".coefficient");
        if (end != std::string::npos)
          if (has (var->first.substr (12, end - 12)))
            value += var->second;
      }
    }
  }

  return value;
}
コード例 #21
0
ファイル: player.cpp プロジェクト: Mutilador/Wolfpack
void cPlayer::showName( cUOSocket* socket )
{
	if ( !socket->player() )
	{
		return;
	}

	QString charName = name();

	// Prefix
	QString prefix( " " );

	// Tag for Prefix
	if ( !isPolymorphed() )
	{
		if ( hasTag( "name.prefix" ) )
		{
			prefix.append( getTag( "name.prefix" ).toString() );
		}
		else if ( fame_ >= 10000 && !isReputationHidden() )
		{
			prefix.append( gender_ ? tr( "Lady" ) : tr( "Lord" ) );
		}
	}

	// Suffix
	QString affix( " " );

	// Tag for Suffix
	if ( !isPolymorphed() )
	{
		if ( hasTag( "name.suffix" ) )
		{
			affix.append( getTag( "name.suffix" ).toString() );
			affix.append( " " );
		}
	}

	if ( !isIncognito() && guild_ && !guild_->abbreviation().isEmpty() )
	{
		cGuild::MemberInfo* info = guild_->getMemberInfo( this );

		if ( info && info->showSign() )
		{
			affix.append( QString( "[%1]" ).arg( guild_->abbreviation() ) );
		}
	}

	// Append serial for GMs
	if ( socket->account()->isShowSerials() )
		affix.append( QString( "[0x%1]" ).arg( serial(), 4, 16 ) );

	// Append offline flag
	if ( !socket_ && !logoutTime_ )
		affix.append( tr( " [offline]" ) );

	// Guarded
	if ( guardedby_.size() > 0 )
		affix.append( tr( " [guarded]" ) );

	// Guarding
	if ( isTamed() && guarding_ )
		affix.append( tr( " [guarding]" ) );

	quint16 speechColor;

	// 0x01 Blue, 0x02 Green, 0x03 Grey, 0x05 Orange, 0x06 Red
	if (Config::instance()->sendAsciiNames()) {
		switch ( notoriety( socket->player() ) )
		{
		case 0x01:
			speechColor = 0x63; break; //blue
		case 0x02:
			speechColor = 0x44; break; //green
		case 0x03:
			speechColor = 0x3B2; break; //grey
		case 0x05:
			speechColor = 0x2b; break; //orange
		case 0x06:
			speechColor = 0x0026; break; //red
		default:
			speechColor = 0x3B2; break; // grey
		}

		if ( isInvulnerable() )
		{
			speechColor = 0x37;
		}

		// ASCII Packet
		cUOTxAsciiSpeech speech;
		speech.setId(body_);
		speech.setSerial(serial_);
		speech.setMessage(prefix + " " + charName + " " + affix);
		speech.setColor(speechColor);
		speech.setFont(3);
		speech.setType(6); // Object Speech
		speech.setName(name_);
		socket->send(&speech);
		// Show it to the socket
		// socket->showSpeech( this, charName, speechColor, 3, cUOTxUnicodeSpeech::System );
		// Names are presented in ASCII speech, Guild titles are not
		//socket->clilocMessage( 1050045, " \t" + charName + "\t " + affix, speechColor, 3, this, true );
	} else {
		switch ( notoriety( socket->player() ) )
		{
		case 0x01:
			speechColor = 0x59; break; //blue
		case 0x02:
			speechColor = 0x3F; break; //green
		case 0x03:
			speechColor = 0x3B2; break; //grey
		case 0x05:
			speechColor = 0x90; break; //orange
		case 0x06:
			speechColor = 0x22; break; //red
		default:
			speechColor = 0x3B2; break; // grey
		}

		if ( isInvulnerable() )
		{
			speechColor = 0x35;
		}

		// Show it to the socket
		// socket->showSpeech( this, charName, speechColor, 3, cUOTxUnicodeSpeech::System );
		// Names are presented in ASCII speech, Guild titles are not
		socket->clilocMessage( 1050045, prefix + " \t" + charName + "\t " + affix, speechColor, 3, this, true );
	}
}
コード例 #22
0
ファイル: image.cpp プロジェクト: cubbu/imgbrd-grabber
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>();
}
コード例 #23
0
 void MetaData::setPrimaryTag(const QString & name) {
     if (hasTag(name)) {
         _primary = name;
     }
 }
コード例 #24
0
ファイル: GameObject.hpp プロジェクト: Lums-proj/Lums
 bool    hasTag(const char* tag) const { return hasTag(lm::sym(tag)); }