2 * This file is part of CameraPlus.
4 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "qtcamscanner.h"
23 #include "qtcamconfig.h"
24 #include "qtcamdevice.h"
27 class QtCameraPrivate {
30 QtCamScanner *scanner;
33 QtCamera::QtCamera(QObject *parent) :
34 QObject(parent), d_ptr(new QtCameraPrivate) {
38 d_ptr->conf = new QtCamConfig(this);
39 d_ptr->scanner = new QtCamScanner(d_ptr->conf, this);
44 QtCamera::QtCamera(const QString& configPath, QObject *parent) :
45 QObject(parent), d_ptr(new QtCameraPrivate) {
49 d_ptr->conf = new QtCamConfig(configPath, this);
50 d_ptr->scanner = new QtCamScanner(d_ptr->conf, this);
55 QtCamera::QtCamera(QtCamConfig *config, QObject *parent) :
56 QObject(parent), d_ptr(new QtCameraPrivate) {
61 d_ptr->scanner = new QtCamScanner(d_ptr->conf, this);
66 QtCamera::~QtCamera() {
67 delete d_ptr; d_ptr = 0;
72 void QtCamera::refreshDevices() {
73 d_ptr->scanner->refresh();
76 QList<QPair<QString, QVariant> > QtCamera::devices() const {
77 return d_ptr->scanner->devices();
80 QtCamDevice *QtCamera::device(const QVariant& id, QObject *parent) {
81 QList<QPair<QString, QVariant> > devs = devices();
83 // G++ barfs with foreach and class templates.
84 typedef QPair<QString, QVariant> Dev;
85 foreach (const Dev& dev, devs) {
86 if (dev.second == id) {
87 return new QtCamDevice(d_ptr->conf, dev.first, dev.second, parent ? parent : this);
94 QtCamConfig *QtCamera::config() const {