Skip to content

Commit

Permalink
Refactor: Use pimpl-friendly audiences for libdeng2 classes
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 2, 2014
1 parent 90209ed commit b92c4b3
Show file tree
Hide file tree
Showing 29 changed files with 87 additions and 86 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/src/alertmask.cpp
Expand Up @@ -67,7 +67,7 @@ void AlertMask::init()
{
foreach(Variable const *var, App::config().names().subrecord("alert").members())
{
var->audienceForChange += d;
var->audienceForChange() += d;
}
d->updateMask();
}
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -1333,7 +1333,7 @@ bool App_ChangeGame(Game &game, bool allowReload)
}

// The current game will be gone very soon.
DENG2_FOR_EACH_OBSERVER(App::GameUnloadAudience, i, App::app().audienceForGameUnload)
DENG2_FOR_EACH_OBSERVER(App::GameUnloadAudience, i, App::app().audienceForGameUnload())
{
i->aboutToUnloadGame(App::game());
}
Expand Down Expand Up @@ -1589,7 +1589,7 @@ bool App_ChangeGame(Game &game, bool allowReload)
#endif

// Game change is complete.
DENG2_FOR_EACH_OBSERVER(App::GameChangeAudience, i, App::app().audienceForGameChange)
DENG2_FOR_EACH_OBSERVER(App::GameChangeAudience, i, App::app().audienceForGameChange())
{
i->currentGameChanged(App::game());
}
Expand Down Expand Up @@ -1703,7 +1703,7 @@ void DD_FinishInitializationAfterWindowReady()
}

/// @todo This notification should be done from the app.
DENG2_FOR_EACH_OBSERVER(App::StartupCompleteAudience, i, App::app().audienceForStartupComplete)
DENG2_FOR_EACH_OBSERVER(App::StartupCompleteAudience, i, App::app().audienceForStartupComplete())
{
i->appStartupCompleted();
}
Expand Down
6 changes: 3 additions & 3 deletions doomsday/client/src/network/serverlink.cpp
Expand Up @@ -66,7 +66,7 @@ DENG2_PIMPL(ServerLink)

~Instance()
{
Loop::appLoop().audienceForIteration -= this;
Loop::appLoop().audienceForIteration() -= this;
}

void notifyDiscoveryUpdate()
Expand Down Expand Up @@ -183,7 +183,7 @@ DENG2_PIMPL(ServerLink)
fetching = true;
N_MAPost(MAC_REQUEST);
N_MAPost(MAC_WAIT);
Loop::appLoop().audienceForIteration += this;
Loop::appLoop().audienceForIteration() += this;
}

void loopIteration()
Expand All @@ -193,7 +193,7 @@ DENG2_PIMPL(ServerLink)
if(N_MADone())
{
fetching = false;
Loop::appLoop().audienceForIteration -= this;
Loop::appLoop().audienceForIteration() -= this;

fromMaster.clear();
int const count = N_MasterGet(0, 0);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/settingsregister.cpp
Expand Up @@ -99,16 +99,16 @@ DENG2_OBSERVES(App, GameChange)

Instance(Public *i) : Base(i), current(CUSTOM_PROFILE)
{
App::app().audienceForGameUnload += this;
App::app().audienceForGameChange += this;
App::app().audienceForGameUnload() += this;
App::app().audienceForGameChange() += this;

addProfile(current);
}

~Instance()
{
App::app().audienceForGameUnload -= this;
App::app().audienceForGameChange -= this;
App::app().audienceForGameUnload() -= this;
App::app().audienceForGameChange() -= this;

clearProfiles();
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -126,17 +126,17 @@ DENG2_PIMPL(ClientWindow)
/// @todo The decision whether to receive input notifications from the
/// canvas is really a concern for the input drivers.

App::app().audienceForGameChange += this;
App::app().audienceForStartupComplete += this;
App::app().audienceForGameChange() += this;
App::app().audienceForStartupComplete() += this;

// Listen to input.
self.canvas().audienceForMouseStateChange += this;
}

~Instance()
{
App::app().audienceForGameChange -= this;
App::app().audienceForStartupComplete -= this;
App::app().audienceForGameChange() -= this;
App::app().audienceForStartupComplete() -= this;

self.canvas().audienceForFocusChange -= this;
self.canvas().audienceForMouseStateChange -= this;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/editors/rendererappearanceeditor.cpp
Expand Up @@ -265,7 +265,7 @@ DENG2_OBSERVES(App, GameChange)
firstColumnWidth(new IndirectRule)
{
// The editor will close automatically when going to Ring Zero.
App::app().audienceForGameChange += this;
App::app().audienceForGameChange() += this;

settings.audienceForProfileChange += this;

Expand Down Expand Up @@ -570,7 +570,7 @@ DENG2_OBSERVES(App, GameChange)

~Instance()
{
App::app().audienceForGameChange -= this;
App::app().audienceForGameChange() -= this;
settings.audienceForProfileChange -= this;
releaseRef(firstColumnWidth);
}
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/ui/widgets/consolecommandwidget.cpp
Expand Up @@ -32,14 +32,14 @@ DENG2_OBSERVES(App, GameChange)
{
Instance(Public *i) : Base(i)
{
App::app().audienceForStartupComplete += this;
App::app().audienceForGameChange += this;
App::app().audienceForStartupComplete() += this;
App::app().audienceForGameChange() += this;
}

~Instance()
{
App::app().audienceForStartupComplete -= this;
App::app().audienceForGameChange -= this;
App::app().audienceForStartupComplete() -= this;
App::app().audienceForGameChange() -= this;
}

void appStartupCompleted()
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -88,12 +88,12 @@ DENG2_OBSERVES(Variable, Change)

grabWidth = style().rules().rule("gap").valuei();

App::config()["console.script"].audienceForChange += this;
App::config()["console.script"].audienceForChange() += this;
}

~Instance()
{
App::config()["console.script"].audienceForChange -= this;
App::config()["console.script"].audienceForChange() -= this;

releaseRef(horizShift);
releaseRef(width);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/client/src/ui/widgets/gameselectionwidget.cpp
Expand Up @@ -239,15 +239,15 @@ DENG_GUI_PIMPL(GameSelectionWidget)
updateSubsetLayout();

App_Games().audienceForAddition += this;
App::app().audienceForStartupComplete += this;
App::app().audienceForGameChange += this;
App::app().audienceForStartupComplete() += this;
App::app().audienceForGameChange() += this;
}

~Instance()
{
App_Games().audienceForAddition -= this;
App::app().audienceForStartupComplete -= this;
App::app().audienceForGameChange -= this;
App::app().audienceForStartupComplete() -= this;
App::app().audienceForGameChange() -= this;
}

void updateSubsetVisibility()
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/gamesessionwidget.cpp
Expand Up @@ -51,12 +51,12 @@ DENG2_PIMPL(GameSessionWidget)
popup->document().setMaximumLineWidth(popup->style().rules().rule("document.popup.width").valuei());
info->audienceForPress += this;

App::app().audienceForGameUnload += this;
App::app().audienceForGameUnload() += this;
}

~Instance()
{
App::app().audienceForGameUnload -= this;
App::app().audienceForGameUnload() -= this;
}

void aboutToUnloadGame(game::Game const &)
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -130,7 +130,7 @@ DENG_GUI_PIMPL(TaskBarWidget)

vertShift = new ScalarRule(0);

App::app().audienceForGameChange += this;
App::app().audienceForGameChange() += this;
ClientApp::serverLink().audienceForJoin += this;
ClientApp::serverLink().audienceForLeave += this;

Expand All @@ -139,7 +139,7 @@ DENG_GUI_PIMPL(TaskBarWidget)

~Instance()
{
App::app().audienceForGameChange -= this;
App::app().audienceForGameChange() -= this;
ClientApp::serverLink().audienceForJoin -= this;
ClientApp::serverLink().audienceForLeave -= this;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/updater/updater.cpp
Expand Up @@ -531,7 +531,7 @@ Updater::Updater() : d(new Instance(this))
connect(d->network, SIGNAL(finished(QNetworkReply *)), this, SLOT(gotReply(QNetworkReply *)));

// Do a silent auto-update check when starting.
App::app().audienceForStartupComplete += d;
App::app().audienceForStartupComplete() += d;
}

void Updater::setupUI()
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libappfw/src/childwidgetorganizer.cpp
Expand Up @@ -55,7 +55,7 @@ DENG2_OBSERVES(ui::Item, Change )
{
DENG2_FOR_EACH_CONST(Mapping, i, mapping)
{
i.value()->audienceForDeletion -= this;
i.value()->audienceForDeletion() -= this;
}
}

Expand Down Expand Up @@ -122,7 +122,7 @@ DENG2_OBSERVES(ui::Item, Change )
}

// Observe.
w->audienceForDeletion += this; // in case it's manually deleted
w->audienceForDeletion() += this; // in case it's manually deleted
item.audienceForChange += this;
}

Expand All @@ -139,7 +139,7 @@ DENG2_OBSERVES(ui::Item, Change )

void deleteWidget(GuiWidget *w)
{
w->audienceForDeletion -= this;
w->audienceForDeletion() -= this;
GuiWidget::destroy(w);
}

Expand Down
6 changes: 3 additions & 3 deletions doomsday/libappfw/src/dialogcontentstylist.cpp
Expand Up @@ -41,19 +41,19 @@ DialogContentStylist::~DialogContentStylist()
{
if(_container)
{
_container->audienceForChildAddition -= this;
_container->audienceForChildAddition() -= this;
}
}

void DialogContentStylist::setContainer(GuiWidget &container)
{
if(_container)
{
_container->audienceForChildAddition -= this;
_container->audienceForChildAddition() -= this;
}

_container = &container;
_container->audienceForChildAddition += this;
_container->audienceForChildAddition() += this;
}

void DialogContentStylist::widgetChildAdded(Widget &child)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libappfw/src/guirootwidget.cpp
Expand Up @@ -55,7 +55,7 @@ DENG2_PIMPL(GuiRootWidget)
, uTexAtlas("uTex", GLUniform::Sampler2D)
, noFramesDrawnYet(true)
{
self.audienceForChildAddition += this;
self.audienceForChildAddition() += this;
}

~Instance()
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libappfw/src/guiwidget.cpp
Expand Up @@ -86,11 +86,11 @@ DENG2_PIMPL(GuiWidget)
, uBlurStep ("uBlurStep", GLUniform::Vec2)
, uBlurWindow ("uWindow", GLUniform::Vec4)
{
self.audienceForChildAddition += this;
self.audienceForChildAddition() += this;
margins.audienceForChange += this;

#ifdef DENG2_DEBUG
self.audienceForParentChange += this;
self.audienceForParentChange() += this;
rule.setDebugName(self.path());
#endif

Expand Down
6 changes: 3 additions & 3 deletions doomsday/libappfw/src/widgets/buttonwidget.cpp
Expand Up @@ -52,7 +52,7 @@ DENG2_OBSERVES(Action, Triggered)

~Instance()
{
if(action) action->audienceForTriggered -= this;
if(action) action->audienceForTriggered() -= this;
releaseRef(action);
}

Expand Down Expand Up @@ -196,14 +196,14 @@ void ButtonWidget::setAction(RefArg<Action> action)
{
if(d->action)
{
d->action->audienceForTriggered -= d;
d->action->audienceForTriggered() -= d;
}

changeRef(d->action, action);

if(action)
{
action->audienceForTriggered += d;
action->audienceForTriggered() += d;
}
}

Expand Down
15 changes: 8 additions & 7 deletions doomsday/libappfw/src/widgets/choicewidget.cpp
Expand Up @@ -37,20 +37,21 @@ DENG2_OBSERVES(ChildWidgetOrganizer, WidgetUpdate)
*/
struct SelectAction : public de::Action
{
Instance *d;
ChoiceWidget::Instance *wd;
ui::Item const &selItem;

SelectAction(Instance *inst, ui::Item const &item) : d(inst), selItem(item) {}
SelectAction(ChoiceWidget::Instance *inst, ui::Item const &item)
: wd(inst), selItem(item) {}

void trigger()
{
Action::trigger();
d->selected = d->items().find(selItem);
d->updateButtonWithSelection();
d->updateItemHighlight();
d->choices->dismiss();
wd->selected = wd->items().find(selItem);
wd->updateButtonWithSelection();
wd->updateItemHighlight();
wd->choices->dismiss();

emit d->self.selectionChangedByUser(d->selected);
emit wd->self.selectionChangedByUser(wd->selected);
}
};

Expand Down

0 comments on commit b92c4b3

Please sign in to comment.