Skip to content

Commit

Permalink
FontManifest|Client: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 15, 2013
1 parent 4862b08 commit 407b71a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
12 changes: 7 additions & 5 deletions doomsday/client/include/resource/fontmanifest.h
Expand Up @@ -55,7 +55,11 @@ DENG2_OBSERVES(AbstractFont, Deletion)
*/
FontScheme &scheme() const;

/// Convenience method for returning the name of the owning scheme.
/**
* Convenient method of returning the name of the owning scheme.
*
* @see scheme(), FontScheme::name()
*/
String const &schemeName() const;

/**
Expand All @@ -67,8 +71,7 @@ DENG2_OBSERVES(AbstractFont, Deletion)
* The path component of the URI will contain the percent-encoded path
* of the manifest.
*/
inline Uri composeUri(QChar sep = '/') const
{
inline Uri composeUri(QChar sep = '/') const {
return Uri(schemeName(), path(sep));
}

Expand All @@ -83,8 +86,7 @@ DENG2_OBSERVES(AbstractFont, Deletion)
*
* @see uniqueId(), setUniqueId()
*/
inline Uri composeUrn() const
{
inline Uri composeUrn() const {
return Uri("urn", String("%1:%2").arg(schemeName()).arg(uniqueId(), 0, 10));
}

Expand Down
20 changes: 12 additions & 8 deletions doomsday/client/src/resource/fontmanifest.cpp
Expand Up @@ -19,7 +19,7 @@
*/

#include "resource/fontmanifest.h"
#include "dd_main.h" // App_Fonts()
#include "dd_main.h" // App_Fonts(), remove me
#include "FontScheme"
#include <de/Log>

Expand All @@ -43,14 +43,9 @@ FontManifest::~FontManifest()
DENG2_FOR_AUDIENCE(Deletion, i) i->manifestBeingDeleted(*this);
}

Fonts &FontManifest::collection()
{
return App_Fonts();
}

FontScheme &FontManifest::scheme() const
{
LOG_AS("FontManifest::scheme");
LOG_AS("FontManifest");
/// @todo Optimize: FontManifest should contain a link to the owning FontScheme.
foreach(FontScheme *scheme, collection().allSchemes())
{
Expand Down Expand Up @@ -78,6 +73,8 @@ int FontManifest::uniqueId() const

bool FontManifest::setUniqueId(int newUniqueId)
{
LOG_AS("FontManifest");

if(d->uniqueId == newUniqueId) return false;

d->uniqueId = newUniqueId;
Expand All @@ -100,11 +97,13 @@ AbstractFont &FontManifest::resource() const
return *d->resource.data();
}
/// @throw MissingFontError No resource is associated with the manifest.
throw MissingFontError("FontManifest::font", "No resource is associated");
throw MissingFontError("FontManifest::resource", "No resource is associated");
}

void FontManifest::setResource(AbstractFont *newResource)
{
LOG_AS("FontManifest");

if(d->resource.data() != newResource)
{
if(AbstractFont *curFont = d->resource.data())
Expand All @@ -127,3 +126,8 @@ void FontManifest::fontBeingDeleted(AbstractFont const & /*resource*/)
{
d->resource.reset();
}

Fonts &FontManifest::collection()
{
return App_Fonts();
}

0 comments on commit 407b71a

Please sign in to comment.