Back to index

unity  6.0.0
Public Member Functions | Protected Member Functions | Protected Attributes
unity::dash::HomeLens::FiltersMerger Class Reference
Inheritance diagram for unity::dash::HomeLens::FiltersMerger:
Inheritance graph
[legend]
Collaboration diagram for unity::dash::HomeLens::FiltersMerger:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FiltersMerger (glib::Object< DeeModel > target)
void OnSourceRowAdded (DeeModel *model, DeeModelIter *iter)
void OnSourceRowRemoved (DeeModel *model, DeeModelIter *iter)
void OnSourceRowChanged (DeeModel *model, DeeModelIter *iter)
void AddSource (glib::Object< DeeModel > source)

Protected Member Functions

void EnsureRowBuf (DeeModel *source)
DeeModelTag * FindSourceToTargetTag (DeeModel *model)

Protected Attributes

glib::SignalManager sig_manager_
GVariant ** row_buf_
unsigned int n_cols_
glib::Object< DeeModel > target_
std::map< DeeModel
*, DeeModelTag * > 
source_to_target_tags_

Detailed Description

Definition at line 266 of file HomeLens.cpp.


Constructor & Destructor Documentation

Definition at line 323 of file HomeLens.cpp.


Member Function Documentation

void unity::dash::HomeLens::ModelMerger::AddSource ( glib::Object< DeeModel >  source) [inherited]

Definition at line 333 of file HomeLens.cpp.

{
  typedef glib::Signal<void, DeeModel*, DeeModelIter*> RowSignalType;

  if (!source)
  {
    LOG_ERROR(logger) << "Trying to add NULL source to ModelMerger";
    return;
  }

  DeeModelTag* merger_tag = dee_model_register_tag(source, NULL);
  source_to_target_tags_[source.RawPtr()] = merger_tag;

  sig_manager_.Add(new RowSignalType(source.RawPtr(),
                                     "row-added",
                                     sigc::mem_fun(this, &HomeLens::ModelMerger::OnSourceRowAdded)));

  sig_manager_.Add(new RowSignalType(source.RawPtr(),
                                       "row-removed",
                                       sigc::mem_fun(this, &HomeLens::ModelMerger::OnSourceRowRemoved)));

  sig_manager_.Add(new RowSignalType(source.RawPtr(),
                                       "row-changed",
                                       sigc::mem_fun(this, &HomeLens::ModelMerger::OnSourceRowChanged)));
}

Here is the call graph for this function:

void unity::dash::HomeLens::ModelMerger::EnsureRowBuf ( DeeModel *  source) [protected, inherited]

Definition at line 557 of file HomeLens.cpp.

{
  if (G_UNLIKELY (n_cols_ == 0))
  {
    /* We have two things to accomplish here.
     * 1) Allocate the row_buf_, and
     * 2) Make sure that the target model has the correct schema set.
     *
     * INVARIANT: n_cols_ == 0 iff row_buf_ == NULL.
     */

    n_cols_ = dee_model_get_n_columns(model);

    if (n_cols_ == 0)
    {
      LOG_ERROR(logger) << "Source model has not provided a schema for the model merger!";
      return;
    }

    /* Lazily adopt schema from source if we don't have one.
     * If we do have a schema let's validate that they match the source */
    if (dee_model_get_n_columns(target_) == 0)
    {
      dee_model_set_schema_full(target_,
                                dee_model_get_schema(model, NULL),
                                n_cols_);
    }
    else
    {
      unsigned int n_cols1;
      const gchar* const *schema1 = dee_model_get_schema(target_, &n_cols1);
      const gchar* const *schema2 = dee_model_get_schema(model, NULL);

      /* At the very least we should have an equal number of rows */
      if (n_cols_ != n_cols1)
      {
        LOG_ERROR(logger) << "Schema mismatch between source and target model. Expected "
                          << n_cols1 << " columns, but found "
                          << n_cols_ << ".";
        n_cols_ = 0;
        return;
      }

      /* Compare schemas */
      for (unsigned int i = 0; i < n_cols_; i++)
      {
        if (g_strcmp0(schema1[i], schema2[i]) != 0)
        {
          LOG_ERROR(logger) << "Schema mismatch between source and target model. Expected column "
                            << i << " to be '" << schema1[i] << "', but found '"
                            << schema2[i] << "'.";
          n_cols_ = 0;
          return;
        }
      }
    }

    row_buf_ = g_new0 (GVariant*, n_cols_);
  }
}
DeeModelTag * unity::dash::HomeLens::ModelMerger::FindSourceToTargetTag ( DeeModel *  model) [protected, inherited]

Definition at line 618 of file HomeLens.cpp.

{
  return source_to_target_tags_[model];
}
void unity::dash::HomeLens::FiltersMerger::OnSourceRowAdded ( DeeModel *  model,
DeeModelIter *  iter 
) [virtual]

Reimplemented from unity::dash::HomeLens::ModelMerger.

Definition at line 481 of file HomeLens.cpp.

{
  /* Supporting filters on the home screen is possible, but *quite* tricky.
   * So... Discard ALL the rows!
   */
}
void unity::dash::HomeLens::FiltersMerger::OnSourceRowChanged ( DeeModel *  model,
DeeModelIter *  iter 
) [virtual]

Reimplemented from unity::dash::HomeLens::ModelMerger.

Definition at line 552 of file HomeLens.cpp.

{
  /* We aren't adding any rows to the merged model, so nothing to do here */
}
void unity::dash::HomeLens::FiltersMerger::OnSourceRowRemoved ( DeeModel *  model,
DeeModelIter *  iter 
) [virtual]

Reimplemented from unity::dash::HomeLens::ModelMerger.

Definition at line 523 of file HomeLens.cpp.

{
  /* We aren't adding any rows to the merged model, so nothing to do here */
}

Member Data Documentation

unsigned int unity::dash::HomeLens::ModelMerger::n_cols_ [protected, inherited]

Definition at line 206 of file HomeLens.cpp.

GVariant** unity::dash::HomeLens::ModelMerger::row_buf_ [protected, inherited]

Definition at line 205 of file HomeLens.cpp.

Definition at line 204 of file HomeLens.cpp.

std::map<DeeModel*,DeeModelTag*> unity::dash::HomeLens::ModelMerger::source_to_target_tags_ [protected, inherited]

Definition at line 208 of file HomeLens.cpp.

Definition at line 207 of file HomeLens.cpp.


The documentation for this class was generated from the following file: