~ahayzen/ubuntu-ui-extras/printer-components-fix-empty-commented-tests

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/Extras/Printers/printer/printersignalhandler.cpp

  • Committer: Andrew Hayzen
  • Date: 2017-02-21 10:46:29 UTC
  • Revision ID: ahayzen@gmail.com-20170221104629-pbm454x5k7rr4ot5
* Add printer-components from ubuntu-settings-components to ubuntu-ui-extras (original branch https://code.launchpad.net/~phablet-team/ubuntu-settings-components/printer-components)
* Add plugin module to Extras/Printers
* Add translation support for cpp/h
* Add tests for Printers
* Add debian depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2017 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
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 Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include "printersignalhandler.h"
 
18
 
 
19
PrinterSignalHandler::PrinterSignalHandler(int triggerEventDelay,
 
20
                                           QObject *parent)
 
21
    : QObject(parent)
 
22
{
 
23
    m_timer.setInterval(triggerEventDelay);
 
24
    connect(&m_timer, SIGNAL(timeout()), this, SLOT(process()));
 
25
}
 
26
 
 
27
PrinterSignalHandler::~PrinterSignalHandler()
 
28
{
 
29
}
 
30
 
 
31
void PrinterSignalHandler::process()
 
32
{
 
33
    Q_FOREACH(auto printer, m_unprocessed) {
 
34
        Q_EMIT printerModified(printer);
 
35
    }
 
36
    m_unprocessed.clear();
 
37
    m_timer.stop();
 
38
}
 
39
 
 
40
void PrinterSignalHandler::onPrinterModified(
 
41
    const QString &text, const QString &printerUri,
 
42
    const QString &printerName, uint printerState,
 
43
    const QString &printerStateReason, bool acceptingJobs)
 
44
{
 
45
 
 
46
    Q_UNUSED(text);
 
47
    Q_UNUSED(printerUri);
 
48
    Q_UNUSED(printerState);
 
49
    Q_UNUSED(printerStateReason);
 
50
    Q_UNUSED(acceptingJobs);
 
51
 
 
52
    m_unprocessed << printerName;
 
53
    m_timer.start();
 
54
}
 
55
 
 
56
void PrinterSignalHandler::onPrinterStateChanged(
 
57
    const QString &text, const QString &printerUri,
 
58
    const QString &printerName, uint printerState,
 
59
    const QString &printerStateReason, bool acceptingJobs)
 
60
{
 
61
    Q_UNUSED(text);
 
62
    Q_UNUSED(printerUri);
 
63
    Q_UNUSED(printerState);
 
64
    Q_UNUSED(printerStateReason);
 
65
    Q_UNUSED(acceptingJobs);
 
66
 
 
67
    m_unprocessed << printerName;
 
68
    m_timer.start();
 
69
}