~artmello/gallery-app/badcontext_crash

« back to all changes in this revision

Viewing changes to src/checkerboard-agent.cpp

  • Committer: Adam Dingle
  • Date: 2011-12-02 16:50:22 UTC
  • Revision ID: adam@yorba.org-20111202165022-uwvs4abs076oqwgy
Initial commit from Yorba.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical Ltd
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors:
 
17
 * Jim Nelson <jim@yorba.org>
 
18
 * Lucas Beeler <lucas@yorba.org>
 
19
 */
 
20
 
 
21
#include "checkerboard-agent.h"
 
22
 
 
23
#include <QDeclarativeView>
 
24
#include <QDeclarativeItem>
 
25
 
 
26
#include "qml-media-model.h"
 
27
 
 
28
CheckerboardAgent::CheckerboardAgent(QDeclarativeView* view) {
 
29
  // TODO: Clean this up
 
30
  QDeclarativeItem* item =
 
31
    qobject_cast<QDeclarativeItem*>(view->rootObject());
 
32
  Q_ASSERT(item != NULL);
 
33
  
 
34
  QObject* loader = item->findChild<QObject*>("loader");
 
35
  Q_ASSERT(loader != NULL);
 
36
  
 
37
  QObject* checkerboard = loader->findChild<QObject*>("checkerboard");
 
38
  Q_ASSERT(checkerboard != NULL);
 
39
  
 
40
  QObject::connect(checkerboard, SIGNAL(activated(int)), this,
 
41
    SIGNAL(activated(int)));
 
42
  
 
43
  QObject::connect(checkerboard, SIGNAL(selection_toggled(int)), this,
 
44
    SIGNAL(selection_toggled(int)));
 
45
  
 
46
  QObject::connect(checkerboard, SIGNAL(unselect_all()), this,
 
47
    SIGNAL(unselect_all()));
 
48
  
 
49
  grid_ = checkerboard->findChild<QObject*>("grid");
 
50
  Q_ASSERT(grid_ != NULL);
 
51
}