本文整理汇总了C++中FWObject::isReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C++ FWObject::isReadOnly方法的具体用法?C++ FWObject::isReadOnly怎么用?C++ FWObject::isReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWObject
的用法示例。
在下文中一共展示了FWObject::isReadOnly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveObject
void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
{
FWObject *cl=getCurrentLib();
if (cl==targetLib) return;
FWObject *grp = NULL;
if (FWObjectDatabase::isA(targetLib)) grp = targetLib;
else
{
grp = FWBTree().getStandardSlotForObject(
targetLib, obj->getTypeName().c_str());
}
if (grp==NULL) grp=targetLib;
if (!grp->isReadOnly())
{
map<int, set<FWObject*> > reference_holders;
FWCmdMoveObject *cmd = new FWCmdMoveObject(m_project,
obj->getParent(),
grp,
obj,
reference_holders,
"Move object");
m_project->undoStack->push(cmd);
}
if (fwbdebug) qDebug("ObjectManipulator::moveObject all done");
}
示例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: loadFromRCS
//.........这里部分代码省略.........
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() );
}
}
/* this is a hack: 'Standard' library should be read-only. I
* have too many files I already converted to the new API/DTD
* and I am too lazy to convert them again, so I patch it up
* here.
*
* However, if I am editing standard library, it should not be
* read-only.
*/
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
if (slib!=nullptr )
{
if (fwbdebug)
qDebug("standard library read-only status: %d, "
"editingStandardLib: %d",
slib->isReadOnly(), editingStandardLib);
slib->setReadOnly(! editingStandardLib);
}
/* if the file name has an old extension .xml, change it to .fwb and
* warn the user
*/
QString fn = rcs->getFileName();
QFileInfo ofinfo(fn);
if ( ofinfo.suffix()=="xml")
{
if (fwbdebug)
{
qDebug("Need to rename file: %s",
fn.toLatin1().constData());
qDebug(" dirPath: %s",
ofinfo.dir().absolutePath().toLatin1().constData());
qDebug(" filePath: %s",
ofinfo.absoluteFilePath().toLatin1().constData());
}
QString newFileName = ofinfo.dir().absolutePath()
+ "/" + ofinfo.completeBaseName() + ".fwb";
bool needToRename = true;
/* need these dances with symlinks to fix bug #1008956:
* "Existing .fwb file gets overwritten if has wrong
* extension"
*/
QFileInfo nfinfo(newFileName);
if (nfinfo.exists() && ofinfo.isSymLink() && ofinfo.readLink()==newFileName)
示例4: event
bool ProjectPanel::event(QEvent *event)
{
if (event->type() >= QEvent::User)
{
fwbUpdateEvent *ev = dynamic_cast<fwbUpdateEvent*>(event);
int event_code = event->type() - QEvent::User;
QString data_file = ev->getFileName();
int obj_id = ev->getObjectId();
FWObject *obj = db()->findInIndex(obj_id);
if (fwbdebug)
qDebug() << this
<< "rcs:"
<< rcs
<< "rcs->getFileName():"
<< QString((rcs!=NULL) ? rcs->getFileName() : "")
<< "file:"
<< data_file
<< "event:"
<< ev->getEventName()
<< "object:"
<< ((obj!=NULL) ? QString::fromUtf8(obj->getName().c_str()) : "")
<< "(" << ((obj!=NULL) ? obj->getTypeName().c_str() : "") << ")"
<< "id=" << ((obj!=NULL) ? obj->getId() : -1);
if (event_code == UPDATE_GUI_STATE_EVENT && mdiWindow != NULL)
{
m_panel->om->updateCreateObjectMenu(getCurrentLib());
ev->accept();
return true;
}
if ((rcs && rcs->getFileName() == data_file) ||
(!rcs && data_file.isEmpty()))
{
switch (event_code)
{
case RELOAD_OBJECT_TREE_EVENT:
registerTreeReloadRequest();
ev->accept();
return true;
case RELOAD_OBJECT_TREE_IMMEDIATELY_EVENT:
m_panel->om->reload();
ev->accept();
return true;
case RELOAD_RULESET_EVENT:
registerRuleSetRedrawRequest();
// update rule set title as well
//updateFirewallName();
ev->accept();
return true;
case MAKE_CURRENT_RULE_VISIBLE_IN_RULESET_EVENT:
{
RuleSetView* rsv = getCurrentRuleSetView();
if (rsv) rsv->makeCurrentRuleVisible();
ev->accept();
return true;
}
case RELOAD_RULESET_IMMEDIATELY_EVENT:
redrawRuleSets();
//reopenFirewall();
// update rule set title as well
//updateFirewallName();
ev->accept();
return true;
}
if (obj == NULL) return false;
switch (event_code)
{
case DATA_MODIFIED_EVENT:
{
// This event does not trigger any updates in the UI,
// this purely data structure update event.
FWObject *p = obj;
while (p && Firewall::cast(p)==NULL) p = p->getParent();
Firewall *f = Firewall::cast(p);
// when user locks firewall object, this code tries to
// update last_modified timestamp in it because it
// depends on itself. Dont.
if (f && !f->isReadOnly())
{
f->updateLastModifiedTimestamp();
QCoreApplication::postEvent(
mw, new updateObjectInTreeEvent(data_file, f->getId()));
}
registerModifiedObject(obj);
QCoreApplication::postEvent(mw, new updateGUIStateEvent());
ev->accept();
return true;
}
//.........这里部分代码省略.........