mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-23 19:57:21 +01:00
fixed #1728 "Update Library drop down menu". Library drop down
list shows an item "Object libraries:" at the top that can not be selected and that always stays on top as libraries are added, removed and renamed.
This commit is contained in:
parent
2345f13be1
commit
dce2f5b402
@ -1,4 +1,14 @@
|
||||
2010-09-25 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
2010-09-26 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* listOfLibrariesModel.cpp (ListOfLibrariesModel::addStaticItems):
|
||||
fixed #1728 "Update Library drop down menu". Library drop down
|
||||
list shows an item "Object libraries:" at the top that can not be
|
||||
selected and that always stays on top as libraries are added,
|
||||
removed and renamed. The list always stays sorted in ascending
|
||||
order. Library names are indented by 2 spaces to make them
|
||||
visually distinguishable from the prompt item at the
|
||||
top. Implementation uses class ListOfLibrariesModel that inherits
|
||||
QStringListModel.
|
||||
|
||||
* PrefsDialog.cpp (PrefsDialog::PrefsDialog): fixed #1739 "remove
|
||||
"tooltip delay" input form preferences dialog". Qt4 does not allow
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "FWCmdChange.h"
|
||||
#include "FWCmdMoveObject.h"
|
||||
#include "FWWindow.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "events.h"
|
||||
|
||||
#include "fwbuilder/Firewall.h"
|
||||
@ -164,9 +165,18 @@ void FWCmdMoveObject::notify()
|
||||
{
|
||||
if (Library::isA(obj))
|
||||
{
|
||||
// looks like the object that moved into Deleted Objects is
|
||||
// another library. Show Deleted Objects library.
|
||||
new_obj = current_parent;
|
||||
// // See #1740
|
||||
// // looks like the object that moved into Deleted Objects is
|
||||
// // another library. Show Deleted Objects library if it is enabled.
|
||||
// //
|
||||
// if (fwbdebug)
|
||||
// qDebug() << "Moved library to Deleted objects"
|
||||
// << "old_parent=" << old_parent;
|
||||
|
||||
// if (st->getBool("UI/ShowDeletedObjects"))
|
||||
new_obj = current_parent;
|
||||
// else
|
||||
// new_obj = old_parent; // this does not work!
|
||||
}else
|
||||
new_obj = old_parent;
|
||||
} else
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#include "platforms.h"
|
||||
#include "events.h"
|
||||
|
||||
|
||||
#include "listOfLibrariesModel.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjectManipulator.h"
|
||||
#include "ObjectEditor.h"
|
||||
@ -99,11 +99,14 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
|
||||
|
||||
HistoryItem::~HistoryItem() {}
|
||||
|
||||
ObjectManipulator::~ObjectManipulator()
|
||||
{
|
||||
delete m_objectManipulator;
|
||||
delete libs_model;
|
||||
}
|
||||
|
||||
ObjectManipulator::ObjectManipulator(QWidget *parent):
|
||||
@ -113,6 +116,9 @@ ObjectManipulator::ObjectManipulator(QWidget *parent):
|
||||
m_objectManipulator->setupUi(this);
|
||||
setObjectName(tr("Object Manipulator"));
|
||||
|
||||
libs_model = new ListOfLibrariesModel();
|
||||
m_objectManipulator->libs->setModel(libs_model);
|
||||
|
||||
m_project = NULL;
|
||||
|
||||
treeWidth = -1;
|
||||
@ -133,6 +139,18 @@ void ObjectManipulator::setupProject(ProjectPanel *project)
|
||||
m_project = project;
|
||||
}
|
||||
|
||||
vector<QTreeWidget*> ObjectManipulator::getTreeWidgets()
|
||||
{
|
||||
vector<QTreeWidget*> res;
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
|
||||
if (objTreeView == NULL) continue;
|
||||
res.push_back(objTreeView);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method decides what should be shown in the column #1 of the
|
||||
* tree for the given object
|
||||
@ -162,28 +180,28 @@ void ObjectManipulator::showDeletedObjects(bool f)
|
||||
m_project->db()->add(dobj);
|
||||
}
|
||||
|
||||
int idx = getIdxForLib(dobj);
|
||||
QModelIndex idx = libs_model->getIdxForLib(dobj);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::showDeletedObjects idx=%d", idx);
|
||||
qDebug("ObjectManipulator::showDeletedObjects idx.row()=%d", idx.row());
|
||||
|
||||
if (f)
|
||||
{
|
||||
if (idx>=0) return;
|
||||
if (idx.isValid()) return;
|
||||
addLib( dobj );
|
||||
openLib( dobj );
|
||||
} else
|
||||
{
|
||||
if (idx<0) return;
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
QTreeWidget *otv = idxToTrees[idx];
|
||||
QTreeWidget *otv = libs_model->getTreeWidget(idx);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::showDeletedObjects otv=%p", otv);
|
||||
|
||||
assert(otv!=NULL);
|
||||
m_objectManipulator->widgetStack->removeWidget( otv );
|
||||
removeLib(idx);
|
||||
removeLib(idx.row());
|
||||
}
|
||||
}
|
||||
catch(FWException &ex)
|
||||
@ -194,25 +212,6 @@ void ObjectManipulator::showDeletedObjects(bool f)
|
||||
}
|
||||
}
|
||||
|
||||
int ObjectManipulator::getIdxForLib(FWObject* lib)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ObjectManipulator::getIdxForLib"
|
||||
<< "lib=" << lib->getName().c_str();
|
||||
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
{
|
||||
if ( idxToLibs[i]->getId() == lib->getId() )
|
||||
{
|
||||
if (fwbdebug) qDebug() << "Index=" << i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if (fwbdebug) qDebug() << "Library not found";
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString ObjectManipulator::getStandardName(FWObject *parent,
|
||||
const string&,
|
||||
const string &namesuffix)
|
||||
@ -409,24 +408,25 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
FWObject *cl = getCurrentLib();
|
||||
vector<FWObject*>::iterator i;
|
||||
|
||||
for (i=idxToLibs.begin(); i!=idxToLibs.end(); ++i,++libid)
|
||||
int N = libs_model->rowCount();
|
||||
for (int i=0 ; i<N; ++i)
|
||||
{
|
||||
FWObject *lib = *i;
|
||||
|
||||
QModelIndex idx = libs_model->index(i, 0);
|
||||
FWObject *lib = libs_model->getLibrary(idx);
|
||||
if (lib == NULL) continue;
|
||||
if ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||
lib->isReadOnly())
|
||||
continue;
|
||||
if (lib == cl) continue; // skip current library
|
||||
|
||||
dupID = duptargets->addAction(
|
||||
tr("place in library %1").arg(
|
||||
QString::fromUtf8(lib->getName().c_str())));
|
||||
dupID->setData(libid);
|
||||
|
||||
/* can't move to the same library or if selected object is
|
||||
* a library
|
||||
*/
|
||||
if (!libSelected && lib!=cl)
|
||||
// can't move to the same library
|
||||
if (!libSelected)
|
||||
{
|
||||
moveTargetsCounter++;
|
||||
QAction* mact = movetargets->addAction(
|
||||
@ -436,7 +436,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
popup_menu->addSeparator();
|
||||
|
||||
QAction *copyID = popup_menu->addAction(tr("Copy"), this, SLOT(copyObj()));
|
||||
@ -451,7 +451,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
popup_menu->addSeparator();
|
||||
|
||||
QList<QAction*> AddObjectActions;
|
||||
|
||||
|
||||
if (getCurrentObjectTree()->getNumSelected()==1)
|
||||
{
|
||||
|
||||
@ -686,7 +686,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
popup_menu->addAction( tr("Where used"), this, SLOT( findWhereUsedSlot()));
|
||||
}
|
||||
|
||||
|
||||
popup_menu->addSeparator();
|
||||
popup_menu->addAction( tr("Group"), this, SLOT( groupObjects() ) )
|
||||
->setDisabled(getCurrentObjectTree()->getNumSelected()==1);
|
||||
@ -850,8 +850,12 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
|
||||
FWObject *del_obj_library =
|
||||
m_project->db()->findInIndex( FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::getMenuState del_obj_library=" << del_obj_library;
|
||||
|
||||
FWObject *current_library = getCurrentLib();
|
||||
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::getMenuState current_library=" << current_library;
|
||||
|
||||
if (getCurrentObjectTree()==NULL) return;
|
||||
|
||||
// delete, cut and copy menu items will be enabled only if all
|
||||
@ -1255,10 +1259,10 @@ void ObjectManipulator::openLibForObject(FWObject *obj)
|
||||
// library, getIdxForLib() is not going to find it.
|
||||
if (FWObjectDatabase::isA(obj->getParent()))
|
||||
m_objectManipulator->libs->setCurrentIndex(
|
||||
getIdxForLib(obj->getLibrary()));
|
||||
libs_model->getIdxForLib(obj->getLibrary()).row());
|
||||
else
|
||||
m_objectManipulator->libs->setCurrentIndex(
|
||||
getIdxForLib(obj->getParent()->getLibrary()));
|
||||
libs_model->getIdxForLib(obj->getParent()->getLibrary()).row());
|
||||
}
|
||||
|
||||
void ObjectManipulator::showObjectInTree(ObjectTreeViewItem *otvi)
|
||||
@ -1300,11 +1304,14 @@ void ObjectManipulator::expandObjectInTree(FWObject *obj)
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManipulator::libChangedById(int id)
|
||||
void ObjectManipulator::libChangedById(int obj_id)
|
||||
{
|
||||
for (vector<FWObject*>::size_type i = 0 ; i < idxToLibs.size(); i++)
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
if (idxToLibs[i]->getId()==id)
|
||||
QModelIndex idx = libs_model->index(i, 0);
|
||||
FWObject *l = libs_model->getLibrary(idx);
|
||||
if (l == NULL) continue;
|
||||
if (l->getId() == obj_id)
|
||||
{
|
||||
libChanged(i);
|
||||
m_objectManipulator->libs->setCurrentIndex(i);
|
||||
@ -1317,49 +1324,61 @@ void ObjectManipulator::changeFirstNotSystemLib()
|
||||
{
|
||||
QString sid2 = "syslib000";
|
||||
QString sid3 = "syslib001";
|
||||
for (vector<FWObject*>::size_type i = 0 ; i < idxToLibs.size(); i++)
|
||||
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
QString sid1 = FWObjectDatabase::getStringId(idxToLibs[i]->getId()).c_str();
|
||||
if ( sid1 != sid2)
|
||||
QModelIndex idx = libs_model->index(i, 0);
|
||||
FWObject *l = libs_model->getLibrary(idx);
|
||||
if (l == NULL) continue;
|
||||
QString sid1 = FWObjectDatabase::getStringId(l->getId()).c_str();
|
||||
if ( sid1 != sid2 && sid1!=sid3)
|
||||
{
|
||||
if (sid1!=sid3)
|
||||
{
|
||||
libChanged(i);
|
||||
m_objectManipulator->libs->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
libChanged(i);
|
||||
m_objectManipulator->libs->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManipulator::libChanged(int ln)
|
||||
void ObjectManipulator::libChanged(int list_row)
|
||||
{
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::libChanged ln=" << ln;
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::libChanged list_row=" << list_row;
|
||||
|
||||
previous_lib_index = ln;
|
||||
previous_lib_index = list_row;
|
||||
|
||||
QTreeWidget *lv = idxToTrees[ln];
|
||||
assert(lv!=NULL);
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(list_row);
|
||||
if (objTreeView == NULL)
|
||||
{
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug() << "There is no object tree widget associated with this row";
|
||||
qDebug() << "Scanning all rows:";
|
||||
|
||||
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(lv->currentItem());
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
qDebug() << "Row" << i;
|
||||
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
|
||||
FWObject *lib = libs_model->getLibrary(i);
|
||||
|
||||
qDebug() << "lib=" << lib << "objTreeView=" << objTreeView;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(objTreeView->currentItem());
|
||||
if (otvi == NULL)
|
||||
{
|
||||
if (lv->invisibleRootItem()->childCount() > 0)
|
||||
if (objTreeView->invisibleRootItem()->childCount() > 0)
|
||||
otvi = dynamic_cast<ObjectTreeViewItem*>(
|
||||
lv->invisibleRootItem()->child(0));
|
||||
objTreeView->invisibleRootItem()->child(0));
|
||||
else
|
||||
assert(FALSE);
|
||||
}
|
||||
|
||||
showObjectInTree( otvi );
|
||||
|
||||
// switching libraries does not open new lib in the editor
|
||||
// if (mw->isEditorVisible()) mw->openEditor(getSelectedObject());
|
||||
|
||||
//updateCreateObjectMenu( idxToLibs[ln] );
|
||||
|
||||
QCoreApplication::postEvent(mw, new updateGUIStateEvent());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1382,7 +1401,9 @@ FWObject* ObjectManipulator::getCurrentLib()
|
||||
{
|
||||
int idx = m_objectManipulator->libs->currentIndex();
|
||||
if (idx == -1 ) return NULL;
|
||||
FWObject *lib = idxToLibs[idx];
|
||||
|
||||
FWObject *lib = libs_model->getLibrary(idx);
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("ObjectManipulator::getCurrentLib(): idx=%d lib=%p", idx, lib);
|
||||
@ -1393,7 +1414,9 @@ FWObject* ObjectManipulator::getCurrentLib()
|
||||
|
||||
ObjectTreeView* ObjectManipulator::getCurrentObjectTree()
|
||||
{
|
||||
return current_tree_view;
|
||||
return libs_model->getTreeWidget(m_objectManipulator->libs->currentIndex());
|
||||
|
||||
// return current_tree_view;
|
||||
}
|
||||
|
||||
void ObjectManipulator::openLib(FWObject *obj)
|
||||
@ -1417,7 +1440,8 @@ void ObjectManipulator::select()
|
||||
|
||||
if (currentObj==NULL) return;
|
||||
|
||||
m_objectManipulator->libs->setCurrentIndex(getIdxForLib(currentObj->getLibrary()));
|
||||
m_objectManipulator->libs->setCurrentIndex(
|
||||
libs_model->getIdxForLib(currentObj->getLibrary()).row());
|
||||
|
||||
// TODO: I forget why do we need flag "active", check this.
|
||||
ObjectTreeViewItem *otvi = allItems[currentObj];
|
||||
@ -1434,9 +1458,13 @@ void ObjectManipulator::unselect()
|
||||
FWObject *currentObj = getSelectedObject();
|
||||
if (currentObj==NULL) return;
|
||||
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
idxToTrees[i]->clearSelection();
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
QTreeWidget *otv = libs_model->getTreeWidget(i);
|
||||
if (otv == NULL) continue;
|
||||
|
||||
otv->clearSelection();
|
||||
}
|
||||
active=false;
|
||||
}
|
||||
|
||||
@ -1504,12 +1532,6 @@ FWObject* ObjectManipulator::getSelectedObject()
|
||||
return otvi->getFWObject();
|
||||
}
|
||||
return NULL;
|
||||
|
||||
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
|
||||
if (so.size() > 0) return so.front();
|
||||
return NULL;
|
||||
|
||||
// return currentObj;
|
||||
}
|
||||
|
||||
void ObjectManipulator::reopenCurrentItemParent()
|
||||
@ -1525,11 +1547,12 @@ void ObjectManipulator::reopenCurrentItemParent()
|
||||
|
||||
void ObjectManipulator::loadSectionSizes()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
|
||||
FWObject *lib = libs_model->getLibrary(i);
|
||||
if (lib == NULL || objTreeView == NULL) continue;
|
||||
|
||||
objTreeView->header()->resizeSection(
|
||||
0,
|
||||
st->getTreeSectionSize(
|
||||
@ -1543,11 +1566,12 @@ void ObjectManipulator::loadSectionSizes()
|
||||
|
||||
void ObjectManipulator::saveSectionSizes()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
|
||||
FWObject *lib = libs_model->getLibrary(i);
|
||||
if (lib == NULL || objTreeView == NULL) continue;
|
||||
|
||||
st->setTreeSectionSize(
|
||||
m_project->getFileName(), lib->getName().c_str(), 0,
|
||||
objTreeView->header()->sectionSize(0));
|
||||
@ -1559,11 +1583,16 @@ void ObjectManipulator::saveSectionSizes()
|
||||
|
||||
void ObjectManipulator::loadExpandedTreeItems()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::loadExpandedTreeItems()";
|
||||
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
if (fwbdebug) qDebug() << "i=" << i;
|
||||
|
||||
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
|
||||
FWObject *lib = libs_model->getLibrary(i);
|
||||
if (lib == NULL || objTreeView == NULL) continue;
|
||||
|
||||
set<int> expanded_objects;
|
||||
st->getExpandedObjectIds(m_project->getFileName(),
|
||||
lib->getName().c_str(),
|
||||
@ -1577,11 +1606,12 @@ void ObjectManipulator::loadExpandedTreeItems()
|
||||
|
||||
void ObjectManipulator::saveExpandedTreeItems()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
|
||||
FWObject *lib = libs_model->getLibrary(i);
|
||||
if (lib == NULL || objTreeView == NULL) continue;
|
||||
|
||||
st->setExpandedObjectIds(m_project->getFileName(),
|
||||
lib->getName().c_str(),
|
||||
objTreeView->getListOfExpandedObjectIds());
|
||||
@ -1590,10 +1620,10 @@ void ObjectManipulator::saveExpandedTreeItems()
|
||||
|
||||
void ObjectManipulator::setAttributesColumnEnabled(bool)
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
for (int i=0; i<libs_model->rowCount(); ++i)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
|
||||
if (objTreeView == NULL) continue;
|
||||
objTreeView->showOrHideAttributesColumn();
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ class QComboBox;
|
||||
class QPixmap;
|
||||
class QUndoCommand;
|
||||
|
||||
class ListOfLibrariesModel;
|
||||
class ProjectPanel;
|
||||
|
||||
|
||||
@ -82,12 +83,15 @@ public:
|
||||
bool operator()(const HistoryItem &itm);
|
||||
};
|
||||
|
||||
|
||||
class ObjectManipulator : public QWidget
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
std::vector<libfwbuilder::FWObject*> idxToLibs;
|
||||
std::vector<QTreeWidget*> idxToTrees;
|
||||
ListOfLibrariesModel *libs_model;
|
||||
// std::vector<libfwbuilder::FWObject*> idxToLibs;
|
||||
// std::vector<QTreeWidget*> idxToTrees;
|
||||
|
||||
int previous_lib_index;
|
||||
QSet<int> ids ;
|
||||
std::list<HistoryItem> history;
|
||||
@ -124,7 +128,6 @@ class ObjectManipulator : public QWidget
|
||||
|
||||
void setObjectIcon(libfwbuilder::FWObject *obj, QPixmap *pm);
|
||||
|
||||
int getIdxForLib(libfwbuilder::FWObject*);
|
||||
void removeLib(int idx);
|
||||
|
||||
void makeNameUnique(libfwbuilder::FWObject* p,libfwbuilder::FWObject* obj);
|
||||
@ -257,6 +260,8 @@ public slots:
|
||||
|
||||
public:
|
||||
|
||||
Ui::ObjectManipulator_q *m_objectManipulator;
|
||||
|
||||
ObjectManipulator(QWidget *parent);
|
||||
~ObjectManipulator();
|
||||
|
||||
@ -264,8 +269,9 @@ public:
|
||||
|
||||
void libChangedById(int id);
|
||||
void changeFirstNotSystemLib();
|
||||
std::vector<QTreeWidget*> getTreeWidgets() { return idxToTrees;};
|
||||
Ui::ObjectManipulator_q *m_objectManipulator;
|
||||
|
||||
std::vector<QTreeWidget*> getTreeWidgets();
|
||||
|
||||
void filterFirewallsFromSelection(
|
||||
std::vector<libfwbuilder::FWObject*> &so,
|
||||
std::set<libfwbuilder::Firewall*> &fo);
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include "platforms.h"
|
||||
#include "events.h"
|
||||
|
||||
#include "listOfLibrariesModel.h"
|
||||
#include "ObjectManipulator.h"
|
||||
#include "ObjectTreeView.h"
|
||||
#include "newFirewallDialog.h"
|
||||
@ -285,7 +286,9 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
|
||||
break;
|
||||
}
|
||||
|
||||
lib= idxToLibs[i];
|
||||
// lib = idxToLibs[i];
|
||||
|
||||
lib = libs_model->getLibrary(i);
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
@ -344,7 +347,10 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
||||
lib=getCurrentLib();
|
||||
break;
|
||||
}
|
||||
lib= idxToLibs[i];
|
||||
// lib = idxToLibs[i];
|
||||
|
||||
lib = libs_model->getLibrary(i);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#include "platforms.h"
|
||||
#include "events.h"
|
||||
|
||||
#include "listOfLibrariesModel.h"
|
||||
#include "ObjectManipulator.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
@ -81,7 +82,7 @@ void ObjectManipulator::moveObj(QAction* action)
|
||||
ot->freezeSelection(true);
|
||||
FWObject *obj;
|
||||
|
||||
FWObject *targetLib = idxToLibs[libid];
|
||||
FWObject *targetLib = libs_model->getLibrary(libid);
|
||||
|
||||
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
|
||||
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
|
||||
@ -233,7 +234,9 @@ void ObjectManipulator::duplicateObj(QAction *action)
|
||||
{
|
||||
obj= *i;
|
||||
if ( FWBTree().isSystem(obj) || Interface::isA(obj) ) continue;
|
||||
FWObject *cl = idxToLibs[libid];
|
||||
|
||||
FWObject *cl = libs_model->getLibrary(libid);
|
||||
|
||||
nobj = duplicateObject(cl, obj);
|
||||
}
|
||||
if (nobj) editObject(nobj);
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "utils_no_qt.h"
|
||||
#include "platforms.h"
|
||||
|
||||
#include "listOfLibrariesModel.h"
|
||||
#include "ObjectManipulator.h"
|
||||
#include "ObjectEditor.h"
|
||||
#include "ObjectTreeViewItem.h"
|
||||
@ -141,7 +142,6 @@ using namespace libfwbuilder;
|
||||
#define OBJTREEVIEW_WIDGET_NAME "ObjTreeView"
|
||||
|
||||
|
||||
|
||||
ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
|
||||
FWObject *obj)
|
||||
{
|
||||
@ -246,11 +246,11 @@ void ObjectManipulator::removeObjectFromTreeView(FWObject *obj)
|
||||
{
|
||||
removeObjectFromHistory(obj);
|
||||
|
||||
// QTreeWidget *objTreeView = idxToTrees[ getIdxForLib(getCurrentLib()) ];
|
||||
int current_lib_idx = m_objectManipulator->libs->currentIndex();
|
||||
QTreeWidget *objTreeView = idxToTrees[current_lib_idx];
|
||||
|
||||
ObjectTreeView *objTreeView = libs_model->getTreeWidget(current_lib_idx);
|
||||
assert(objTreeView);
|
||||
dynamic_cast<ObjectTreeView*>(objTreeView)->clearLastSelected();
|
||||
objTreeView->clearLastSelected();
|
||||
|
||||
ObjectTreeViewItem *itm = allItems[obj];
|
||||
allItems[obj] = NULL;
|
||||
@ -259,6 +259,11 @@ void ObjectManipulator::removeObjectFromTreeView(FWObject *obj)
|
||||
itm->parent()->takeChild(itm->parent()->indexOfChild(itm));
|
||||
delete itm;
|
||||
}
|
||||
|
||||
if (Library::isA(obj))
|
||||
{
|
||||
removeLib(obj);
|
||||
}
|
||||
}
|
||||
|
||||
bool FindHistoryItemByObjectId::operator()(const HistoryItem &itm)
|
||||
@ -281,33 +286,16 @@ void ObjectManipulator::removeObjectFromHistory(FWObject *obj)
|
||||
<< "history.size()=" << history.size();
|
||||
|
||||
if (history.empty()) mw->enableBackAction();
|
||||
|
||||
#if 0
|
||||
int obj_id = obj->getId();
|
||||
list<HistoryItem> tmp_list;
|
||||
while (!history.empty())
|
||||
{
|
||||
HistoryItem itm = history.top();
|
||||
history.pop();
|
||||
if (obj_id == itm.id()) continue;
|
||||
tmp_list.push_back(itm);
|
||||
}
|
||||
|
||||
while (!tmp_list.empty())
|
||||
{
|
||||
history.push(tmp_list.back());
|
||||
tmp_list.pop_back();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObjectManipulator::updateLibColor(FWObject *lib)
|
||||
{
|
||||
QString clr = lib->getStr("color").c_str();
|
||||
int index = getIdxForLib(lib);
|
||||
if (index >= 0)
|
||||
QModelIndex index = libs_model->getIdxForLib(lib);
|
||||
if (index.isValid())
|
||||
{
|
||||
QTreeWidget *objTreeView = idxToTrees[index];
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(index);
|
||||
|
||||
if (clr=="" || clr=="#000000" || clr=="black") clr="#FFFFFF";
|
||||
QPalette palette = objTreeView->palette();
|
||||
palette.setColor(QPalette::Active, QPalette::Base, QColor( clr ));
|
||||
@ -318,11 +306,14 @@ void ObjectManipulator::updateLibColor(FWObject *lib)
|
||||
|
||||
void ObjectManipulator::updateLibName(FWObject *lib)
|
||||
{
|
||||
int index = getIdxForLib(lib);
|
||||
if (index >= 0)
|
||||
QModelIndex index = libs_model->getIdxForLib(lib);
|
||||
if (index.isValid())
|
||||
{
|
||||
QString newlibname = QString::fromUtf8(lib->getName().c_str());
|
||||
m_objectManipulator->libs->setItemText(index, newlibname);
|
||||
libs_model->setName(index, newlibname);
|
||||
libs_model->sort(0, Qt::AscendingOrder);
|
||||
QModelIndex lib_idx = libs_model->getIdxForLib(lib);
|
||||
m_objectManipulator->libs->setCurrentIndex(lib_idx.row());
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,28 +357,23 @@ void ObjectManipulator::clearObjects()
|
||||
|
||||
while (history.size()!=0) history.pop_back();
|
||||
|
||||
int N = m_objectManipulator->libs->count();
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("ObjectManipulator::clearObjects %d libs, "
|
||||
"idxToLibs size: %d, idxToTrees size: %d", N,
|
||||
int(idxToLibs.size()),
|
||||
int(idxToTrees.size()));
|
||||
}
|
||||
int N = libs_model->rowCount();
|
||||
|
||||
for (int i=N-1; i>=0; i--)
|
||||
{
|
||||
QTreeWidget *otv = idxToTrees[i];
|
||||
assert(otv!=NULL);
|
||||
m_objectManipulator->widgetStack->removeWidget( otv );
|
||||
|
||||
QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
|
||||
if (objTreeView == NULL) continue;
|
||||
m_objectManipulator->widgetStack->removeWidget(objTreeView);
|
||||
// delete otv;
|
||||
|
||||
removeLib(i);
|
||||
}
|
||||
idxToLibs.clear();
|
||||
idxToTrees.clear();
|
||||
m_objectManipulator->libs->clear();
|
||||
|
||||
libs_model->removeRows(0, libs_model->rowCount());
|
||||
|
||||
libs_model->addStaticItems();
|
||||
|
||||
current_tree_view = NULL;
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects done");
|
||||
@ -448,29 +434,30 @@ void ObjectManipulator::loadObjects()
|
||||
|
||||
void ObjectManipulator::addLib(FWObject *lib)
|
||||
{
|
||||
if (fwbdebug) qDebug("Object Manipulator::addLib lib: %s",
|
||||
lib->getName().c_str());
|
||||
if (fwbdebug) qDebug() << "Object Manipulator::addLib lib: " << lib->getName().c_str();
|
||||
|
||||
ObjectTreeView *objTreeView = new ObjectTreeView(
|
||||
m_project, m_objectManipulator->widgetStack, OBJTREEVIEW_WIDGET_NAME );
|
||||
|
||||
QString newlibname = QString::fromUtf8(lib->getName().c_str());
|
||||
int N = m_objectManipulator->libs->count();
|
||||
int idx = 0;
|
||||
vector<FWObject*>::iterator i1=idxToLibs.begin();
|
||||
vector<QTreeWidget*>::iterator i2=idxToTrees.begin();
|
||||
for ( ; idx<N; ++idx,++i1,++i2)
|
||||
if ( m_objectManipulator->libs->itemText(idx) > newlibname ) break;
|
||||
|
||||
int idx = libs_model->rowCount();
|
||||
if (fwbdebug) qDebug() << "Adding at idx=" << idx;
|
||||
|
||||
QPixmap pm;
|
||||
doSetObjectIcon(lib, &pm, 0);
|
||||
|
||||
m_objectManipulator->libs->insertItem( idx, pm, newlibname);
|
||||
libs_model->insertRows(idx, 1);
|
||||
QModelIndex model_idx = libs_model->index(idx, 0);
|
||||
libs_model->setData(model_idx, newlibname, lib, objTreeView);
|
||||
libs_model->sort(0, Qt::AscendingOrder);
|
||||
|
||||
// after sorting the row of the new library may be different from where we added it
|
||||
QModelIndex lib_idx = libs_model->getIdxForLib(lib);
|
||||
m_objectManipulator->libs->setCurrentIndex(lib_idx.row());
|
||||
|
||||
|
||||
m_objectManipulator->libs->setCurrentIndex(idx);
|
||||
|
||||
idxToLibs.insert(i1, lib);
|
||||
idxToTrees.insert(i2, objTreeView);
|
||||
|
||||
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
policy.setHorizontalStretch(0);
|
||||
@ -542,25 +529,20 @@ void ObjectManipulator::addLib(FWObject *lib)
|
||||
|
||||
void ObjectManipulator::removeLib(FWObject* lib)
|
||||
{
|
||||
removeLib( getIdxForLib(lib) );
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::removeLib lib=" << lib;
|
||||
|
||||
QModelIndex idx = libs_model->getIdxForLib(lib);
|
||||
if (idx.isValid())
|
||||
removeLib( idx.row() );
|
||||
|
||||
}
|
||||
|
||||
void ObjectManipulator::removeLib(int id)
|
||||
void ObjectManipulator::removeLib(int row)
|
||||
{
|
||||
int N = m_objectManipulator->libs->count();
|
||||
int idx = 0;
|
||||
vector<FWObject*>::iterator i1 = idxToLibs.begin();
|
||||
vector<QTreeWidget*>::iterator i2 = idxToTrees.begin();
|
||||
for ( ; idx<N; ++idx,++i1,++i2)
|
||||
{
|
||||
if ( idx==id )
|
||||
{
|
||||
m_objectManipulator->libs->removeItem( idx );
|
||||
idxToLibs.erase(i1);
|
||||
idxToTrees.erase(i2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fwbdebug) qDebug() << "ObjectManipulator::removeLib row=" << row;
|
||||
libs_model->removeRows(row, 1);
|
||||
m_objectManipulator->libs->setCurrentIndex(libs_model->rowCount() - 1);
|
||||
//libs_model->reset();
|
||||
}
|
||||
|
||||
void ObjectManipulator::refreshSubtree(QTreeWidgetItem *parent, QTreeWidgetItem *itm)
|
||||
|
||||
@ -35,6 +35,7 @@ HEADERS += ../../config.h \
|
||||
SSHProcurve.h \
|
||||
debugDialog.h \
|
||||
findDialog.h \
|
||||
listOfLibrariesModel.h \
|
||||
longTextDialog.h \
|
||||
newGroupDialog.h \
|
||||
filePropDialog.h \
|
||||
@ -212,6 +213,7 @@ SOURCES += ProjectPanel.cpp \
|
||||
SSHProcurve.cpp \
|
||||
debugDialog.cpp \
|
||||
findDialog.cpp \
|
||||
listOfLibrariesModel.cpp \
|
||||
longTextDialog.cpp \
|
||||
newGroupDialog.cpp \
|
||||
filePropDialog.cpp \
|
||||
|
||||
212
src/gui/listOfLibrariesModel.cpp
Normal file
212
src/gui/listOfLibrariesModel.cpp
Normal file
@ -0,0 +1,212 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
$Id$
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "../../config.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "ObjectTreeView.h"
|
||||
#include "listOfLibrariesModel.h"
|
||||
|
||||
#include "fwbuilder/FWObject.h"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace libfwbuilder;
|
||||
|
||||
ListOfLibrariesModel::ListOfLibrariesModel(QObject *parent) : QStringListModel(parent)
|
||||
{
|
||||
top_static_items.push_back(tr("Object Libraries:"));
|
||||
// top_static_items.push_back(tr("----------------"));
|
||||
}
|
||||
|
||||
void ListOfLibrariesModel::addStaticItems()
|
||||
{
|
||||
int row = rowCount();
|
||||
foreach(QString itm, top_static_items)
|
||||
{
|
||||
insertRows(row, 1);
|
||||
QModelIndex idx = index(row, 0);
|
||||
QStringListModel::setData(idx, itm, Qt::DisplayRole);
|
||||
row++;
|
||||
}
|
||||
|
||||
// setData(idx, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
|
||||
}
|
||||
|
||||
Qt::ItemFlags ListOfLibrariesModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
int row = index.row();
|
||||
if (row < 0 || row >= items.size()) return 0;
|
||||
|
||||
FWObject *lib = items.at(index.row()).lib;
|
||||
if (lib == NULL) return Qt::ItemIsEnabled;
|
||||
else return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
bool ListOfLibrariesModel::insertRows(int row, int count, const QModelIndex & parent)
|
||||
{
|
||||
for (int c=0; c < count; ++c)
|
||||
items.insert(row, _item_data("", NULL, NULL));
|
||||
return QStringListModel::insertRows(row, count, parent);
|
||||
}
|
||||
|
||||
bool ListOfLibrariesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ListOfLibrariesModel::removeRows"
|
||||
<< "row=" << row
|
||||
<< "count=" << count;
|
||||
|
||||
int c = count;
|
||||
while (c > 0)
|
||||
{
|
||||
items.removeAt(row);
|
||||
c--;
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug() << "ListOfLibrariesModel::removeRows 2";
|
||||
|
||||
return QStringListModel::removeRows(row, count, parent);
|
||||
}
|
||||
|
||||
static bool ascendingLessThan(const _item_data &s1, const _item_data &s2)
|
||||
{
|
||||
return s1.name < s2.name;
|
||||
}
|
||||
|
||||
static bool decendingLessThan(const _item_data &s1, const _item_data &s2)
|
||||
{
|
||||
return s1.name > s2.name;
|
||||
}
|
||||
|
||||
void ListOfLibrariesModel::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
QList<_item_data> list;
|
||||
for (int i=0; i<rowCount(); ++i)
|
||||
{
|
||||
FWObject *l = getLibrary(i);
|
||||
if (l==NULL) continue;
|
||||
list.append(items.at(i));
|
||||
}
|
||||
|
||||
if (order == Qt::AscendingOrder)
|
||||
qSort(list.begin(), list.end(), ascendingLessThan);
|
||||
else
|
||||
qSort(list.begin(), list.end(), decendingLessThan);
|
||||
|
||||
int pos = 0;
|
||||
foreach(QString itm, top_static_items)
|
||||
{
|
||||
list.insert(pos, _item_data(itm, NULL, NULL));
|
||||
pos++;
|
||||
}
|
||||
|
||||
items.clear();
|
||||
QStringListModel::removeRows(0, rowCount());
|
||||
|
||||
for (int i = 0; i < list.count(); ++i)
|
||||
{
|
||||
QString text = list.at(i).name;
|
||||
insertRows(i, 1);
|
||||
QModelIndex idx = index(i, 0);
|
||||
QStringListModel::setData(idx, indentLibName(text, list.at(i).lib!=NULL), Qt::DisplayRole);
|
||||
items[i] = list[i];
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex ListOfLibrariesModel::getIdxForLib(FWObject* lib)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug() << "ListOfLibrariesModel::getIdxForLib"
|
||||
<< "lib=" << lib->getName().c_str();
|
||||
|
||||
for (int i=0; i<rowCount(); ++i)
|
||||
{
|
||||
QModelIndex idx = index(i, 0);
|
||||
if (idx.isValid())
|
||||
{
|
||||
FWObject *l = getLibrary(idx);
|
||||
if (l && l->getId() == lib->getId())
|
||||
{
|
||||
if (fwbdebug) qDebug() << "Index=" << i;
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
FWObject* ListOfLibrariesModel::getLibrary(QModelIndex idx)
|
||||
{
|
||||
return getLibrary(idx.row());
|
||||
}
|
||||
|
||||
FWObject* ListOfLibrariesModel::getLibrary(int row)
|
||||
{
|
||||
if (fwbdebug) qDebug() << "ListOfLibrariesModel::getLibrary row=" << row;
|
||||
if (row < 0 || row >= items.size()) return NULL;
|
||||
return items[row].lib;
|
||||
}
|
||||
|
||||
ObjectTreeView* ListOfLibrariesModel::getTreeWidget(QModelIndex idx)
|
||||
{
|
||||
return getTreeWidget(idx.row());
|
||||
}
|
||||
|
||||
ObjectTreeView* ListOfLibrariesModel::getTreeWidget(int row)
|
||||
{
|
||||
if (fwbdebug) qDebug() << "ListOfLibrariesModel::getTreeWidget row=" << row;
|
||||
if (row < 0 || row >= items.size()) return NULL;
|
||||
return items[row].tree;
|
||||
}
|
||||
|
||||
void ListOfLibrariesModel::setData(QModelIndex idx, const QString &name, FWObject *lib, ObjectTreeView *otv)
|
||||
{
|
||||
int row = idx.row();
|
||||
if (row < 0 || row >= items.size()) return ;
|
||||
items[row] = _item_data(name, lib, otv);
|
||||
QStringListModel::setData(idx, indentLibName(name, lib!=NULL), Qt::DisplayRole);
|
||||
}
|
||||
|
||||
void ListOfLibrariesModel::setName(QModelIndex idx, const QString &name)
|
||||
{
|
||||
int row = idx.row();
|
||||
if (row < 0 || row >= items.size()) return ;
|
||||
items[row].name = name;
|
||||
QStringListModel::setData(idx, indentLibName(name, items.at(row).lib!=NULL), Qt::DisplayRole);
|
||||
}
|
||||
|
||||
QString ListOfLibrariesModel::indentLibName(const QString &name, bool indent)
|
||||
{
|
||||
if (indent) return " " + name;
|
||||
else return name;
|
||||
}
|
||||
|
||||
|
||||
89
src/gui/listOfLibrariesModel.h
Normal file
89
src/gui/listOfLibrariesModel.h
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2010 NetCitadel, LLC
|
||||
|
||||
Author: Vadim Kurland vadim@fwbuilder.org
|
||||
|
||||
$Id$
|
||||
|
||||
This program is free software which we release under the GNU General Public
|
||||
License. You may redistribute and/or modify this program under the terms
|
||||
of that license as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To get a copy of the GNU General Public License, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __LISTOFLIBRARIESMODEL_H_
|
||||
#define __LISTOFLIBRARIESMODEL_H_
|
||||
|
||||
#include <QStringListModel>
|
||||
#include <QMap>
|
||||
|
||||
class ObjectTreeView;
|
||||
namespace libfwbuilder
|
||||
{
|
||||
class FWObject;
|
||||
};
|
||||
|
||||
|
||||
class _item_data
|
||||
{
|
||||
public:
|
||||
QString name;
|
||||
libfwbuilder::FWObject* lib;
|
||||
ObjectTreeView* tree;
|
||||
|
||||
_item_data(const QString &_n, libfwbuilder::FWObject* _lib, ObjectTreeView* _tree)
|
||||
{
|
||||
name = _n; lib = _lib; tree = _tree;
|
||||
}
|
||||
};
|
||||
|
||||
class ListOfLibrariesModel : public QStringListModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
QStringList top_static_items;
|
||||
QList<_item_data> items;
|
||||
|
||||
public:
|
||||
|
||||
ListOfLibrariesModel(QObject *parent = 0);
|
||||
|
||||
void addStaticItems();
|
||||
|
||||
QString indentLibName(const QString &name, bool indent);
|
||||
|
||||
// virtual QModelIndex index(int, int, const QModelIndex &p = QModelIndex()) const;
|
||||
|
||||
QModelIndex getIdxForLib(libfwbuilder::FWObject*);
|
||||
|
||||
libfwbuilder::FWObject* getLibrary(QModelIndex idx);
|
||||
libfwbuilder::FWObject* getLibrary(int row);
|
||||
|
||||
void setData(QModelIndex idx, const QString &name, libfwbuilder::FWObject *lib, ObjectTreeView *otv);
|
||||
void setName(QModelIndex idx, const QString &name);
|
||||
|
||||
ObjectTreeView* getTreeWidget(QModelIndex idx);
|
||||
ObjectTreeView* getTreeWidget(int row);
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
|
||||
virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
|
||||
|
||||
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,10 +1,11 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ObjectManipulator_q</class>
|
||||
<widget class="QWidget" name="ObjectManipulator_q" >
|
||||
<property name="enabled" >
|
||||
<widget class="QWidget" name="ObjectManipulator_q">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@ -12,32 +13,32 @@
|
||||
<height>441</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Tree of Objects</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_103" >
|
||||
<property name="verticalSpacing" >
|
||||
<layout class="QGridLayout" name="gridLayout_103">
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QGroupBox" name="buttonGroup1" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="buttonGroup1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet" >
|
||||
<string notr="true" >
|
||||
<property name="styleSheet">
|
||||
<string notr="true">
|
||||
QGroupBox {
|
||||
margin-top: 1ex;
|
||||
padding: 0px;
|
||||
@ -49,88 +50,101 @@ QComboBox {
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QToolButton" name="backButton" >
|
||||
<property name="toolTip" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="backButton">
|
||||
<property name="toolTip">
|
||||
<string>Back</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<property name="whatsThis">
|
||||
<string>Go back to the previous object</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainRes.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="MainRes.qrc">
|
||||
<normaloff>:/Icons/Return/icon</normaloff>:/Icons/Return/icon</iconset>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="Line" name="line1" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Fixed" >
|
||||
<item row="0" column="1">
|
||||
<widget class="Line" name="line1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32767</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::VLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth" >
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QComboBox" name="libs" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="libs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet" >
|
||||
<string notr="true" >QComboBox { padding: 2px;}
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Object libraries</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Library <span style=" font-weight:600;">"Standard"</span> holds predefined</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">collection of service and address objects</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">that ships with the package. Library <span style=" font-weight:600;">"User"</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">is where you create your own objects.</p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QComboBox { padding: 2px;}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QToolButton" name="newButton" >
|
||||
<property name="toolTip" >
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="newButton">
|
||||
<property name="toolTip">
|
||||
<string>New Object</string>
|
||||
</property>
|
||||
<property name="whatsThis" >
|
||||
<property name="whatsThis">
|
||||
<string>Create New Object</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainRes.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="MainRes.qrc">
|
||||
<normaloff>:/Icons/newobject_25.png</normaloff>:/Icons/newobject_25.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise" >
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
@ -138,60 +152,60 @@ QComboBox {
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Filter:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutocompletedComboBox" name="filter" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<widget class="AutocompletedComboBox" name="filter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<property name="toolTip">
|
||||
<string>Object name pattern</string>
|
||||
</property>
|
||||
<property name="editable" >
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="clearFilter" >
|
||||
<property name="toolTip" >
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
<widget class="QToolButton" name="clearFilter">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Lucida Grande'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clear filter</p></body></html></string>
|
||||
</style></head><body style=" font-family:'Lucida Grande'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clear filter</p></body></html></string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainRes.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="MainRes.qrc">
|
||||
<normaloff>:/Icons/close.png</normaloff>:/Icons/close.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QStackedWidget" name="widgetStack" >
|
||||
<widget class="QWidget" name="page" >
|
||||
<property name="palette" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QStackedWidget" name="widgetStack">
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
@ -200,9 +214,9 @@ p, li { white-space: pre-wrap; }
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
@ -211,9 +225,9 @@ p, li { white-space: pre-wrap; }
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Text" >
|
||||
<brush brushstyle="SolidPattern" >
|
||||
<color alpha="255" >
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>69</red>
|
||||
<green>69</green>
|
||||
<blue>69</blue>
|
||||
@ -228,7 +242,7 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11" />
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AutocompletedComboBox</class>
|
||||
@ -237,7 +251,7 @@ p, li { white-space: pre-wrap; }
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="MainRes.qrc" />
|
||||
<include location="MainRes.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
@ -246,11 +260,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>ObjectManipulator_q</receiver>
|
||||
<slot>libChanged(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>74</x>
|
||||
<y>31</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
@ -262,11 +276,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>ObjectManipulator_q</receiver>
|
||||
<slot>back()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
@ -278,11 +292,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>ObjectManipulator_q</receiver>
|
||||
<slot>newObject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>50</x>
|
||||
<y>30</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
@ -294,11 +308,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>ObjectManipulator_q</receiver>
|
||||
<slot>currentTreePageChanged(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>20</x>
|
||||
<y>104</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
</hint>
|
||||
@ -310,11 +324,11 @@ p, li { white-space: pre-wrap; }
|
||||
<receiver>filter</receiver>
|
||||
<slot>clearEditText()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>25</x>
|
||||
<y>51</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>69</x>
|
||||
<y>59</y>
|
||||
</hint>
|
||||
|
||||
@ -34,6 +34,7 @@ SOURCES += ../../ProjectPanel.cpp \
|
||||
../../SSHIOS.cpp \
|
||||
../../debugDialog.cpp \
|
||||
../../findDialog.cpp \
|
||||
../../listOfLibrariesModel.cpp \
|
||||
../../longTextDialog.cpp \
|
||||
../../newGroupDialog.cpp \
|
||||
../../filePropDialog.cpp \
|
||||
@ -210,6 +211,7 @@ HEADERS += ../../../../config.h \
|
||||
../../SSHIOS.h \
|
||||
../../debugDialog.h \
|
||||
../../findDialog.h \
|
||||
../../listOfLibrariesModel.h \
|
||||
../../longTextDialog.h \
|
||||
../../newGroupDialog.h \
|
||||
../../filePropDialog.h \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user