~ken-vandine/indicator-transfer/ual_api_change

« back to all changes in this revision

Viewing changes to src/view-gmenu.cpp

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2015-08-19 19:17:06 UTC
  • mfrom: (29.6.11 add-plugins-fix-model-clear)
  • Revision ID: ci-train-bot@canonical.com-20150819191706-k1jnor3lh4n26zax
Added 'clear' function into the Source interface.
Call 'Source.clear' in the 'Controller.clear_all' function.
Does not keep a separated copy of source model inside of the Controller class.
Changed the return of 'Source.get_model()' to const.
Update unit tests.
Approved by: Charles Kerr, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
{
44
44
public:
45
45
 
46
 
  GActions(const std::shared_ptr<Model>& model,
47
 
           const std::shared_ptr<Controller>& controller):
 
46
  explicit GActions(const std::shared_ptr<Controller>& controller):
48
47
    m_action_group(g_simple_action_group_new()),
49
48
    m_controller(controller)
50
49
  {
51
 
    set_model(model);
 
50
    set_model(controller->get_model());
52
51
 
53
52
    const GActionEntry entries[] = {
54
53
        { "activate-transfer", on_tap, "s", nullptr },
75
74
 
76
75
  }
77
76
 
78
 
  void set_model(const std::shared_ptr<Model>& model)
 
77
  void set_model(const std::shared_ptr<const Model>& model)
79
78
  {
80
79
    // out with the old...
81
80
    auto& c = m_connections;
252
251
  }
253
252
 
254
253
  GSimpleActionGroup* m_action_group = nullptr;
255
 
  std::shared_ptr<Model> m_model;
 
254
  std::shared_ptr<const Model> m_model;
256
255
  std::shared_ptr<Controller> m_controller;
257
256
  std::set<core::ScopedConnection> m_connections;
258
257
 
279
278
  GMenuModel* menu_model() { return G_MENU_MODEL(m_menu); }
280
279
 
281
280
  Menu(const char* name_in,
282
 
       const std::shared_ptr<Model>& model,
 
281
       const std::shared_ptr<const Model>& model,
283
282
       const std::shared_ptr<GActions>& gactions):
284
283
    m_name{name_in},
285
284
    m_gactions{gactions}
296
295
    g_clear_object(&m_menu);
297
296
  }
298
297
 
299
 
  void set_model (const std::shared_ptr<Model>& model)
 
298
  void set_model (const std::shared_ptr<const Model>& model)
300
299
  {
301
300
    auto& c = m_connections;
302
301
    c.clear();
563
562
    return item;
564
563
  }
565
564
 
566
 
  static bool bulk_menu_item_is_equal(GMenuModel* model, 
 
565
  static bool bulk_menu_item_is_equal(GMenuModel* model,
567
566
                                      int pos,
568
567
                                      GMenuItem* item)
569
568
  {
772
771
  GMenu* m_menu = nullptr;
773
772
  const char* const m_name;
774
773
 
775
 
  std::shared_ptr<Model> m_model;
 
774
  std::shared_ptr<const Model> m_model;
776
775
  std::shared_ptr<GActions> m_gactions;
777
776
  std::map<Transfer::Id,Section> m_visible_transfers;
778
777
  GMenu* m_submenu = nullptr;
936
935
{
937
936
public:
938
937
 
939
 
  Impl (const std::shared_ptr<Model>& model,
940
 
        const std::shared_ptr<Controller>& controller):
941
 
    m_model(model),
 
938
  explicit Impl (const std::shared_ptr<Controller>& controller):
942
939
    m_controller(controller),
943
 
    m_gactions(new GActions(model, controller)),
 
940
    m_gactions(new GActions(controller)),
944
941
    m_exporter(new Exporter)
945
942
  {
 
943
    set_model(controller->get_model());
946
944
    // create the Menus
947
945
    for(int i=0; i<Menu::NUM_PROFILES; i++)
948
946
      m_menus.push_back(create_menu_for_profile(Menu::Profile(i)));
949
 
  
 
947
 
950
948
    m_exporter->publish(m_gactions, m_menus);
951
949
  }
952
950
 
954
952
  {
955
953
  }
956
954
 
957
 
  void set_model(const std::shared_ptr<Model>& model)
 
955
  void set_model(const std::shared_ptr<const Model>& model)
958
956
  {
959
957
    m_model = model;
960
958
 
976
974
    return m;
977
975
  }
978
976
 
979
 
  std::shared_ptr<Model> m_model;
 
977
  std::shared_ptr<const Model> m_model;
980
978
  std::shared_ptr<Controller> m_controller;
981
979
  std::shared_ptr<GActions> m_gactions;
982
980
  std::vector<std::shared_ptr<Menu>> m_menus;
987
985
****
988
986
***/
989
987
 
990
 
GMenuView::GMenuView(const std::shared_ptr<Model>& model,
991
 
                 const std::shared_ptr<Controller>& controller):
992
 
  p(new Impl(model, controller))
 
988
GMenuView::GMenuView(const std::shared_ptr<Controller>& controller):
 
989
  p(new Impl(controller))
993
990
{
994
991
}
995
992
 
997
994
{
998
995
}
999
996
 
1000
 
void GMenuView::set_model(const std::shared_ptr<Model>& model)
1001
 
{
1002
 
  p->set_model(model);
1003
 
}
1004
 
 
1005
997
const core::Signal<>& GMenuView::name_lost() const
1006
998
{
1007
999
  return p->name_lost();