Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AutoTypeAssociations.cpp « core « src - github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5ec4eb3b33aca759a1ca93d27f7af2a1928e308c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 *  Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 or (at your option)
 *  version 3 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "AutoTypeAssociations.h"

bool AutoTypeAssociations::Association::operator==(const AutoTypeAssociations::Association& other) const
{
    return window == other.window && sequence == other.sequence;
}

bool AutoTypeAssociations::Association::operator!=(const AutoTypeAssociations::Association& other) const
{
    return window != other.window || sequence != other.sequence;
}


AutoTypeAssociations::AutoTypeAssociations(QObject* parent)
    : QObject(parent)
{
}

void AutoTypeAssociations::copyDataFrom(const AutoTypeAssociations* other)
{
    if (m_associations == other->m_associations) {
        return;
    }

    emit aboutToReset();
    m_associations = other->m_associations;
    emit reset();
    emit modified();
}

void AutoTypeAssociations::add(const AutoTypeAssociations::Association& association)
{
    int index = m_associations.size();
    emit aboutToAdd(index);
    m_associations.append(association);
    emit added(index);
    emit modified();
}

void AutoTypeAssociations::remove(int index)
{
    Q_ASSERT(index >= 0 && index < m_associations.size());

    emit aboutToRemove(index);
    m_associations.removeAt(index);
    emit removed(index);
    emit modified();
}

void AutoTypeAssociations::removeEmpty()
{
    QMutableListIterator<AutoTypeAssociations::Association> i(m_associations);
    while (i.hasNext()) {
        const Association& assoc = i.next();
        if (assoc.window.isEmpty() && assoc.sequence.isEmpty()) {
            i.remove();
        }
    }
}

void AutoTypeAssociations::update(int index, const AutoTypeAssociations::Association& association)
{
    Q_ASSERT(index >= 0 && index < m_associations.size());

    if (m_associations.at(index) != association) {
        m_associations[index] = association;
        emit dataChanged(index);
        emit modified();
    }
}

AutoTypeAssociations::Association AutoTypeAssociations::get(int index) const
{
    Q_ASSERT(index >= 0 && index < m_associations.size());

    return m_associations.at(index);
}

QList<AutoTypeAssociations::Association> AutoTypeAssociations::getAll() const
{
    return m_associations;
}

int AutoTypeAssociations::size() const
{
    return m_associations.size();
}

void AutoTypeAssociations::clear()
{
    m_associations.clear();
}