|
|
|
@ -325,7 +325,7 @@ KexiTableDesignerView::createPropertySet( int row, const KexiDB::Field& field, b
|
|
|
|
|
));
|
|
|
|
|
prop->setVisible(false);
|
|
|
|
|
set->addProperty(prop = new KoProperty::Property("this:useCaptionAsObjectName",
|
|
|
|
|
TQVariant(true, 1), TQString())); //we want "caption" to be displayed in the header, not name
|
|
|
|
|
TQVariant(true), TQString())); //we want "caption" to be displayed in the header, not name
|
|
|
|
|
prop->setVisible(false);
|
|
|
|
|
|
|
|
|
|
//name
|
|
|
|
@ -376,7 +376,7 @@ KexiTableDesignerView::createPropertySet( int row, const KexiDB::Field& field, b
|
|
|
|
|
prop->setVisible(false);//always hidden
|
|
|
|
|
|
|
|
|
|
set->addProperty(prop
|
|
|
|
|
= new KoProperty::Property("unsigned", TQVariant(field.isUnsigned(), 4), i18n("Unsigned Number")));
|
|
|
|
|
= new KoProperty::Property("unsigned", TQVariant(field.isUnsigned()), i18n("Unsigned Number")));
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("length", (int)field.length()/*200?*/, i18n("Length")));
|
|
|
|
@ -407,24 +407,24 @@ KexiTableDesignerView::createPropertySet( int row, const KexiDB::Field& field, b
|
|
|
|
|
// prop->setVisible(false);
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("primaryKey", TQVariant(field.isPrimaryKey(), 4), i18n("Primary Key")));
|
|
|
|
|
= new KoProperty::Property("primaryKey", TQVariant(field.isPrimaryKey()), i18n("Primary Key")));
|
|
|
|
|
prop->setIcon("key");
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("unique", TQVariant(field.isUniqueKey(), 4), i18n("Unique")));
|
|
|
|
|
= new KoProperty::Property("unique", TQVariant(field.isUniqueKey()), i18n("Unique")));
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("notNull", TQVariant(field.isNotNull(), 4), i18n("Required")));
|
|
|
|
|
= new KoProperty::Property("notNull", TQVariant(field.isNotNull()), i18n("Required")));
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("allowEmpty", TQVariant(!field.isNotEmpty(), 4), i18n("Allow Zero\nSize")));
|
|
|
|
|
= new KoProperty::Property("allowEmpty", TQVariant(!field.isNotEmpty()), i18n("Allow Zero\nSize")));
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("autoIncrement", TQVariant(field.isAutoIncrement(), 4), i18n("Autonumber")));
|
|
|
|
|
= new KoProperty::Property("autoIncrement", TQVariant(field.isAutoIncrement()), i18n("Autonumber")));
|
|
|
|
|
prop->setIcon("autonumber");
|
|
|
|
|
|
|
|
|
|
set->addProperty( prop
|
|
|
|
|
= new KoProperty::Property("indexed", TQVariant(field.isIndexed(), 4), i18n("Indexed")));
|
|
|
|
|
= new KoProperty::Property("indexed", TQVariant(field.isIndexed()), i18n("Indexed")));
|
|
|
|
|
|
|
|
|
|
//- properties related to lookup columns (used and set by the "lookup column" tab in the property pane)
|
|
|
|
|
KexiDB::LookupFieldSchema *lookupFieldSchema = field.table() ? field.table()->lookupFieldSchema(field) : 0;
|
|
|
|
@ -491,7 +491,7 @@ void KexiTableDesignerView::slotTogglePrimaryKey()
|
|
|
|
|
return;
|
|
|
|
|
KoProperty::Set &set = *propertySet();
|
|
|
|
|
bool isSet = !set["primaryKey"].value().toBool();
|
|
|
|
|
set.changeProperty("primaryKey", TQVariant(isSet,1)); //this will update all related properties as well
|
|
|
|
|
set.changeProperty("primaryKey", TQVariant(isSet)); //this will update all related properties as well
|
|
|
|
|
/* CommandGroup *setPrimaryKeyCommand;
|
|
|
|
|
if (isSet) {
|
|
|
|
|
setPrimaryKeyCommand = new CommandGroup(i18n("Set primary key for field \"%1\"")
|
|
|
|
@ -510,8 +510,8 @@ void KexiTableDesignerView::switchPrimaryKey(KoProperty::Set &propertySet,
|
|
|
|
|
bool set, bool aWasPKey, CommandGroup* commandGroup)
|
|
|
|
|
{
|
|
|
|
|
const bool was_pkey = aWasPKey || propertySet["primaryKey"].value().toBool();
|
|
|
|
|
// propertySet["primaryKey"] = TQVariant(set, 1);
|
|
|
|
|
d->setPropertyValueIfNeeded( propertySet, "primaryKey", TQVariant(set,1), commandGroup );
|
|
|
|
|
// propertySet["primaryKey"] = TQVariant(set);
|
|
|
|
|
d->setPropertyValueIfNeeded( propertySet, "primaryKey", TQVariant(set), commandGroup );
|
|
|
|
|
if (&propertySet==this->propertySet()) {
|
|
|
|
|
//update action and icon @ column 0 (only if we're changing current property set)
|
|
|
|
|
d->action_toggle_pkey->setChecked(set);
|
|
|
|
@ -537,10 +537,10 @@ void KexiTableDesignerView::switchPrimaryKey(KoProperty::Set &propertySet,
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (i<count) {//remove
|
|
|
|
|
//(*s)["autoIncrement"] = TQVariant(false, 0);
|
|
|
|
|
d->setPropertyValueIfNeeded( *s, "autoIncrement", TQVariant(false,0), commandGroup );
|
|
|
|
|
//(*s)["primaryKey"] = TQVariant(false, 0);
|
|
|
|
|
d->setPropertyValueIfNeeded( *s, "primaryKey", TQVariant(false,0), commandGroup );
|
|
|
|
|
//(*s)["autoIncrement"] = TQVariant(false);
|
|
|
|
|
d->setPropertyValueIfNeeded( *s, "autoIncrement", TQVariant(false), commandGroup );
|
|
|
|
|
//(*s)["primaryKey"] = TQVariant(false);
|
|
|
|
|
d->setPropertyValueIfNeeded( *s, "primaryKey", TQVariant(false), commandGroup );
|
|
|
|
|
//remove key from table
|
|
|
|
|
d->view->KexiDataAwareObjectInterface::data()->clearRowEditBuffer();
|
|
|
|
|
KexiTableItem *item = d->view->itemAt(i);
|
|
|
|
@ -560,8 +560,8 @@ void KexiTableDesignerView::switchPrimaryKey(KoProperty::Set &propertySet,
|
|
|
|
|
//propertySet["subType"] = KexiDB::Field::typeString(KexiDB::Field::BigInteger);
|
|
|
|
|
d->setPropertyValueIfNeeded( propertySet, "subType", KexiDB::Field::typeString(KexiDB::Field::BigInteger),
|
|
|
|
|
commandGroup );
|
|
|
|
|
//propertySet["unsigned"] = TQVariant(true,4);
|
|
|
|
|
d->setPropertyValueIfNeeded( propertySet, "unsigned", TQVariant(true,4), commandGroup );
|
|
|
|
|
//propertySet["unsigned"] = TQVariant(true);
|
|
|
|
|
d->setPropertyValueIfNeeded( propertySet, "unsigned", TQVariant(true), commandGroup );
|
|
|
|
|
/*todo*/
|
|
|
|
|
d->slotBeforeCellChanged_enabled = true;
|
|
|
|
|
}
|
|
|
|
@ -780,9 +780,9 @@ void KexiTableDesignerView::slotBeforeCellChanged(
|
|
|
|
|
// notNull and defaultValue=false is reasonable for boolean type
|
|
|
|
|
if (fieldType == KexiDB::Field::Boolean) {
|
|
|
|
|
//! @todo maybe this is good for other data types as well?
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true, 1), changeDataTypeCommand,
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true), changeDataTypeCommand,
|
|
|
|
|
false /*!forceAddCommand*/, false /*!rememberOldValue*/);
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "defaultValue", TQVariant(false, 1), changeDataTypeCommand,
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "defaultValue", TQVariant(false), changeDataTypeCommand,
|
|
|
|
|
false /*!forceAddCommand*/, false /*!rememberOldValue*/);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -799,8 +799,8 @@ void KexiTableDesignerView::slotBeforeCellChanged(
|
|
|
|
|
/*not needed, line below will do the work
|
|
|
|
|
d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_ICON, TQVariant());
|
|
|
|
|
d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item); */
|
|
|
|
|
//set["primaryKey"] = TQVariant(false, 1);
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(false, 1), changeDataTypeCommand );
|
|
|
|
|
//set["primaryKey"] = TQVariant(false);
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(false), changeDataTypeCommand );
|
|
|
|
|
//! @todo should we display (passive?) dialog informing about cleared pkey?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -884,7 +884,7 @@ void KexiTableDesignerView::slotRowUpdated(KexiTableItem *item)
|
|
|
|
|
// reasonable case for boolean type: set notNull flag and "false" as default value
|
|
|
|
|
if (fieldType == KexiDB::Field::Boolean) {
|
|
|
|
|
field.setNotNull( true );
|
|
|
|
|
field.setDefaultValue( TQVariant(false, 0) );
|
|
|
|
|
field.setDefaultValue( TQVariant(false) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kexipluginsdbg << "KexiTableDesignerView::slotRowUpdated(): " << field.debugString() << endl;
|
|
|
|
@ -970,15 +970,15 @@ void KexiTableDesignerView::slotPropertyChanged(KoProperty::Set& set, KoProperty
|
|
|
|
|
setAutonumberCommand = new CommandGroup(
|
|
|
|
|
i18n("Assign autonumber for field \"%1\"").arg(set["name"].value().toString()) );
|
|
|
|
|
toplevelCommand = setAutonumberCommand;
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(true,1), setAutonumberCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(true), setAutonumberCommand );
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
setAutonumberCommand = new CommandGroup(
|
|
|
|
|
i18n("Remove autonumber from field \"%1\"").arg(set["name"].value().toString()) );
|
|
|
|
|
//d->slotPropertyChanged_enabled = false;
|
|
|
|
|
// set["autoIncrement"].setValue( TQVariant(false,1), false/*don't save old*/);
|
|
|
|
|
// set["autoIncrement"].setValue( TQVariant(false), false/*don't save old*/);
|
|
|
|
|
// d->slotPropertyChanged_enabled = true;
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(false,1), setAutonumberCommand,
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(false), setAutonumberCommand,
|
|
|
|
|
true /*forceAddCommand*/, false/*rememberOldValue*/ );
|
|
|
|
|
addHistoryCommand( setAutonumberCommand, false /* !execute */ );
|
|
|
|
|
return;
|
|
|
|
@ -997,10 +997,10 @@ void KexiTableDesignerView::slotPropertyChanged(KoProperty::Set& set, KoProperty
|
|
|
|
|
CommandGroup *unsetIndexedOrUniquOrNotNullCommand = new CommandGroup(
|
|
|
|
|
i18n("Set \"%1\" property for field \"%2\"").arg(property.caption()).arg(set["name"].value().toString()) );
|
|
|
|
|
toplevelCommand = unsetIndexedOrUniquOrNotNullCommand;
|
|
|
|
|
d->setPropertyValueIfNeeded( set, pname, TQVariant(false,1), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, pname, TQVariant(false), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
if (pname=="notNull") {
|
|
|
|
|
//? d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true,1), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "unique", TQVariant(false,1), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
//? d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "unique", TQVariant(false), unsetIndexedOrUniquOrNotNullCommand );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1091,19 +1091,19 @@ void KexiTableDesignerView::slotPropertyChanged(KoProperty::Set& set, KoProperty
|
|
|
|
|
else
|
|
|
|
|
toplevelCommand = setPrimaryKeyCommand;
|
|
|
|
|
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(true,1), setPrimaryKeyCommand, true /*forceAddCommand*/ );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "unique", TQVariant(true,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "allowEmpty", TQVariant(false,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "indexed", TQVariant(true,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(true), setPrimaryKeyCommand, true /*forceAddCommand*/ );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "unique", TQVariant(true), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "notNull", TQVariant(true), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "allowEmpty", TQVariant(false), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "indexed", TQVariant(true), setPrimaryKeyCommand );
|
|
|
|
|
//! \todo: add setting for this: "Integer PKeys have autonumber set by default"
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(true,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(true), setPrimaryKeyCommand );
|
|
|
|
|
|
|
|
|
|
/* set["unique"] = TQVariant(true,1);
|
|
|
|
|
set["notNull"] = TQVariant(true,1);
|
|
|
|
|
set["allowEmpty"] = TQVariant(false,1);
|
|
|
|
|
set["indexed"] = TQVariant(true,1);
|
|
|
|
|
set["autoIncrement"] = TQVariant(true,1);*/
|
|
|
|
|
/* set["unique"] = TQVariant(true);
|
|
|
|
|
set["notNull"] = TQVariant(true);
|
|
|
|
|
set["allowEmpty"] = TQVariant(false);
|
|
|
|
|
set["indexed"] = TQVariant(true);
|
|
|
|
|
set["autoIncrement"] = TQVariant(true);*/
|
|
|
|
|
// d->addHistoryCommand_in_slotPropertyChanged_enabled = prev_addHistoryCommand_in_slotPropertyChanged_enabled;
|
|
|
|
|
//down addHistoryCommand( toplevelCommand, false /* !execute */ );
|
|
|
|
|
}
|
|
|
|
@ -1117,8 +1117,8 @@ void KexiTableDesignerView::slotPropertyChanged(KoProperty::Set& set, KoProperty
|
|
|
|
|
else
|
|
|
|
|
toplevelCommand = setPrimaryKeyCommand;
|
|
|
|
|
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(false,1), setPrimaryKeyCommand, true /*forceAddCommand*/ );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(false,1), setPrimaryKeyCommand );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant(false), setPrimaryKeyCommand, true /*forceAddCommand*/ );
|
|
|
|
|
d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant(false), setPrimaryKeyCommand );
|
|
|
|
|
// set["autoIncrement"] = TQVariant(false,1);
|
|
|
|
|
|
|
|
|
|
//down addHistoryCommand( toplevelCommand, false /* !execute */ );
|
|
|
|
|