~3v1n0/unity/overlay-border-scale

« back to all changes in this revision

Viewing changes to UnityCore/Model-inl.h

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
MergedĀ latestĀ lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
template<class RowAdaptor>
36
36
Model<RowAdaptor>::Model()
 
37
  : model_type_(ModelType::REMOTE)
 
38
{
 
39
  Init();
 
40
}
 
41
 
 
42
template<class RowAdaptor>
 
43
Model<RowAdaptor>::Model (ModelType model_type)
 
44
  : model_type_(model_type)
 
45
{
 
46
  Init();
 
47
 
 
48
  if (model_type == ModelType::LOCAL)
 
49
    swarm_name = ":local";
 
50
}
 
51
 
 
52
template<class RowAdaptor>
 
53
void Model<RowAdaptor>::Init ()
37
54
{
38
55
  swarm_name.changed.connect(sigc::mem_fun(this, &Model<RowAdaptor>::OnSwarmNameChanged));
39
56
  count.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_count));
40
57
  seqnum.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_seqnum));
 
58
  model.SetGetterFunction(sigc::mem_fun(this, &Model<RowAdaptor>::get_model));
41
59
}
42
60
 
43
61
template<class RowAdaptor>
52
70
  if (model_)
53
71
    dee_model_clear(model_);
54
72
 
55
 
  model_ = dee_shared_model_new(swarm_name.c_str());
 
73
  switch(model_type_)
 
74
  {
 
75
    case ModelType::LOCAL:
 
76
      model_ = dee_sequence_model_new();
 
77
      break;
 
78
    case ModelType::REMOTE:
 
79
      model_ = dee_shared_model_new(swarm_name.c_str());
 
80
      sig_manager_.Add(new TransactionSignalType(model_,
 
81
                                                 "begin-transaction",
 
82
                                                 sigc::mem_fun(this, &Model<RowAdaptor>::OnTransactionBegin)));
 
83
 
 
84
      sig_manager_.Add(new TransactionSignalType(model_,
 
85
                                                 "end-transaction",
 
86
                                                 sigc::mem_fun(this, &Model<RowAdaptor>::OnTransactionEnd)));
 
87
      break;
 
88
    default:
 
89
      LOG_ERROR(_model_inl_logger) <<  "Unexpected ModelType " << model_type_;
 
90
      break;
 
91
  }
 
92
 
 
93
  model.EmitChanged(model_);
 
94
 
 
95
 
56
96
  renderer_tag_ = dee_model_register_tag(model_, NULL);
57
97
 
58
98
  sig_manager_.Add(new RowSignalType(model_,
66
106
  sig_manager_.Add(new RowSignalType(model_,
67
107
                                     "row-removed",
68
108
                                     sigc::mem_fun(this, &Model<RowAdaptor>::OnRowRemoved)));
69
 
 
70
 
  sig_manager_.Add(new TransactionSignalType(model_,
71
 
                                             "begin-transaction",
72
 
                                             sigc::mem_fun(this, &Model<RowAdaptor>::OnTransactionBegin)));
73
 
 
74
 
  sig_manager_.Add(new TransactionSignalType(model_,
75
 
                                             "end-transaction",
76
 
                                             sigc::mem_fun(this, &Model<RowAdaptor>::OnTransactionEnd)));
77
109
}
78
110
 
79
111
template<class RowAdaptor>
148
180
    return 0;
149
181
}
150
182
 
 
183
template<class RowAdaptor>
 
184
glib::Object<DeeModel> Model<RowAdaptor>::get_model()
 
185
{
 
186
  return model_;
 
187
}
 
188
 
151
189
}
152
190
}
153
191