~macslow/unity/backported-remote-add-to-5.0

1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
/*
3
 * Copyright (C) 2011 Canonical Ltd
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 3 as
7
 * published by the Free Software Foundation.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18
 */
19
1276.2.12 by Neil Jagdish Patel
Clean up Model implementation and add tests, incliding support for testing dbus-based services
20
#include "Category.h"
1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
21
1276.2.43 by Neil Jagdish Patel
Put the accessing of DeeModelIters inside the RowAdaptorBase class and use sigc::bind to manipulate those functions for getters - excellent idea by Tim
22
#include <sigc++/bind.h>
23
1276.2.19 by Neil Jagdish Patel
update to coding style
24
namespace unity
25
{
26
namespace dash
27
{
1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
28
1276.2.12 by Neil Jagdish Patel
Clean up Model implementation and add tests, incliding support for testing dbus-based services
29
Category::Category(DeeModel* model,
30
                   DeeModelIter* iter,
1276.2.15 by Neil Jagdish Patel
- Add support for testing Results and Categories
31
                   DeeModelTag* renderer_name_tag)
1276.2.27 by Neil Jagdish Patel
clean up RowAdaptorBase
32
  : RowAdaptorBase(model, iter, renderer_name_tag)
1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
33
{
1276.2.39 by Neil Jagdish Patel
Make copy constructors work
34
  SetupGetters();
35
}
36
37
Category::Category(Category const& other)
1276.3.18 by Neil Jagdish Patel
use default copy constructor
38
  : RowAdaptorBase(other)
1276.2.39 by Neil Jagdish Patel
Make copy constructors work
39
{
40
  SetupGetters();
41
}
42
1276.3.14 by Neil Jagdish Patel
Fix issues raised by Tim
43
Category& Category::operator=(Category const& other)
1276.3.4 by Neil Jagdish Patel
Add tests for category
44
{
1276.3.17 by Neil Jagdish Patel
[merge] parent and fix issues related to that
45
  RowAdaptorBase::operator=(other);
46
  SetupGetters();
1276.3.14 by Neil Jagdish Patel
Fix issues raised by Tim
47
  return *this;
1276.3.4 by Neil Jagdish Patel
Add tests for category
48
}
49
1276.2.39 by Neil Jagdish Patel
Make copy constructors work
50
void Category::SetupGetters()
51
{
1276.2.43 by Neil Jagdish Patel
Put the accessing of DeeModelIters inside the RowAdaptorBase class and use sigc::bind to manipulate those functions for getters - excellent idea by Tim
52
  name.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 0));
53
  icon_hint.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 1));
1276.2.12 by Neil Jagdish Patel
Clean up Model implementation and add tests, incliding support for testing dbus-based services
54
  index.SetGetterFunction(sigc::mem_fun(this, &Category::get_index));
1276.2.43 by Neil Jagdish Patel
Put the accessing of DeeModelIters inside the RowAdaptorBase class and use sigc::bind to manipulate those functions for getters - excellent idea by Tim
55
  renderer_name.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 2));
1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
56
}
57
1276.2.32 by Neil Jagdish Patel
s/unsigned int/std::size_t
58
std::size_t Category::get_index() const
1276.2.9 by Neil Jagdish Patel
Update and add models that use the new Category interface
59
{
60
  return dee_model_get_position(model_, iter_);
61
}
62
63
}
64
}