mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-21 07:04:52 +02:00
Merge branch 'revert-recursive-subfolder'
A subfolder is currently mostly visual. In the document it is implemented as a subfolder attribute on the parent and folder attribute on the child. The child objects are siblings whether they are put in a subfolder or not. This contributed idea of subfolders in subfolders is a good idea, but currently will lead to many bugs. If the feature is desired a different implementation is required.
This commit is contained in:
@@ -323,8 +323,6 @@ public:
|
||||
const std::string &namesuffix);
|
||||
void autorenameVlans(std::list<libfwbuilder::FWObject*> &obj_list);
|
||||
|
||||
std::string getFolderNameString(libfwbuilder::FWObject *obj);
|
||||
|
||||
void reload();
|
||||
|
||||
void loadObjects();
|
||||
@@ -494,8 +492,6 @@ public:
|
||||
void addSubfolderActions(QList<QAction*> &AddObjectActions, libfwbuilder::FWObject *currentObj, ObjectTreeViewItem *item, bool &addSubfolder);
|
||||
signals:
|
||||
void libraryAccessChanged(bool writable);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -224,39 +224,17 @@ static ObjectTreeViewItem *findUserFolder(ObjectTreeViewItem *parent,
|
||||
{
|
||||
if (folder.isEmpty()) return parent;
|
||||
|
||||
ObjectTreeViewItem *otvi = nullptr;
|
||||
|
||||
int childNo = 0;
|
||||
while(parent->child(childNo) != nullptr && otvi == nullptr) {
|
||||
for (int ii = 0; ii < parent->childCount(); ii++) {
|
||||
ObjectTreeViewItem *sub =
|
||||
dynamic_cast<ObjectTreeViewItem *>(parent->child(childNo));
|
||||
dynamic_cast<ObjectTreeViewItem *>(parent->child(ii));
|
||||
if (sub != nullptr &&
|
||||
sub->getUserFolderParent() != nullptr &&
|
||||
sub->getUserFolderName() == folder) {
|
||||
otvi = sub;
|
||||
return otvi;
|
||||
break;
|
||||
return sub;
|
||||
}
|
||||
else {
|
||||
otvi = findUserFolder(sub, folder);
|
||||
}
|
||||
childNo++;
|
||||
}
|
||||
|
||||
// for (int ii = 0; ii < parent->childCount(); ii++) {
|
||||
// while(parent->childCount() > 0) {
|
||||
// ObjectTreeViewItem *sub =
|
||||
// dynamic_cast<ObjectTreeViewItem *>(parent->child(ii));
|
||||
// if (sub != 0 &&
|
||||
// sub->getUserFolderParent() != 0 &&
|
||||
// sub->getUserFolderName() == folder) {
|
||||
// return sub;
|
||||
// }
|
||||
// parent = sub;
|
||||
// }
|
||||
// }
|
||||
|
||||
return otvi;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +249,7 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
|
||||
obj->getTypeName() + "/hidden")) return nullptr;
|
||||
|
||||
ObjectTreeViewItem *item = itm;
|
||||
if (!obj->getStr("folder").empty()) {
|
||||
if (!obj->getStr("folder").empty()) {
|
||||
item = findUserFolder(itm, obj->getStr("folder").c_str());
|
||||
|
||||
/* If we can't find the user folder, put it under the system
|
||||
@@ -280,7 +258,6 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
|
||||
item = itm;
|
||||
obj->setStr("folder", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ObjectTreeViewItem *nitm = new ObjectTreeViewItem(item);
|
||||
@@ -301,7 +278,6 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
|
||||
}
|
||||
|
||||
nitm->setProperty("type", obj->getTypeName().c_str() );
|
||||
|
||||
nitm->setFWObject( obj );
|
||||
|
||||
allItems[obj] = nitm;
|
||||
@@ -333,9 +309,6 @@ void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj)
|
||||
for (iter = subfolders.begin(); iter != subfolders.end(); ++iter) {
|
||||
ObjectTreeViewItem *sub = new ObjectTreeViewItem(nitm);
|
||||
sub->setUserFolderParent(obj);
|
||||
// FWObject* newFolder = obj->getRoot()->create("ObjectGroup");
|
||||
// newFolder->setParent(obj);
|
||||
// sub->setFWObject(newFolder);
|
||||
QString name = QString::fromUtf8((*iter).c_str());
|
||||
sub->setUserFolderName(name);
|
||||
sub->setText(0, name);
|
||||
@@ -553,7 +526,7 @@ void ObjectManipulator::clearObjects()
|
||||
libs_model->removeRows(0, libs_model->rowCount());
|
||||
|
||||
libs_model->addStaticItems();
|
||||
|
||||
|
||||
current_tree_view = nullptr;
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects done");
|
||||
@@ -804,23 +777,10 @@ void ObjectManipulator::moveItems(ObjectTreeViewItem *dest,
|
||||
void ObjectManipulator::addUserFolderToTree(FWObject *obj,
|
||||
const QString &folder)
|
||||
{
|
||||
|
||||
ObjectTreeViewItem *item = allItems[obj];
|
||||
|
||||
if (item == nullptr) return;
|
||||
|
||||
ObjectTreeViewItem *sub = new ObjectTreeViewItem(item);
|
||||
|
||||
|
||||
FWObject* newFolder = obj->getRoot()->create(ObjectGroup::TYPENAME);
|
||||
newFolder->setParent(obj);
|
||||
newFolder->setName(folder.toUtf8().constData()
|
||||
);
|
||||
sub->setFWObject(newFolder);
|
||||
allItems[newFolder] = sub;
|
||||
obj->setStr("folder", folder.toUtf8().constData());
|
||||
newFolder->setStr("folder", getFolderNameString(newFolder));
|
||||
|
||||
sub->setUserFolderParent(obj);
|
||||
sub->setUserFolderName(folder);
|
||||
sub->setText(0, folder);
|
||||
@@ -829,21 +789,6 @@ void ObjectManipulator::addUserFolderToTree(FWObject *obj,
|
||||
}
|
||||
|
||||
|
||||
std::string ObjectManipulator::getFolderNameString(libfwbuilder::FWObject *obj) {
|
||||
std::string result = "";
|
||||
FWObject *parent = obj->getParent();
|
||||
|
||||
|
||||
while(parent != nullptr) {
|
||||
result = parent->getName() + "/" + result;
|
||||
parent = parent->getParent();
|
||||
}
|
||||
|
||||
result = result + obj->getName();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ObjectManipulator::removeUserFolderFromTree(FWObject *obj,
|
||||
const QString &folder)
|
||||
{
|
||||
@@ -892,4 +837,4 @@ void ObjectManipulator::moveToFromUserFolderInTree(FWObject *obj,
|
||||
refreshSubtree(newItem, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user