本文整理汇总了C++中FWObject::setReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C++ FWObject::setReadOnly方法的具体用法?C++ FWObject::setReadOnly怎么用?C++ FWObject::setReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWObject
的用法示例。
在下文中一共展示了FWObject::setReadOnly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromRCS
bool ProjectPanel::loadFromRCS(RCS *_rcs)
{
resetFD();
editingStandardLib = false;
editingTemplateLib = false;
bool forceSave=false; // use this flag to force 'save' operation if file should be renamed
MessageBoxUpgradePredicate upgrade_predicate(mainW);
assert(_rcs!=nullptr);
rcs = _rcs;
try
{
/* load the data file */
systemFile = false;
clearObjects();
if (objdb)
{
objdb->destroyChildren();
delete objdb;
}
objdb = new FWObjectDatabase();
// need to drop read-only flag on the database before I load new objects
objdb->setReadOnly( false );
// always loading system objects
mw->showStatusBarMessage(tr("Loading system objects...") );
objdb->load( Constants::getStandardObjectsFilePath(),
&upgrade_predicate, Constants::getDTDDirectory());
objdb->setFileName("");
// objects from a data file are in database ndb
mw->showStatusBarMessage(tr("Reading and parsing data file..."));
FWObjectDatabase *ndb = new FWObjectDatabase();
ndb->load(rcs->getFileName().toLocal8Bit().constData(),
&upgrade_predicate,Constants::getDTDDirectory());
time_t oldtimestamp = ndb->getTimeLastModified();
/* loadingLib is true if user wants to open a library or master library file */
bool loadingLib = editingLibrary();
if (fwbdebug)
{
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
{
qDebug("* Found library %s %s in the data file",
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
(*i)->getName().c_str() );
}
}
/* if user opens library file, clear read-only flag so they can edit it */
if (loadingLib)
{
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
{
if ((*i)->getId()==FWObjectDatabase::STANDARD_LIB_ID)
editingStandardLib=true;
if ((*i)->getId()==FWObjectDatabase::TEMPLATE_LIB_ID)
editingTemplateLib=true;
(*i)->setReadOnly( false );
}
}
mw->showStatusBarMessage(tr("Merging with system objects...") );
MergeConflictRes mcr(mainW);
objdb->merge(ndb, &mcr);
ndb->destroyChildren();
delete ndb;
objdb->setFileName(rcs->getFileName().toLocal8Bit().constData());
objdb->resetTimeLastModified(oldtimestamp);
objdb->setDirty(false);
if (fwbdebug)
{
qDebug("* Merge is done");
list<FWObject*> ll = db()->getByType(Library::TYPENAME);
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
{
qDebug("* Library %s %s in the data file",
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
(*i)->getName().c_str() );
}
}
//.........这里部分代码省略.........
示例2: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Utf8"));
#endif
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
QStringList args = app.arguments();
if (args.size()<=1)
{
usage(argv[0]);
exit(1);
}
QString last_arg;
string filename;
for (int idx=0; idx < args.size(); idx++)
{
QString arg = args.at(idx);
last_arg = arg;
if (arg == "-V")
{
usage(argv[0]);
exit(0);
}
if (arg == "-f")
{
idx++;
filename = string(args.at(idx).toLatin1().constData());
continue;
}
}
if (filename.empty())
{
usage(argv[0]);
exit(1);
}
init(argv);
try
{
new Resources(Constants::getResourcesFilePath());
/* create database */
objdb = new FWObjectDatabase();
/* load the data file */
UpgradePredicate upgrade_predicate;
cout << " *** Loading data ...";
objdb->setReadOnly( false );
objdb->load( filename, &upgrade_predicate, Constants::getDTDDirectory());
objdb->setFileName(filename);
objdb->reIndex();
cout << " done\n";
FWObject *slib = objdb->getById(FWObjectDatabase::STANDARD_LIB_ID);
if (slib && slib->isReadOnly()) slib->setReadOnly(false);
CompilerDriver_nxosacl *driver = new CompilerDriver_nxosacl(objdb);
if (!driver->prepare(args))
{
usage(argv[0]);
exit(1);
}
driver->compile();
//int ret = (driver->getStatus() == BaseCompiler::FWCOMPILER_SUCCESS) ? 0 : 1;
int ret = driver->getStatus();
delete driver;
delete objdb;
return ret;
} catch(libfwbuilder::FWException &ex)
{
cerr << ex.toString() << endl;
return 1;
} catch (std::string s)
{
cerr << s << endl;
return 1;
} catch (std::exception ex)
{
cerr << "exception: " << ex.what() << endl;
return 1;
} catch (...)
{
cerr << "Unsupported exception";
return 1;
//.........这里部分代码省略.........
示例3: deleteObject
void ObjectManipulator::deleteObject(FWObject *obj, QUndoCommand* macro)
{
bool firstAction = true ;
if (fwbdebug)
qDebug() << "ObjectManipulator::deleteObject"
<< "obj=" << obj
<< "name=" << obj->getName().c_str();
FWObject *object_library = obj->getLibrary();
FWObject *parent = obj->getParent();
FWObject *deleted_objects_lib = m_project->db()->findInIndex(
FWObjectDatabase::DELETED_OBJECTS_ID );
if (deleted_objects_lib == NULL)
{
FWObject *dobj = m_project->db()->createLibrary();
dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID);
dobj->setName("Deleted Objects");
dobj->setReadOnly(false);
m_project->db()->add(dobj);
deleted_objects_lib = dobj;
}
if (object_library->getId() == FWObjectDatabase::STANDARD_LIB_ID)
return;
if (obj->isReadOnly()) return;
if (obj->getId() == FWObjectDatabase::STANDARD_LIB_ID ||
obj->getId() == FWObjectDatabase::DELETED_OBJECTS_ID) return;
bool is_library = Library::isA(obj);
bool is_firewall = Firewall::cast(obj) != NULL; // includes Cluster too
bool is_deleted_object = (deleted_objects_lib!=NULL && obj->isChildOf(deleted_objects_lib));
// ruleset_visible == true if 1) we delete firewall object and one of its
// rulesets is visible in the project panel, or 2) we delete ruleset object
// which is visible in the project panel
bool ruleset_visible = (
(is_firewall && m_project->getCurrentRuleSet()->isChildOf(obj)) ||
(m_project->getCurrentRuleSet() == obj));
mw->findObjectWidget->reset();
QCoreApplication::postEvent(
mw, new closeObjectEvent(m_project->getFileName(), obj->getId()));
#if 0
// Remove object we are about to delete from the clipboard.
// Sequence "delete then paste" is risky if the object is pasted into
// a group or rule where only reference is added
FWObjectClipboard::obj_clipboard->remove(obj);
#endif
try
{
if (fwbdebug)
qDebug() << "ObjectManipulator::deleteObject"
<< "is_library=" << is_library
<< "is_firewall= " << is_firewall
<< "ruleset_visible=" << ruleset_visible
<< "is_deleted_object="<< is_deleted_object;
if (is_deleted_object)
{
unselect();
FWCmdDeleteObject *cmd = new FWCmdDeleteObject(
m_project,
obj,
QString("Delete object"),
macro);
if (macro==0)
m_project->undoStack->push(cmd);
return;
}
if (is_library && obj->isReadOnly()) obj->setReadOnly(false);
if (is_library) parent = m_project->db()->getFirstByType(Library::TYPENAME);
actuallyDeleteObject(obj, macro);
if (ruleset_visible) m_project->closeRuleSetPanel();
}
catch (FWException &ex)
{
if (fwbdebug)
qDebug() << "ObjectManipulator::deleteObject:"
<< "catch: restoreOverrideCursor";
QApplication::restoreOverrideCursor();
QMessageBox::warning(
this,"Firewall Builder",
ex.toString().c_str(),
"&Continue", QString::null,QString::null,
0, 1 );
throw(ex);
}
if (fwbdebug) qDebug("ObjectManipulator::deleteObject done");
//.........这里部分代码省略.........