7 /////////////////////////////////////////////////////////////////
9 /////////////////////////////////////////////////////////////////
12 // qDebug() << "Const Flag ()";
16 Flag::Flag(const QString &fname)
18 // qDebug() << "Const Flag (fname)" << fname;
21 qWarning() << "Flag::Flag Failed to load " << fname;
26 // qDebug() << "Destr Flag this="<<this <<" " << qPrintable(name) << "
45 uuid = QUuid::createUuid();
48 bool Flag::load(const QString &fn)
51 image = new ImageObj();
56 if (fn.contains("svg")) {
57 image->setWidth(32); // FIXME-3 scale svg of flags
65 void Flag::setName(const QString &n)
68 if (name.contains("/"))
69 name = basename(name);
71 name = name.section('.', 0, 0);
74 const QString Flag::getName() { return name; }
76 const QString Flag::getPath() { return path; }
78 void Flag::setVisible(bool b) { visible = b; }
80 bool Flag::isVisible() { return visible; }
82 void Flag::setGroup(const QString &n) { group = n; }
84 const QString Flag::getGroup() { return group; }
86 void Flag::unsetGroup() { group.clear(); }
88 void Flag::setToolTip(const QString &n) { tooltip = n; }
90 const QString Flag::getToolTip() { return tooltip; }
92 ImageObj *Flag::getImageObj()
100 void Flag::setAction(QAction *a) { action = a; }
102 QAction *Flag::getAction() { return action; }
104 void Flag::setUsed(bool b) { used = b; }
106 bool Flag::isUsed() { return used; }
108 Flag::FlagType Flag::getType() { return type; }
110 void Flag::setType(Flag::FlagType t) { type = t; }
112 void Flag::setUuid(const QUuid &id) { uuid = id; }
114 QUuid Flag::getUuid() { return uuid; }
116 QString Flag::getDefinition(const QString &prefix)
118 if (type == Flag::UserFlag) {
119 QString url = "flags/" + prefix + uuid.toString() + "-" + name +
120 image->getExtension();
121 QStringList attributes;
122 attributes << attribut("name", name);
123 attributes << attribut("href", QString("file:%1").arg(url));
124 attributes << attribut("uuid", uuid.toString());
125 return singleElement("userflagdef", attributes);
131 void Flag::saveDataToDir(const QString &dirPath)
134 path = dirPath + "/" + uuid.toString() + "-" + name +
135 image->getExtension();
140 QString Flag::saveState()
142 if (type == Flag::UserFlag)
143 return singleElement("userflag", attribut("name", name) +
144 attribut("uuid", uuid.toString()));
146 return valueElement("standardflag", name);