~unity-team/unity/trunk

« back to all changes in this revision

Viewing changes to shortcuts/ShortcutModel.cpp

  • Committer: Tarmac
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2013-01-22 04:45:15 UTC
  • mfrom: (2919.3.42 shortcut-WS-dynamic)
  • Revision ID: tarmac-20130122044515-xsdaeiqe7u021htz
shortcut: cleanup the code making it more dynamic and model-dependent. Fixes: https://bugs.launchpad.net/bugs/1102429.

Approved by Andrea Azzarone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
{
26
26
 
27
27
Model::Model(std::list<AbstractHint::Ptr> const& hints)
 
28
  : categories_per_column(3, [] (int& target, int const& new_value) {
 
29
      int cat_per_col = std::max<int>(1, new_value);
 
30
      if (cat_per_col != target)
 
31
      {
 
32
        target = cat_per_col;
 
33
        return true;
 
34
      }
 
35
      return false;
 
36
    })
28
37
{
29
 
  for (auto hint : hints)
 
38
  for (auto const& hint : hints)
30
39
    AddHint(hint);
31
40
}
32
41
 
44
53
 
45
54
void Model::Fill()
46
55
{
47
 
  for (auto category : categories_)
48
 
    for (auto item : hints_[category])
 
56
  for (auto const& category : categories_)
 
57
    for (auto const& item : hints_[category])
49
58
      item->Fill();
50
59
}
51
60