20#include "kexitabledesignerview.h"
21#include "kexitabledesignerview_p.h"
22#include "kexilookupcolumnpage.h"
23#include "kexitabledesignercommands.h"
27#include <tqsplitter.h>
29#include <kiconloader.h>
33#include <tdepopupmenu.h>
34#include <tdemessagebox.h>
35#include <kiconeffect.h>
37#include <koproperty/set.h>
38#include <koproperty/utils.h>
40#include <kexidb/cursor.h>
41#include <kexidb/tableschema.h>
42#include <kexidb/connection.h>
43#include <kexidb/utils.h>
44#include <kexidb/roweditbuffer.h>
45#include <kexidb/error.h>
46#include <kexidb/lookupfieldschema.h>
47#include <kexiutils/identifier.h>
48#include <kexiproject.h>
49#include <keximainwindow.h>
50#include <widget/tableview/kexidataawarepropertyset.h>
51#include <widget/kexicustompropertyfactory.h>
52#include <kexiutils/utils.h>
53#include <kexidialogbase.h>
54#include <kexitableview.h>
59#define DEFAULT_OBJECT_TYPE_VALUE "image"
66using namespace KexiTableDesignerCommands;
69static bool isIntegerTQVariant(TQVariant::Type t)
71 return t==TQVariant::LongLong
72 || t==TQVariant::ULongLong
74 || t==TQVariant::UInt;
78static bool canCastTQVariant(TQVariant::Type fromType, TQVariant::Type toType)
80 return (fromType==TQVariant::Int && toType==TQVariant::UInt)
81 || (fromType==TQVariant::CString && toType==TQVariant::String)
82 || (fromType==TQVariant::LongLong && toType==TQVariant::ULongLong)
83 || ((fromType==TQVariant::String || fromType==TQVariant::CString)
84 && (isIntegerTQVariant(toType) || toType==TQVariant::Double));
91static TQVariant tryCastTQVariant( const TQVariant& fromVal, TQVariant::Type toType )
93 const TQVariant::Type fromType = fromVal.type();
94 if (fromType == toType)
96 if (canCastTQVariant(fromType, toType) || canCastTQVariant(toType, fromType)
97 || (isIntegerTQVariant(fromType) && toType==TQVariant::Double))
99 TQVariant res( fromVal );
100 if (res.cast(toType))
109 , KexiTableDesignerInterface()
110 , d( new KexiTableDesignerViewPrivate(this) )
120 d->data->setReadOnly( true);
121 d->data->setInsertingEnabled( false );
124 i18n( "Additional information about the field"));
129 d->data->addColumn( col );
133 i18n( "Describes caption for the field"));
137 d->data->addColumn( col );
140 i18n( "Describes data type for the field"));
141 d->data->addColumn( col );
143#ifdef KEXI_NO_BLOB_FIELDS
145 TQValueVector<TQString> types(KexiDB::Field::LastTypeGroup-1);
147 TQValueVector<TQString> types(KexiDB::Field::LastTypeGroup);
149 d->maxTypeNameTextWidth = 0;
150 TQFontMetrics fm(font());
151 for (uint i=1; i<=types.count(); i++) {
153 d->maxTypeNameTextWidth = TQMAX(d->maxTypeNameTextWidth, fm.width(types[i-1]));
158 i18n( "Describes additional comments for the field")) );
160 d->view->setSpreadSheetMode();
162 connect(d->data, TQ_SIGNAL(aboutToChangeCell(KexiTableItem*, int,TQVariant&, KexiDB::ResultInfo*)),
164 connect(d->data, TQ_SIGNAL(rowUpdated(KexiTableItem*)),
168 connect(d->data, TQ_SIGNAL(aboutToDeleteRow(KexiTableItem&, KexiDB::ResultInfo*, bool)),
171 setMinimumSize(d->view->minimumSizeHint().width(), d->view->minimumSizeHint().height());
175 connect(d->sets, TQ_SIGNAL(rowDeleted()), this, TQ_SLOT( updateActions()));
176 connect(d->sets, TQ_SIGNAL(rowInserted()), this, TQ_SLOT( slotRowInserted()));
178 d->contextMenuTitle = new TDEPopupTitle(d->view->contextMenu());
179 d->view->contextMenu()->insertItem(d->contextMenuTitle, -1, 0);
183 d->action_toggle_pkey = static_cast<TDEToggleAction* >( sharedAction( "tablepart_toggle_pkey") );
184 d->action_toggle_pkey->plug(d->view->contextMenu(), 1);
185 d->view->contextMenu()->insertSeparator(2);
188#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
193 connect(d->history, TQ_SIGNAL(commandExecuted(KCommand*)), this, TQ_SLOT( slotCommandExecuted(KCommand*)));
197 KexiUtils::addAlterTableActionDebug(TQString());
198 KexiUtils::connectPushButtonActionForDebugWindow(
200 KexiUtils::connectPushButtonActionForDebugWindow(
205KexiTableDesignerView::~KexiTableDesignerView()
215 d->data->deleteAllRows();
216 int tableFieldCount = 0;
217 d->primaryKeyExists = false;
219 if (tempData()->table) {
220 tableFieldCount = tempData()->table->fieldCount();
224 for( int i=0; i < tableFieldCount; i++) {
226 KexiTableItem *item = d->data->createItem();
227 if (field->isPrimaryKey()) {
228 (*item)[COLUMN_ID_ICON] = "key";
229 d->primaryKeyExists = true;
233 = field->table() ? field->table()->lookupFieldSchema(*field) : 0;
237 (*item)[COLUMN_ID_ICON] = "combo";
241 (*item)[COLUMN_ID_TYPE] = field->typeGroup()-1;
242 (*item)[COLUMN_ID_DESC] = field->description();
243 d->data->append(item);
254 for ( int i=tableFieldCount; i<(int)d->sets->size(); i++) {
256 d->data->append(d->data->createItem());
260 d->view->setData(d->data);
263 if (tempData()->table) {
264 for( int i=0; i < tableFieldCount; i++) {
271 d->view->setColumnWidth(COLUMN_ID_ICON, IconSize( TDEIcon::Small ) + 10);
272 d->view->adjustColumnWidthToContents(COLUMN_ID_CAPTION);
273 d->view->setColumnWidth(COLUMN_ID_TYPE, d->maxTypeNameTextWidth + 2 * d->view->rowHeight());
274 d->view->setColumnStretchEnabled( true, COLUMN_ID_DESC );
275 const int minCaptionColumnWidth = d->view->fontMetrics().width( "wwwwwwwwwww");
276 if (minCaptionColumnWidth > d->view->columnWidth(COLUMN_ID_CAPTION))
277 d->view->setColumnWidth(COLUMN_ID_CAPTION, minCaptionColumnWidth);
280 d->view->setCursorPosition(0, COLUMN_ID_CAPTION);
287 TQStringList& stringsList, TQStringList& namesList)
293 stringsList << "image";
294 namesList << i18n("Image object type", "Image");
300 kexipluginsdbg << "KexiTableDesignerView::getSubTypeListData(): subType strings: " <<
301 stringsList.join( "|") << "\nnames: " << namesList.join( "|") << endl;
307 TQString typeName = "KexiDB::Field::" + field.typeGroupString();
308 KoProperty::Set *set = new KoProperty::Set(d->sets, typeName);
309 if ( mainWin()->project()->dbConnection()->isReadOnly())
310 set->setReadOnly( true );
314 KoProperty::Property *prop;
316 set->addProperty(prop = new KoProperty::Property( "uid", d->generateUniqueId(), ""));
317 prop->setVisible( false);
320 set->addProperty(prop = new KoProperty::Property( "this:classString", i18n( "Table field")) );
321 prop->setVisible( false);
322 set->addProperty(prop = new KoProperty::Property( "this:iconName",
326 prop->setVisible( false);
327 set->addProperty(prop = new KoProperty::Property( "this:useCaptionAsObjectName",
328 TQVariant( true), TQString()));
329 prop->setVisible( false);
332 set->addProperty(prop
333 = new KoProperty::Property( "name", TQVariant(field.name()), i18n( "Name"),
337 set->addProperty( prop
338 = new KoProperty::Property( "type", TQVariant(field.type()), i18n( "Type")) );
339#ifndef KexiTableDesignerView_DEBUG
340 prop->setVisible( false);
344 TQStringList typeStringList, typeNameList;
351 subTypeValue = slist.first();
354 TQString subTypeValue = field.typeString();
356 set->addProperty(prop = new KoProperty::Property( "subType",
357 typeStringList, typeNameList, subTypeValue, i18n( "Subtype")));
360 TQStringList objectTypeStringList, objectTypeNameList;
362 objectTypeStringList << "image";
363 objectTypeNameList << i18n( "Image object type", "Image");
364 TQString objectTypeValue( field.customProperty( "objectType").toString() );
365 if (objectTypeValue.isEmpty())
366 objectTypeValue = DEFAULT_OBJECT_TYPE_VALUE;
367 set->addProperty(prop = new KoProperty::Property( "objectType",
368 objectTypeStringList, objectTypeNameList, objectTypeValue, i18n( "Subtype")));
370 set->addProperty( prop
371 = new KoProperty::Property( "caption", TQVariant(field.caption()), i18n( "Caption") ) );
372 prop->setVisible( false);
374 set->addProperty( prop
375 = new KoProperty::Property( "description", TQVariant(field.description())) );
376 prop->setVisible( false);
378 set->addProperty(prop
379 = new KoProperty::Property( "unsigned", TQVariant(field.isUnsigned()), i18n( "Unsigned Number")));
381 set->addProperty( prop
382 = new KoProperty::Property( "length", ( int)field.length(), i18n( "Length")));
384 set->addProperty( prop
385 = new KoProperty::Property( "precision", ( int)field.precision(), i18n( "Precision")));
386#ifdef KEXI_NO_UNFINISHED
387 prop->setVisible( false);
389 set->addProperty( prop
390 = new KoProperty::Property( "visibleDecimalPlaces", field.visibleDecimalPlaces(), i18n( "Visible Decimal Places")));
391 prop->setOption( "min", -1);
392 prop->setOption( "minValueText", i18n( "Auto Decimal Places", "Auto"));
395 set->addProperty( prop
396 = new KoProperty::Property( "width", ( int)field.width(), i18n( "Column Width")));
397#ifdef KEXI_NO_UNFINISHED
398 prop->setVisible( false);
401 set->addProperty( prop
402 = new KoProperty::Property( "defaultValue", field.defaultValue(), i18n( "Default Value"),
405 (KoProperty::PropertyType)field.variantType()) );
406 prop->setOption( "3rdState", i18n( "None"));
409 set->addProperty( prop
410 = new KoProperty::Property( "primaryKey", TQVariant(field.isPrimaryKey()), i18n( "Primary Key")));
411 prop->setIcon( "key");
413 set->addProperty( prop
414 = new KoProperty::Property( "unique", TQVariant(field.isUniqueKey()), i18n( "Unique")));
416 set->addProperty( prop
417 = new KoProperty::Property( "notNull", TQVariant(field.isNotNull()), i18n( "Required")));
419 set->addProperty( prop
420 = new KoProperty::Property( "allowEmpty", TQVariant(!field.isNotEmpty()), i18n( "Allow Zero\nSize")));
422 set->addProperty( prop
423 = new KoProperty::Property( "autoIncrement", TQVariant(field.isAutoIncrement()), i18n( "Autonumber")));
424 prop->setIcon( "autonumber");
426 set->addProperty( prop
427 = new KoProperty::Property( "indexed", TQVariant(field.isIndexed()), i18n( "Indexed")));
431 set->addProperty( prop = new KoProperty::Property( "rowSource",
432 lookupFieldSchema ? lookupFieldSchema-> rowSource(). name() : TQString(), i18n( "Row Source")));
433 prop->setVisible( false);
435 set->addProperty( prop = new KoProperty::Property( "rowSourceType",
436 lookupFieldSchema ? lookupFieldSchema-> rowSource(). typeName() : TQString(), i18n( "Row Source\nType")));
437 prop->setVisible( false);
439 set->addProperty( prop
440 = new KoProperty::Property( "boundColumn",
441 lookupFieldSchema ? lookupFieldSchema-> boundColumn() : -1, i18n( "Bound Column")));
442 prop->setVisible( false);
447 int visibleColumn = -1;
448 if (lookupFieldSchema && !lookupFieldSchema-> visibleColumns().isEmpty())
450 set->addProperty( prop
451 = new KoProperty::Property( "visibleColumn", visibleColumn, i18n( "Visible Column")));
452 prop->setVisible( false);
457 d->updatePropertiesVisibility(field.type(), *set);
459 connect(set, TQ_SIGNAL(propertyChanged(KoProperty::Set&, KoProperty::Property&)),
462 d->sets->insert(row, set, newOne);
474 d->slotTogglePrimaryKeyCalled = true;
475 d->action_toggle_pkey->setChecked(set[ "primaryKey"].value().toBool());
476 d->slotTogglePrimaryKeyCalled = false;
479void KexiTableDesignerView::slotUpdateRowActions( int row)
481 KexiDataTable::slotUpdateRowActions(row);
487 if (d->slotTogglePrimaryKeyCalled)
489 d->slotTogglePrimaryKeyCalled = true;
493 bool isSet = !set[ "primaryKey"].value().toBool();
494 set.changeProperty( "primaryKey", TQVariant(isSet));
506 d->slotTogglePrimaryKeyCalled = false;
510 bool set, bool aWasPKey, CommandGroup* commandGroup)
512 const bool was_pkey = aWasPKey || propertySet[ "primaryKey"].value().toBool();
514 d->setPropertyValueIfNeeded( propertySet, "primaryKey", TQVariant(set), commandGroup );
517 d->action_toggle_pkey->setChecked(set);
518 if (d->view->selectedItem()) {
520 d->view->KexiDataAwareObjectInterface::data()->clearRowEditBuffer();
521 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(d->view->selectedItem(), COLUMN_ID_ICON,
522 TQVariant(set ? "key" : ""));
523 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*d->view->selectedItem(), true);
526 d->primaryKeyExists = set;
531 KoProperty::Set *s = 0;
533 const int count = (int)d->sets->size();
534 for (i=0; i<count; i++) {
536 if (s && s!=& propertySet && (*s)[ "primaryKey"].value().toBool() && i!=d->view->currentRow())
541 d->setPropertyValueIfNeeded( *s, "autoIncrement", TQVariant( false), commandGroup );
543 d->setPropertyValueIfNeeded( *s, "primaryKey", TQVariant( false), commandGroup );
545 d->view->KexiDataAwareObjectInterface::data()->clearRowEditBuffer();
546 KexiTableItem *item = d->view->itemAt(i);
548 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_ICON, TQVariant());
549 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item, true);
554 d->slotBeforeCellChanged_enabled = false;
555 d->view->KexiDataAwareObjectInterface::data()->clearRowEditBuffer();
556 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(d->view->selectedItem(), COLUMN_ID_TYPE,
557 TQVariant(KexiDB::Field::IntegerGroup-1));
559 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*d->view->selectedItem(), true);
564 d->setPropertyValueIfNeeded( propertySet, "unsigned", TQVariant( true), commandGroup );
566 d->slotBeforeCellChanged_enabled = true;
582 if (!d->view->acceptRowEdit())
590 if (mode==Kexi::DataViewMode) {
592 KMessageBox::sorry( this, i18n( "Cannot switch to data view, because table design is empty.\n"
593 "First, please create your design.") );
602 int r = KMessageBox::warningYesNoCancel( this,
603 i18n( "Saving changes for existing table design is now required.")
606 KStdGuiItem::save(), KStdGuiItem::discard(), TQString(),
607 KMessageBox::Notify|KMessageBox::Dangerous);
608 if (r == KMessageBox::Cancel)
612 dontStore = (r!=KMessageBox::Yes);
614 d->dontAskOnStoreData = true;
638 return d->sets ? d->sets->currentPropertySet() : 0;
660 if (!d->slotBeforeCellChanged_enabled)
664 if (colnum==COLUMN_ID_CAPTION) {
667 if (item->at(COLUMN_ID_TYPE).isNull()) {
669 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_TYPE, TQVariant(( int)0));
672 KoProperty::Set *propertySetForItem = d->sets->findPropertySetForItem(*item);
673 if (propertySetForItem) {
674 d->addHistoryCommand_in_slotPropertyChanged_enabled = false;
675 TQString oldName( propertySetForItem->property( "name").value().toString() );
676 TQString oldCaption( propertySetForItem->property( "caption").value().toString() );
683 propertySetForItem->changeProperty( "caption", newValue);
684 propertySetForItem->changeProperty( "name", newValue);
688 CommandGroup *changeCaptionAndNameCommand = new CommandGroup(
689 i18n( "Change \"%1\" field's name to \"%2\" and caption from \"%3\" to \"%4\"")
690 .arg(oldName).arg(propertySetForItem->property( "name").value().toString())
691 .arg(oldCaption).arg(newValue.toString() ));
692 changeCaptionAndNameCommand->addCommand( changeCaptionCommand );
696 changeCaptionAndNameCommand->addCommand(
698 "name", oldName, propertySetForItem->property( "name").value().toString())
702 d->addHistoryCommand_in_slotPropertyChanged_enabled = true;
705 else if (colnum==COLUMN_ID_TYPE) {
706 if (newValue.isNull()) {
708 d->slotBeforeCellChanged_enabled = false;
709 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_ICON, TQVariant());
710 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_CAPTION, TQVariant(TQString()));
711 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_DESC, TQVariant());
712 d->slotBeforeCellChanged_enabled = true;
716 KoProperty::Set *propertySetForItem = d->sets->findPropertySetForItem(*item);
717 if (!propertySetForItem)
720 KoProperty::Set &set = *propertySetForItem;
725 int i_fieldTypeGroup = newValue.toInt()+1;
726 if (i_fieldTypeGroup < 1 || i_fieldTypeGroup >
727#ifdef KEXI_NO_BLOB_FIELDS
729 ( int)KexiDB::Field::LastTypeGroup-1)
731 (int)KexiDB::Field::LastTypeGroup)
744 TQStringList slist, nlist;
747 TQString subTypeValue;
756 KoProperty::Property *subTypeProperty = &set[ "subType"];
757 kexipluginsdbg << subTypeProperty->value() << endl;
760 CommandGroup *changeDataTypeCommand = new CommandGroup(
761 i18n( "Change data type for field \"%1\" to \"%2\"")
767 const bool forcePropertySetReload
771 const bool useListData = slist.count() > 1;
777 d->setPropertyValueIfNeeded( set, "type", ( int)fieldType, changeDataTypeCommand,
783 d->setPropertyValueIfNeeded( set, "notNull", TQVariant( true), changeDataTypeCommand,
785 d->setPropertyValueIfNeeded( set, "defaultValue", TQVariant( false), changeDataTypeCommand,
796 if (set[ "primaryKey"].value().toBool()== true) {
798 if (fieldTypeGroup != KexiDB::Field::IntegerGroup) {
803 d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant( false), changeDataTypeCommand );
809 d->setPropertyValueIfNeeded( set, "subType", subTypeValue,
810 changeDataTypeCommand, false, false ,
813 if (d->updatePropertiesVisibility(fieldType, set, changeDataTypeCommand) || forcePropertySetReload) {
820 else if (colnum==COLUMN_ID_DESC) {
821 KoProperty::Set *propertySetForItem = d->sets->findPropertySetForItem(*item);
822 if (!propertySetForItem)
825 TQVariant oldValue((*propertySetForItem)[ "description"].value());
826 kexipluginsdbg << oldValue << endl;
827 propertySetForItem->changeProperty( "description", newValue);
836 const int row = d->view->KexiDataAwareObjectInterface::data()->findRef(item);
844 TQString fieldCaption( item->at(COLUMN_ID_CAPTION).toString() );
845 const bool prop_set_allowed = !item->at(COLUMN_ID_TYPE).isNull();
847 if (!prop_set_allowed && d->sets->at(row)) {
849 d->sets->remove( row );
852 d->view->KexiDataAwareObjectInterface::data()->clearRowEditBuffer();
854 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_TYPE, TQVariant());
855 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item);
857 } else if (prop_set_allowed && !d->sets->at(row)) {
860 item->at(COLUMN_ID_TYPE).toInt()+1 );
865 TQString description( item->at(COLUMN_ID_DESC).toString() );
874 KexiDB::Field::NoConstraints,
875 KexiDB::Field::NoOptions,
886 field.setNotNull( true );
887 field.setDefaultValue( TQVariant( false) );
890 kexipluginsdbg << "KexiTableDesignerView::slotRowUpdated(): " << field.debugString() << endl;
905 if (d->addHistoryCommand_in_slotRowUpdated_enabled) {
911 kexipluginswarn << "KexiTableDesignerView::slotRowUpdated() row # not found !" << endl;
925 const TQCString pname = property.name();
926 kexipluginsdbg << "KexiTableDesignerView::slotPropertyChanged(): " << pname << " = " << property.value()
927 << " (oldvalue = " << property.oldValue() << ")" << endl;
930 bool changePrimaryKey = false;
932 bool setPrimaryKey = false;
934 if (pname== "primaryKey" && d->slotPropertyChanged_primaryKey_enabled) {
935 changePrimaryKey = true;
936 setPrimaryKey = property.value().toBool();
940 if (pname== "rowSource" || pname== "rowSourceType") {
943 const int row = d->sets->findRowForPropertyValue( "uid", set[ "uid"].value().toInt());
944 KexiTableItem *item = d->view->itemAt(row);
946 d->updateIconForItem(*item, set);
950 CommandGroup *setAutonumberCommand = 0;
951 CommandGroup *toplevelCommand = 0;
952 if (pname== "autoIncrement" && property.value().toBool()== true) {
953 if (set[ "primaryKey"].value().toBool()== false) {
954 TQString msg = TQString( "<p>")
955 +i18n( "Setting autonumber requires primary key to be set for current field.")+ "</p>";
956 if (d->primaryKeyExists)
957 msg += (TQString( "<p>")+ i18n( "Previous primary key will be removed.")+ "</p>");
958 msg += (TQString( "<p>")
959 +i18n( "Do you want to create primary key for current field? "
960 "Click \"Cancel\" to cancel setting autonumber.")+ "</p>");
962 if (KMessageBox::Yes == KMessageBox::questionYesNo( this, msg,
963 i18n( "Setting Autonumber Field"),
964 KGuiItem(i18n( "Create &Primary Key"), "key"), KStdGuiItem::cancel() ))
966 changePrimaryKey = true;
967 setPrimaryKey = true;
970 setAutonumberCommand = new CommandGroup(
971 i18n( "Assign autonumber for field \"%1\"").arg(set[ "name"].value().toString()) );
972 toplevelCommand = setAutonumberCommand;
973 d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant( true), setAutonumberCommand );
976 setAutonumberCommand = new CommandGroup(
977 i18n( "Remove autonumber from field \"%1\"").arg(set[ "name"].value().toString()) );
981 d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant( false), setAutonumberCommand,
990 if ((pname== "indexed" || pname== "unique" || pname== "notNull")
991 && set[ "primaryKey"].value().toBool() && property.value().toBool()== false)
994 changePrimaryKey = true;
995 setPrimaryKey = false;
997 CommandGroup *unsetIndexedOrUniquOrNotNullCommand = new CommandGroup(
998 i18n( "Set \"%1\" property for field \"%2\"").arg(property.caption()).arg(set[ "name"].value().toString()) );
999 toplevelCommand = unsetIndexedOrUniquOrNotNullCommand;
1000 d->setPropertyValueIfNeeded( set, pname, TQVariant( false), unsetIndexedOrUniquOrNotNullCommand );
1001 if (pname== "notNull") {
1003 d->setPropertyValueIfNeeded( set, "unique", TQVariant( false), unsetIndexedOrUniquOrNotNullCommand );
1007 if (pname== "defaultValue") {
1012 if (pname== "subType" && d->slotPropertyChanged_subType_enabled) {
1013 d->slotPropertyChanged_subType_enabled = false;
1014 if (set[ "primaryKey"].value().toBool()== true
1017 kexipluginsdbg << "INVALID " << property.value().toString() << endl;
1042 CommandGroup* changeFieldTypeCommand = new CommandGroup(
1043 i18n( "Change type for field \"%1\" to \"%2\"").arg(set[ "name"].value().toString())
1045 d->setPropertyValueIfNeeded( set, "subType", property.value(), property.oldValue(),
1046 changeFieldTypeCommand );
1048 kexipluginsdbg << set[ "type"].value() << endl;
1050 set[ "type"].setValue( newType );
1053 TQVariant oldDefVal( set[ "defaultValue"].value() );
1055 if (oldDefVal.type()!=newDefVal.type())
1056 set[ "defaultValue"].setType( newDefVal.type() );
1057 d->setPropertyValueIfNeeded( set, "defaultValue", newDefVal, newDefVal,
1058 changeFieldTypeCommand );
1060 d->updatePropertiesVisibility(newType, set);
1063 d->slotPropertyChanged_subType_enabled = true;
1072 if (d->addHistoryCommand_in_slotPropertyChanged_enabled && !changePrimaryKey) {
1074 property.name(), property.oldValue() , property.value()),
1078 if (changePrimaryKey) {
1079 d->slotPropertyChanged_primaryKey_enabled = false;
1080 if (setPrimaryKey) {
1086 CommandGroup *setPrimaryKeyCommand = new CommandGroup(
1087 i18n( "Set primary key for field \"%1\"")
1088 .arg(set[ "name"].value().toString()) );
1089 if (toplevelCommand)
1090 toplevelCommand->addCommand( setPrimaryKeyCommand );
1092 toplevelCommand = setPrimaryKeyCommand;
1094 d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant( true), setPrimaryKeyCommand, true );
1095 d->setPropertyValueIfNeeded( set, "unique", TQVariant( true), setPrimaryKeyCommand );
1096 d->setPropertyValueIfNeeded( set, "notNull", TQVariant( true), setPrimaryKeyCommand );
1097 d->setPropertyValueIfNeeded( set, "allowEmpty", TQVariant( false), setPrimaryKeyCommand );
1098 d->setPropertyValueIfNeeded( set, "indexed", TQVariant( true), setPrimaryKeyCommand );
1100 d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant( true), setPrimaryKeyCommand );
1112 CommandGroup *setPrimaryKeyCommand = new CommandGroup(
1113 i18n( "Unset primary key for field \"%1\"")
1114 .arg(set[ "name"].value().toString()) );
1115 if (toplevelCommand)
1116 toplevelCommand->addCommand( setPrimaryKeyCommand );
1118 toplevelCommand = setPrimaryKeyCommand;
1120 d->setPropertyValueIfNeeded( set, "primaryKey", TQVariant( false), setPrimaryKeyCommand, true );
1121 d->setPropertyValueIfNeeded( set, "autoIncrement", TQVariant( false), setPrimaryKeyCommand );
1127 d->updatePropertiesVisibility(
1132 d->slotPropertyChanged_primaryKey_enabled = true;
1140 if (d->addHistoryCommand_in_slotRowInserted_enabled) {
1141 const int row = d->view->currentRow();
1154 if (item[COLUMN_ID_ICON].toString()== "key")
1155 d->primaryKeyExists = false;
1157 if (d->addHistoryCommand_in_slotAboutToDeleteRow_enabled) {
1158 const int row = d->view->KexiDataAwareObjectInterface::data()->findRef(&item);
1159 KoProperty::Set *set = row >=0 ? d->sets->at(row) : 0;
1171 kexipluginsdbg << set[ "type"].value() << endl;
1172 TQMap<TQCString, TQVariant> values = KoProperty::propertyValues(set);
1174 TQMap<TQCString, TQVariant>::Iterator it = values.begin();
1177 while (it!=values.end()) {
1178 const TQString propName( it.key() );
1179 if (d->internalPropertyNames.find(propName.latin1()) || propName.startsWith( "this:")
1182 TQMap<TQCString, TQVariant>::Iterator it_tmp = it;
1184 values.remove(it_tmp);
1200 if (!d->view->acceptRowEdit())
1205 if (!d->primaryKeyExists) {
1207 kexipluginsdbg << "KexiTableDesignerView::buildSchema(): no primay key defined..." << endl;
1210 const int questionRes = KMessageBox::questionYesNoCancel( this,
1211 i18n( "<p>Table \"%1\" has no <b>primary key</b> defined.</p>"
1212 "<p>Although a primary key is not required, it is needed "
1213 "for creating relations between database tables. "
1214 "Do you want to add primary key automatically now?</p>"
1215 "<p>If you want to add a primary key by hand, press \"Cancel\" "
1216 "to cancel saving table design.</p>").arg(schema.name()),
1217 TQString(), KGuiItem(i18n( "&Add Primary Key"), "key"), KStdGuiItem::no(),
1218 "autogeneratePrimaryKeysOnTableDesignSaving");
1219 if (questionRes==KMessageBox::Cancel) {
1222 else if (questionRes==KMessageBox::Yes) {
1226 TQString pkFieldName( "id%1");
1227 TQString pkFieldCaption(i18n( "Identifier%1", "Id%1"));
1228 while (i<( int)d->sets->size()) {
1229 KoProperty::Set *set = d->sets->at(i);
1231 if ((*set)[ "name"].value().toString()
1232 == pkFieldName.arg(idIndex==1?TQString() : TQString::number(idIndex))
1233 || (*set)[ "caption"].value().toString()
1234 == pkFieldCaption.arg(idIndex==1?TQString() : TQString::number(idIndex)))
1244 pkFieldName = pkFieldName.arg(idIndex==1?TQString() : TQString::number(idIndex));
1245 pkFieldCaption = pkFieldCaption.arg(idIndex==1?TQString() : TQString::number(idIndex));
1247 d->view->insertEmptyRow(0);
1248 d->view->setCursorPosition(0, COLUMN_ID_CAPTION);
1249 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(d->view->selectedItem(), COLUMN_ID_CAPTION,
1250 TQVariant(pkFieldCaption));
1251 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(d->view->selectedItem(), COLUMN_ID_TYPE,
1252 TQVariant(KexiDB::Field::IntegerGroup-1));
1253 if (!d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*d->view->selectedItem(), true)) {
1262 KoProperty::Set *b = 0;
1263 bool no_fields = true;
1265 TQDict<char> names(1009, false);
1267 for (i=0;i<(int)d->sets->size();i++) {
1271 const TQString name = (*b)[ "name"].value().toString();
1272 if (name.isEmpty()) {
1275 TQString( "KexiTableDesignerView::buildSchema(): no field caption entered at row %1...")
1279 d->view->setCursorPosition(i, COLUMN_ID_CAPTION);
1280 d->view->startEditCurrentCell();
1281 KMessageBox::information( this, i18n( "You should enter field caption.") );
1289 names.insert( name, &dummy );
1292 if (res == true && no_fields) {
1295 "KexiTableDesignerView::buildSchema(): no field defined..." << endl;
1298 KMessageBox::sorry( this,
1299 i18n( "You have added no fields.\nEvery table should have at least one field.") );
1303 if (res == true && b && i<( int)d->sets->size()) {
1306 TQString( "KexiTableDesignerView::buildSchema(): duplicated field name '%1'")
1307 .arg((*b)[ "name"].value().toString()) << endl;
1310 d->view->setCursorPosition(i, COLUMN_ID_CAPTION);
1311 d->view->startEditCurrentCell();
1313 KMessageBox::sorry( this,
1314 i18n( "You have added \"%1\" field name twice.\nField names cannot be repeated. "
1315 "Correct name of the field.")
1316 .arg((*b)[ "name"].value().toString()) );
1322 for (i=0;i<(int)d->sets->size();i++) {
1323 KoProperty::Set *s = d->sets->at(i);
1330 if (!(*s)[ "rowSource"].value().toString().isEmpty() && !(*s)[ "rowSourceType"].value().toString().isEmpty()) {
1334 lookupFieldSchema-> rowSource(). setName( (*s)[ "rowSource"].value().toString() );
1335 lookupFieldSchema-> setBoundColumn( (*s)[ "boundColumn"].value().toInt() );
1339 TQValueList<uint> visibleColumns;
1340 const int visibleColumn = (*s)[ "visibleColumn"].value().toInt();
1341 if (visibleColumn >= 0)
1342 visibleColumns.append( (uint)visibleColumn );
1347 "KexiTableDesignerView::buildSchema(): !schema.setLookupFieldSchema()" << endl;
1348 delete lookupFieldSchema;
1361 CommandGroup* cmdGroup = dynamic_cast<CommandGroup* >( command );
1363 for (TQPtrListIterator<KCommand> it(cmdGroup->commands()); it.current(); ++it)
1364 copyAlterTableActions(it.current(), actions);
1369 kexipluginswarn << "KexiTableDesignerView::copyAlterTableActions(): cmd is not of type 'Command'!" << endl;
1375 actions.append( action );
1381 kexipluginsdbg << "KexiTableDesignerView::buildAlterTableActions(): " << d->history->commands().count()
1382 << " top-level command(s) to process..." << endl;
1383 for (TQPtrListIterator<KCommand> it(d->history->commands()); it.current(); ++it) {
1384 copyAlterTableActions(it.current(), actions);
1391 if (tempData()->table || m_dialog->schemaData())
1396 tempData()->table->setName( sdata.name() );
1397 tempData()->table->setCaption( sdata.caption() );
1398 tempData()->table->setDescription( sdata.description() );
1414 tempData()->tableSchemaChangedInPreviousView = true;
1419 delete tempData()->table;
1420 tempData()->table = 0;
1422 return tempData()->table;
1427 if (!tempData()->table || !m_dialog->schemaData()) {
1428 d->recentResultOfStoreData = false;
1439 bool realAlterTableCanBeUsed = false;
1444 if (!d->tempStoreDataUsingRealAlterTable) {
1448 (void)alterTableHandler-> execute(tempData()->table->name(), args);
1451 realAlterTableCanBeUsed = true;
1456 res = KexiTablePart::askForClosingObjectsUsingTableSchema(
1457 this, *conn, *tempData()->table,
1458 i18n( "You are about to change the design of table \"%1\" "
1459 "but following objects using this table are opened:")
1460 .arg(tempData()->table->name()));
1464 if (!d->tempStoreDataUsingRealAlterTable && !realAlterTableCanBeUsed) {
1466 delete alterTableHandler;
1467 alterTableHandler = 0;
1469 if (!d->dontAskOnStoreData && !dontAsk) {
1471 const TQString msg = d->messageForSavingChanges(emptyTable);
1473 if (KMessageBox::No == KMessageBox::questionYesNo( this, msg))
1477 d->dontAskOnStoreData = false;
1479 d->recentResultOfStoreData = res;
1487 kexipluginsdbg << "KexiTableDesignerView::storeData() : BUILD SCHEMA:" << endl;
1490 res = conn-> alterTable(*tempData()->table, *newTable);
1496 newTable = alterTableHandler-> execute(tempData()->table->name(), args);
1498 kexipluginsdbg << "KexiTableDesignerView::storeData() : ALTER TABLE EXECUTE: "
1508 tempData()->table = newTable;
1509 tempData()->tableSchemaChangedInPreviousView = true;
1510 d->history-> clear();
1515 delete alterTableHandler;
1516 d->recentResultOfStoreData = res;
1522#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
1523# ifdef KEXI_DEBUG_GUI
1526 if (!tempData()->table || !m_dialog->schemaData())
1541 (void)alterTableHandler. execute(tempData()->table->name(), args);
1559 signal.connect( mainWin(), TQ_SLOT(slotProjectSave()) );
1560 d->tempStoreDataUsingRealAlterTable = true;
1561 d->recentResultOfStoreData = false;
1563 d->tempStoreDataUsingRealAlterTable = false;
1564 return d->recentResultOfStoreData;
1567KexiTablePart::TempData* KexiTableDesignerView::tempData() const
1589#ifdef KEXI_DEBUG_GUI
1590void KexiTableDesignerView::debugCommand( KCommand* command, int nestingLevel )
1592 if ( dynamic_cast<Command* >(command))
1593 KexiUtils::addAlterTableActionDebug( dynamic_cast<Command* >(command)->debugString(), nestingLevel);
1595 KexiUtils::addAlterTableActionDebug(command->name(), nestingLevel);
1597 if ( dynamic_cast<CommandGroup* >(command)) {
1598 for (TQPtrListIterator<KCommand> it( dynamic_cast<CommandGroup* >(command)->commands()); it.current(); ++it) {
1599 debugCommand(it.current(), nestingLevel + 1);
1607#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
1608# ifdef KEXI_DEBUG_GUI
1609 debugCommand( command, 0 );
1611 d->history->addCommand( command, execute );
1618#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
1619 setAvailable( "edit_undo", d->historyActionCollection->action( "edit_undo")->isEnabled());
1620 setAvailable( "edit_redo", d->historyActionCollection->action( "edit_redo")->isEnabled());
1626#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
1627# ifdef KEXI_DEBUG_GUI
1628 KexiUtils::addAlterTableActionDebug(TQString( "UNDO:"));
1637#ifndef KEXI_NO_UNDOREDO_ALTERTABLE
1638# ifdef KEXI_DEBUG_GUI
1639 KexiUtils::addAlterTableActionDebug(TQString( "REDO:"));
1648#ifdef KEXI_DEBUG_GUI
1649 debugCommand( command, 1 );
1658 TQString captionOrName(set[ "caption"].value().toString());
1659 if (captionOrName.isEmpty())
1660 captionOrName = set[ "name"].value().toString();
1662 d->contextMenuTitle->setTitle( i18n( "Table field \"%1\"").arg(captionOrName) );
1665 d->contextMenuTitle->setTitle( i18n( "Empty table row", "Empty Row") );
1684 if (!d->view->acceptRowEdit())
1686 KexiTableItem *item = d->view->itemAt(row);
1690 d->sets->remove( row );
1694 d->addHistoryCommand_in_slotRowUpdated_enabled = false;
1695 d->addHistoryCommand_in_slotPropertyChanged_enabled = false;
1696 d->slotBeforeCellChanged_enabled = false;
1698 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_TYPE, TQVariant());
1700 d->addHistoryCommand_in_slotRowUpdated_enabled = true;
1701 d->addHistoryCommand_in_slotPropertyChanged_enabled = true;
1702 d->slotBeforeCellChanged_enabled = true;
1704 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item, true);
1718 const TQString& caption, bool addCommand)
1720 if (set && (!set->contains( "type") || !set->contains( "caption"))) {
1721 kexipluginswarn << "KexiTableDesignerView::insertField(): no 'type' or 'caption' property in set!" << endl;
1724 if (!d->view->acceptRowEdit())
1726 KexiTableItem *item = d->view->itemAt(row);
1730 d->addHistoryCommand_in_slotRowUpdated_enabled = false;
1731 d->addHistoryCommand_in_slotPropertyChanged_enabled = false;
1732 d->slotBeforeCellChanged_enabled = false;
1734 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_CAPTION,
1735 set ? (*set)[ "caption"].value() : TQVariant(caption));
1736 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_TYPE,
1738 : ((( int)KexiDB::Field::TextGroup)-1)
1740 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_DESC,
1741 set ? (*set)[ "description"].value() : TQVariant());
1743 d->slotBeforeCellChanged_enabled = true;
1746 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item);
1748 KoProperty::Set *newSet = d->sets->at(row);
1753 kexipluginswarn << "KexiTableDesignerView::insertField() !newSet, row==" << row << endl;
1757 d->addHistoryCommand_in_slotPropertyChanged_enabled = true;
1758 d->addHistoryCommand_in_slotRowUpdated_enabled = true;
1760 d->view->updateRow( row );
1767 d->addHistoryCommand_in_slotRowInserted_enabled = false;
1769 d->view->insertEmptyRow( row );
1771 d->addHistoryCommand_in_slotRowInserted_enabled = true;
1784 KexiTableItem *item = d->view->itemAt( row );
1788 d->addHistoryCommand_in_slotAboutToDeleteRow_enabled = false;
1790 const bool res = d->view->deleteItem(item);
1792 d->addHistoryCommand_in_slotAboutToDeleteRow_enabled = true;
1799 const TQCString& propertyName, const TQVariant& newValue,
1800 KoProperty::Property::ListData* const listData, bool addCommand )
1802#ifdef KEXI_DEBUG_GUI
1803 KexiUtils::addAlterTableActionDebug(TQString( "** changeFieldProperty: \"")
1804 + TQString(propertyName) + "\" to \"" + newValue.toString() + "\"", 2);
1806 if (!d->view->acceptRowEdit())
1809 KoProperty::Set* set = d->sets->at( row );
1810 if (!set || !set->contains(propertyName))
1812 KoProperty::Property & property = set->property(propertyName);
1814 if (listData->keys.isEmpty())
1815 property.setListData( 0 );
1817 property.setListData( new KoProperty::Property::ListData(*listData) );
1819 if (propertyName != "type")
1820 property.setValue(newValue);
1821 KexiTableItem *item = d->view->itemAt(row);
1824 if (propertyName == "type") {
1827 d->slotPropertyChanged_subType_enabled = false;
1828 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_TYPE,
1830 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item);
1831 d->addHistoryCommand_in_slotRowUpdated_enabled = true;
1834 property.setValue(newValue);
1838 d->addHistoryCommand_in_slotRowUpdated_enabled = false;
1839 d->addHistoryCommand_in_slotPropertyChanged_enabled = false;
1840 d->slotPropertyChanged_subType_enabled = false;
1843 if (propertyName == "caption") {
1845 d->slotBeforeCellChanged_enabled = false;
1847 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_CAPTION, newValue);
1848 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item);
1850 d->slotBeforeCellChanged_enabled = true;
1853 else if (propertyName == "description") {
1855 d->slotBeforeCellChanged_enabled = false;
1857 d->view->KexiDataAwareObjectInterface::data()->updateRowEditBuffer(item, COLUMN_ID_DESC, newValue);
1859 d->slotBeforeCellChanged_enabled = true;
1861 d->view->KexiDataAwareObjectInterface::data()->saveRowChanges(*item);
1864 d->addHistoryCommand_in_slotPropertyChanged_enabled = true;
1865 d->addHistoryCommand_in_slotRowUpdated_enabled = true;
1866 d->slotPropertyChanged_subType_enabled = true;
1868 d->view->updateRow( row );
1872 const TQCString& propertyName, const TQVariant& newValue,
1873 KoProperty::Property::ListData* const listData, bool addCommand )
1876 const int row = d->sets->findRowForPropertyValue( "uid", fieldUID);
1878 kexipluginswarn << "KexiTableDesignerView::changeFieldProperty(): field with uid="<<fieldUID<< " not found!"<<endl;
1885 int fieldUID, const TQCString& propertyName, bool visible )
1887#ifdef KEXI_DEBUG_GUI
1888 KexiUtils::addAlterTableActionDebug(TQString( "** changePropertyVisibility: \"")
1889 + TQString(propertyName) + "\" to \"" + (visible ? "true" : "false") + "\"", 2);
1891 if (!d->view->acceptRowEdit())
1895 const int row = d->sets->findRowForPropertyValue( "uid", fieldUID);
1898 KoProperty::Set* set = d->sets->at( row );
1899 if (!set || !set->contains(propertyName))
1902 KoProperty::Property & property = set->property(propertyName);
1903 if (property.isVisible() != visible) {
1904 property.setVisible(visible);
1935 (void)alterTableHandler-> execute(tempData()->table->name(), args);
1937 delete alterTableHandler;
1943#include "kexitabledesignerview.moc"
void plugSharedAction(const char *action_name, TQObject *receiver, const char *slot)
@ Identifier string allowing nonempty identifiers
static void init() Called once to register all propert and editor types provided by this factory.
Abstract base class used for implementing all the AlterTable actions.
Arguments for AlterTableHandler::execute().
bool onlyComputeRequirements
A tool for handling altering database table schema.
void setActions(const ActionList &actions)
TQPtrList< ActionBase > ActionList Defines a type for action list.
TableSchema * execute(const TQString &tableName, ExecutionArguments &args)
Provides database connection, allowing queries and data modification.
bool createTable(TableSchema *tableSchema, bool replaceExisting=false) Creates a table according to the given schema.
virtual bool isReadOnly() const
tristate alterTable(TableSchema &tableSchema, TableSchema &newTableSchema)
FieldList & addField(Field *field)
TQString typeName() const
TQString captionOrName() const
TQString typeString() const
static TQVariant::Type variantType(uint type) Converts type type to TQVariant equivalent as accurate as possible.
void setEnumHints(const TQValueVector< TQString > &l)
void setSubType(const TQString &subType)
static Type typeForString(const TQString &typeString)
static TQString typeName(uint type)
TypeGroup typeGroup() const
TQString typeGroupName() const
static TypeGroup typeGroup(uint type)
virtual TableSchema * table() const
static TQString typeString(uint type)
TQString typeName() const
void setTypeByName(const TQString &typeName)
@ NoType used for invalid schema
void setName(const TQString &name)
Provides information about lookup field's setup.
void setVisibleColumns(const TQValueList< uint > &list)
void setBoundColumn(int column)
TQValueList< uint > visibleColumns() const
TQString debugString(bool includeTableName)
bool setLookupFieldSchema(const TQString &fieldName, LookupFieldSchema *lookupFieldSchema)
KexiTableViewData * data() const
KexiDataTable(KexiMainWindow *mainWin, TQWidget *parent, const char *name=0, bool dbAware=true)
KexiDialogTempData * tempData() const
KexiPart::Part * part() const
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
virtual KexiProject * project()=0 Project data of currently opened project or NULL if no project here yet.
KexiDB::Connection * dbConnection() const
Undo/redo command used for when changing a property for a table field.
Base class for all Table Designer's commands.
virtual KexiDB::AlterTableHandler::ActionBase * createAction()
Undo/redo command used when property visibility is changed.
Undo/redo command used when a new field is inserted into a table.
Undo/redo command used when a field is removed from a table.
void slotAboutToShowContextMenu()
void switchPrimaryKey(KoProperty::Set &propertySet, bool set, bool aWasPKey=false, CommandGroup *commandGroup=0)
void slotTogglePrimaryKey()
virtual KoProperty::Set * propertySet()
void getSubTypeListData(KexiDB::Field::TypeGroup fieldTypeGroup, TQStringList &stringsList, TQStringList &namesList) Gets subtype strings and names for type fieldType.
virtual KexiDB::SchemaData * storeNewData(const KexiDB::SchemaData &sdata, bool &cancel)
void slotAboutToDeleteRow(KexiTableItem &item, KexiDB::ResultInfo *result, bool repaint) Called before row deleting in tableview.
virtual tristate afterSwitchFrom(int mode)
virtual void deleteRow(int row, bool addCommand=false)
void insertFieldInternal(int row, KoProperty::Set *set, const TQString &caption, bool addCommand)
void addHistoryCommand(KCommand *command, bool execute)
virtual void propertySetSwitched() Reimplemented to pass the information also to the "Lookup" tab.
KexiTableDesignerView(KexiMainWindow *win, TQWidget *parent)
virtual void changeFieldPropertyForRow(int row, const TQCString &propertyName, const TQVariant &newValue, KoProperty::Property::ListData *const listData, bool addCommand)
tristate buildSchema(KexiDB::TableSchema &schema, bool beSilent=false)
virtual void insertField(int row, const TQString &caption, bool addCommand=false)
virtual TQString debugStringForCurrentTableSchema(tristate &result)
void initData() called whenever data should be reloaded (on switching to this view mode)
void slotRowInserted() Called before row inserting in tableview.
void slotBeforeCellChanged(KexiTableItem *item, int colnum, TQVariant &newValue, KexiDB::ResultInfo *result) Called before cell change in tableview.
virtual tristate storeData(bool dontAsk=false)
virtual void clearRow(int row, bool addCommand=false)
virtual tristate executeRealAlterTable()
void slotSimulateAlterTableExecution()
void slotCommandExecuted(KCommand *command)
void slotPropertyChanged(KoProperty::Set &set, KoProperty::Property &property)
void updateUndoRedoActions() Updates undo/redo shared actions availability by looking at command history's action.
KoProperty::Set * createPropertySet(int row, const KexiDB::Field &field, bool newOne=false)
void changePropertyVisibility(int fieldUID, const TQCString &propertyName, bool visible)
KexiDB::Field * buildField(const KoProperty::Set &set) const
bool isPhysicalAlteringNeeded()
tristate buildAlterTableActions(KexiDB::AlterTableHandler::ActionList &actions)
virtual tristate simulateAlterTableExecution(TQString *debugTarget)
virtual tristate beforeSwitchTo(int mode, bool &dontStore)
void slotRowUpdated(KexiTableItem *item) Called on row change in a tableview.
virtual void insertEmptyRow(int row, bool addCommand=false)
void changeFieldProperty(int fieldUID, const TQCString &propertyName, const TQVariant &newValue, KoProperty::Property::ListData *const listData=0, bool addCommand=false)
KexiDB::Field * field() const
void setHeaderTextVisible(bool visible)
void setIcon(const TQIconSet &icon)
void setReadOnly(bool ro) forces readOnly flag to be set to ro
KexiTableView class provides a widget for displaying data in a tabular view.
virtual TDEAction * sharedAction(const char *action_name)
virtual bool dirty() const
virtual void setAvailable(const char *action_name, bool set)
virtual void propertySetSwitched()
void propertySetReloaded(bool preservePrevSelection=false, const TQCString &propertyToSelect=TQCString())
KexiDialogBase * parentDialog() const
KexiMainWindow * mainWin() const
3-state logical type with three values: true, false and cancelled and convenient operators.
TQString toString() const
KEXI_DB_EXPORT TQStringList typeStringsForGroup(Field::TypeGroup typeGroup)
KEXI_DB_EXPORT Field::Type intToFieldType(int type)
KEXI_DB_EXPORT TQStringList typeNamesForGroup(Field::TypeGroup typeGroup)
KEXI_DB_EXPORT bool setFieldProperties(Field &field, const TQMap< TQCString, TQVariant > &values)
KEXI_DB_EXPORT Field::Type defaultTypeForGroup(Field::TypeGroup typeGroup)
KEXIUTILS_EXPORT TQString string2Identifier(const TQString &s)
KEXIUTILS_EXPORT TQIconSet colorizeIconToTextColor(const TQPixmap &icon, const TQPalette &palette)
@ TextViewMode Also known as SQL View Mode.
|