Exemplo n.º 1
0
RKEditor *RKWorkplace::editObject (RObject *object) {
	RK_TRACE (APP);

	RObject *iobj = object;
	RKEditor *ed = 0;
	RKEditor *existing_editor = RKGlobals::tracker ()->objectEditor (object);
	if (!existing_editor) {
		if (!iobj->isDataFrame ()) {
			if (iobj->isVariable () && iobj->getContainer ()->isDataFrame ()) {
				iobj = iobj->getContainer ();
			} else {
				return 0;
			}
		}

		unsigned long size = 1;
		foreach (int dim, iobj->getDimensions ()) {
			size *= dim;
		}
		if ((RKSettingsModuleGeneral::warnLargeObjectThreshold () != 0) && (size > RKSettingsModuleGeneral::warnLargeObjectThreshold ())) {
			if (KMessageBox::warningContinueCancel (view (), i18n ("You are about to edit object \"%1\", which is very large (%2 fields). RKWard is not optimized to handle very large objects in the built in data editor. This will use a lot of memory, and - depending on your system - might be very slow. For large objects it is generally recommended to edit using command line means or to split into smaller chunks before editing. On the other hand, if you have enough memory, or the data is simple enough (numeric data is easier to handle, than factor), editing may not be a problem at all. You can configure this warning (or turn it off entirely) under Settings->Configure RKWard->General.\nReally edit object?", iobj->getFullName (), size), i18n ("About to edit very large object")) != KMessageBox::Continue) {
				return 0;
			}
		}

		ed = new RKEditorDataFrame (static_cast<RContainerObject*> (iobj), 0);
		addWindow (ed);
	} else {
RKVarEditDataFrameModel::RKVarEditDataFrameModel (const QString& validized_name, RContainerObject* parent_object, RCommandChain* chain, int initial_cols, QObject* parent) : RKVarEditModel (parent) {
	RK_TRACE (EDITOR);

	RObject *object = parent_object->createPendingChild (validized_name, -1, true, true);
	RK_ASSERT (object->isDataFrame ());
	RContainerObject* df = static_cast<RContainerObject*> (object);

// initialize the new object
	for (int i = 0; i < initial_cols; ++i) {
		RObject* child = df->createPendingChild (df->validizeName (QString ()), -1, false, false);
		RK_ASSERT (child->isVariable ());
		// let's start with one (empty) row, to avoid confusion
		static_cast<RKVariable*> (child)->setLength (1);
	}

	init (df);

	// creates the pending object in the backend
	pushTable (chain);
}