~ubuntu-branches/debian/sid/scribus/sid

« back to all changes in this revision

Viewing changes to scribus/chartablemodel.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-09 21:50:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120209215056-2wrx1ara0jbm7fi5
Tags: 1.4.0.dfsg+r17287-1
* New upstream stable release upload into Debian (Closes: #654703).
* Applied the Ubuntu armel patch.
* Removed non-free color swatches from resources.
* debian/control:
  - Moved icc-profiles from Recommends to Suggests (Closes: #655885).
  - Updated Standards-Version to 3.9.2.
  - Updated extended description per lintian warning.
* debian/rules:
  - Update mailcap (Closes: #630751). A request for mime.types update has
    been sent to the mime-support maintainer.
  - Added build-arch and build-indep targets per lintian warning.
* debian/patches:
  - top_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't copy extra docs and changelogs.
  - scribus_cmakelists.patch - don't install the non-free "doc" dir.
  - profiles_cmakelists.patch - don't install non-free sRGB profile.
* debian/copyright: 
  - Converted to the DEP5 machine readable foramt.
  - Added licenses for free color swatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
{
22
22
        m_selectionModel = new QItemSelectionModel(this);
23
23
        m_characters.clear();
 
24
        m_fonts.clear();
24
25
}
25
26
 
26
27
int CharTableModel::rowCount(const QModelIndex & parent) const
40
41
 
41
42
        int ix = index.row() * m_cols + index.column();
42
43
        int currentChar;
 
44
        QString currentFont = m_fontInUse;
43
45
        if (ix < m_characters.count())
44
 
                currentChar = m_characters[ix];
 
46
        {
 
47
                currentChar = m_characters[ix];
 
48
                currentFont = m_fonts[ix];
 
49
        }
45
50
        else
46
51
                return QVariant();
47
52
 
48
53
        // for mimeData()
49
54
        if (role == Qt::AccessibleTextRole)
50
 
                return m_characters[ix];
 
55
                return QString("%1#%2").arg(currentChar).arg(currentFont);
51
56
 
52
57
        // tooltip
53
58
        if (role == Qt::ToolTipRole)
65
70
                QMatrix chma;
66
71
                chma.scale(baseSize/10, baseSize/10);
67
72
 
68
 
                ScFace face = (*m_doc->AllFonts)[m_fontInUse];
 
73
                ScFace face = (*m_doc->AllFonts)[currentFont];
69
74
                uint gl = face.char2CMap(currentChar);
70
75
                int size = baseSize + qRound(-face.descent() * baseSize) + 1;
71
76
                double ww = baseSize - face.glyphWidth(gl, baseSize);
109
114
void CharTableModel::setCharacters(CharClassDef ch)
110
115
{
111
116
        m_characters.clear();
112
 
        m_characters = ch;
113
 
        reset();
 
117
        m_fonts.clear();
 
118
        m_characters = ch;
 
119
        for (int a = 0; a < m_characters.count(); a++)
 
120
        {
 
121
                m_fonts.append(m_fontInUse);
 
122
        }
 
123
        reset();
 
124
}
 
125
 
 
126
void CharTableModel::setCharactersAndFonts(CharClassDef ch, QStringList fonts)
 
127
{
 
128
        m_characters.clear();
 
129
        m_fonts.clear();
 
130
        m_characters = ch;
 
131
        m_fonts = fonts;
 
132
        reset();
 
133
}
 
134
 
 
135
void CharTableModel::addCharacter(QString ch)
 
136
{
 
137
        int orig = rowCount();
 
138
        bool ok;
 
139
        int a = ch.indexOf(" ");
 
140
        QString si = ch.left(a);
 
141
        QString sf = ch.mid(a+1);
 
142
        int val = si.toInt(&ok, 10);
 
143
        if (!ok)
 
144
                return;
 
145
        m_characters.append(val);
 
146
        m_fonts.append(sf);
 
147
        reset();
 
148
        if (orig < rowCount())
 
149
                emit rowAppended();
114
150
}
115
151
 
116
152
void CharTableModel::setFontInUse(QString font)
126
162
{
127
163
        int orig = rowCount();
128
164
        bool ok;
129
 
        int val = s.toInt(&ok, base);
 
165
        int a = s.indexOf("#");
 
166
        QString si = s.left(a);
 
167
        QString sf = s.mid(a+1);
 
168
        int val = si.toInt(&ok, base);
130
169
        if (!ok)
131
170
                return;
132
171
 
133
 
        if (!m_characters.contains(val))
 
172
        if ((!m_characters.contains(val)) || (!m_fonts.contains(sf)))
134
173
        {
135
174
                m_characters.append(val);
 
175
                m_fonts.append(sf);
136
176
                reset();
137
177
        }
138
178
        else
154
194
        if (index >= 0 && index < m_characters.size())
155
195
        {
156
196
                m_characters.removeAt(index);
 
197
                m_fonts.removeAt(index);
157
198
                reset();
158
199
                return true;
159
200
        }