3 #include "flagrowmaster.h"
4 #include "mainwindow.h"
7 extern Main *mainWindow;
9 /////////////////////////////////////////////////////////////////
11 /////////////////////////////////////////////////////////////////
12 FlagRowMaster::FlagRowMaster()
14 // qDebug()<< "Const FlagRowMaster ()";
16 configureAction = NULL;
19 FlagRowMaster::~FlagRowMaster()
21 // qDebug()<< "Destr FlagRowMaster toolbar=" << toolbar;
24 Flag *FlagRowMaster::createFlag(const QString &path)
26 Flag *flag = new Flag;
33 void FlagRowMaster::createConfigureAction()
39 new QAction(QIcon(":/configure-plus.svg"), QString("add flag"));
40 a->setCheckable(false);
41 a->connect(a, SIGNAL(triggered()), mainWindow, SLOT(addUserFlag()));
43 toolbar->addAction(a);
47 void FlagRowMaster::addActionToToolbar(QAction *a)
53 toolbar->insertAction(configureAction, a);
55 toolbar->addAction(a);
58 Flag *FlagRowMaster::findFlagByUid(const QUuid &uid)
61 while (i <= flags.size() - 1) {
62 if (flags.at(i)->getUuid() == uid)
69 Flag *FlagRowMaster::findFlagByName(const QString &name)
72 while (i <= flags.size() - 1) {
73 if (flags.at(i)->getName() == name)
77 qDebug() << "FR::findFlagByName failed for name " << name;
81 void FlagRowMaster::resetUsedCounter()
83 for (int i = 0; i < flags.size(); ++i)
84 flags.at(i)->setUsed(false);
87 QString FlagRowMaster::saveDef(WriteMode mode)
89 // Write definitions of flags
93 for (int i = 0; i < flags.size(); ++i)
94 if ((mode == AllFlags) || (mode == UsedFlags && flags.at(i)->isUsed()))
95 s += flags.at(i)->getDefinition(prefix);
100 void FlagRowMaster::saveDataToDir(const QString &tmpdir, WriteMode mode)
102 // Save icons to dir, if verbose is set (xml export)
104 // and this standardflag is really used somewhere.
105 // Userflags are written anyway (if master flagrow)
107 for (int i = 0; i < flags.size(); ++i)
108 if ((mode == AllFlags) || (mode == UsedFlags && flags.at(i)->isUsed()))
109 flags.at(i)->saveDataToDir(tmpdir);
112 void FlagRowMaster::setName(const QString &n) { rowName = n; }
114 void FlagRowMaster::setPrefix(const QString &p) { prefix = p; }
116 QString FlagRowMaster::getName() { return rowName; }
118 void FlagRowMaster::setToolBar(QToolBar *tb) { toolbar = tb; }
120 void FlagRowMaster::setEnabled(bool b) { toolbar->setEnabled(b); }
122 void FlagRowMaster::updateToolBar(QList<QUuid> activeUids)
125 for (int i = 0; i < flags.size(); ++i)
126 flags.at(i)->getAction()->setChecked(false);
128 for (int i = 0; i < flags.size(); ++i) {
129 int n = activeUids.indexOf(flags.at(i)->getUuid());
131 flags.at(i)->getAction()->setChecked(true);