Scribus
Open source desktop publishing at your fingertips
resourcecollection.h
1 /*
2  For general Scribus (>=1.3.2) copyright and licensing information please refer
3  to the COPYING file provided with the program. Following this notice may exist
4  a copyright and/or license notice that predates the release of Scribus 1.3.2
5  for which a new license (GPL+exception) is in place.
6  */
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 
17 #ifndef RESOURCE_COLLECTION_H
18 #define RESOURCE_COLLECTION_H
19 
20 #include <QList>
21 #include <QMap>
22 #include <QString>
23 
24 class ColorList;
25 class SCFonts;
26 
41 {
42 public:
43  void collectFont(const QString& name) { if (!name.isEmpty()) m_fonts.insert(name,name); }
44  void collectPattern(const QString& name) { if (!name.isEmpty()) m_patterns.insert(name,name); }
45  void collectColor(const QString& name) { if (!name.isEmpty()) m_colors.insert(name,name); }
46  void collectStyle(const QString& name) { if (!name.isEmpty()) m_pstyles.insert(name,name); }
47  void collectCharStyle(const QString& name) { if (!name.isEmpty()) m_cstyles.insert(name,name); }
48  void collectLineStyle(const QString& name) { if (!name.isEmpty()) m_linestyles.insert(name,name); }
49 
50  void mapFont(const QString& oldname, const QString& newname) { m_fonts.insert(oldname, newname); }
51  void mapPattern(const QString& oldname, const QString& newname) { m_patterns.insert(oldname, newname); }
52  void mapColor(const QString& oldname, const QString& newname) { m_colors.insert(oldname, newname); }
53  void mapStyle(const QString& oldname, const QString& newname) { m_pstyles.insert(oldname, newname); }
54  void mapCharStyle(const QString& oldname, const QString& newname) { m_cstyles.insert(oldname, newname); }
55  void mapLineStyle(const QString& oldname, const QString& newname) { m_linestyles.insert(oldname, newname); }
56 
57  void mapFonts(const QMap<QString,QString>& newnames) { m_fonts = newnames; }
58  void mapPatterns(const QMap<QString,QString>& newnames) { m_patterns = newnames; }
59  void mapColors(const QMap<QString,QString>& newnames) { m_colors = newnames; }
60  void mapStyles(const QMap<QString,QString>& newnames) { m_pstyles = newnames; }
61  void mapCharStyles(const QMap<QString,QString>& newnames) { m_cstyles = newnames; }
62  void mapLineStyles(const QMap<QString,QString>& newnames) { m_linestyles = newnames; }
63 
64  const QMap<QString, QString>& fonts() { return m_fonts; }
65  const QMap<QString, QString>& patterns() { return m_patterns; }
66  const QMap<QString, QString>& colors() { return m_colors; }
67  const QMap<QString, QString>& styles() { return m_pstyles; }
68  const QMap<QString, QString>& charStyles() { return m_cstyles; }
69  const QMap<QString, QString>& lineStyles() { return m_linestyles; }
70 
71  QList<QString> fontNames() const { return m_fonts.keys(); }
72  QList<QString> patternNames() const { return m_patterns.keys(); }
73  QList<QString> colorNames() const { return m_colors.keys(); }
74  QList<QString> styleNames() const { return m_pstyles.keys(); }
75  QList<QString> charStyleNames() const { return m_cstyles.keys(); }
76  QList<QString> lineStyleNames() const { return m_linestyles.keys(); }
77 
78  // modifies newNames so that forall x in both newNames.key() and in existingNames, newNames[x] will map to a new unique name
79  static void makeUnique(QMap<QString,QString>& newNames, const QList<QString> existingNames);
80 
81  void makeNamedResourcesUnique(ResourceCollection& other);
82 
83  SCFonts* availableFonts;
84  ColorList* availableColors;
85 private:
86  QMap<QString,QString> m_fonts;
87  QMap<QString,QString> m_patterns;
88  QMap<QString,QString> m_colors;
89  QMap<QString,QString> m_pstyles;
90  QMap<QString,QString> m_cstyles;
91  QMap<QString,QString> m_linestyles;
92 };
93 
94 
95 #endif
Definition: sccolor.h:155
Definition: resourcecollection.h:41
Main class SCFonts. Subclass of QDict. This class replaces the previous SCFonts typedef...
Definition: scfonts.h:36