[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/koffice/1.6/koffice/kexi/plugins/tables
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2007-04-05 11:05:25
Message-ID: 1175771125.422835.30795.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 650734 by staniek:
Table Designer
- clear command history after successful saving of the design
- on switching to data view, do not warn about removing data,
if the data will stay untouched
2.0: merged
M +27 -2 kexitabledesignerview.cpp
M +6 -0 kexitabledesignerview.h
M +6 -2 kexitabledesignerview_p.cpp
M +7 -1 kexitabledesignerview_p.h
M +2 -2 kexitablepartinstui.rc
--- branches/koffice/1.6/koffice/kexi/plugins/tables/kexitabledesignerview.cpp \
#650733:650734 @@ -601,7 +601,8 @@
bool emptyTable;
int r = KMessageBox::warningYesNoCancel(this,
i18n("Saving changes for existing table design is now required.")
- + "\n" + d->messageForSavingChanges(emptyTable), QString::null,
+ + "\n" + d->messageForSavingChanges(emptyTable, /* skip warning? \
*/!isPhysicalAlteringNeeded()), + QString::null,
KStdGuiItem::save(), KStdGuiItem::discard(), QString::null,
KMessageBox::Notify|KMessageBox::Dangerous);
if (r == KMessageBox::Cancel)
@@ -1464,7 +1465,7 @@
//! @todo temp; remove this case:
delete alterTableHandler;
alterTableHandler = 0;
- // - inform about removing the current table and ask for confimation
+ // - inform about removing the current table and ask for confirmation
if (!d->dontAskOnStoreData && !dontAsk) {
bool emptyTable;
const QString msg = d->messageForSavingChanges(emptyTable);
@@ -1506,6 +1507,7 @@
//change current schema
tempData()->table = newTable;
tempData()->tableSchemaChangedInPreviousView = true;
+ d->history->clear();
}
else {
delete newTable;
@@ -1915,4 +1917,27 @@
->assignPropertySet(propertySet());
}
+bool KexiTableDesignerView::isPhysicalAlteringNeeded()
+{
+ //- create action list for the alter table handler
+ KexiDB::AlterTableHandler::ActionList actions;
+ tristate res = buildAlterTableActions( actions );
+ if (res != true)
+ return true;
+
+ KexiDB::Connection *conn = mainWin()->project()->dbConnection();
+ KexiDB::AlterTableHandler *alterTableHandler = new KexiDB::AlterTableHandler( *conn \
); + alterTableHandler->setActions(actions);
+
+ //only compute requirements
+ KexiDB::AlterTableHandler::ExecutionArguments args;
+ args.onlyComputeRequirements = true;
+ (void)alterTableHandler->execute(tempData()->table->name(), args);
+ res = args.result;
+ delete alterTableHandler;
+ if (res == true && 0 == (args.requirements & (0xffff ^ \
KexiDB::AlterTableHandler::SchemaAlteringRequired))) + return false;
+ return true;
+}
+
#include "kexitabledesignerview.moc"
--- branches/koffice/1.6/koffice/kexi/plugins/tables/kexitabledesignerview.h \
#650733:650734 @@ -245,6 +245,12 @@
//! Reimplemented to pass the information also to the "Lookup" tab
virtual void propertySetSwitched();
+ /*! \return true if physical altering is needed for the current list of actions.
+ Used in KexiTableDesignerView::beforeSwitchTo() to avoid warning about removinf
+ table data if table recreating is not needed.
+ True is also returned if there is any trouble with getting the answer. */
+ bool isPhysicalAlteringNeeded();
+
private:
KexiTableDesignerViewPrivate *d;
};
--- branches/koffice/1.6/koffice/kexi/plugins/tables/kexitabledesignerview_p.cpp \
#650733:650734 @@ -87,6 +87,10 @@
KCommandHistory::redo();
}
+void CommandHistory::clear() {
+ KCommandHistory::clear(); m_commandsToUndo.clear();
+}
+
//----------------------------------------------
KexiTableDesignerViewPrivate::KexiTableDesignerViewPrivate(KexiTableDesignerView* \
aDesignerView) @@ -265,13 +269,13 @@
return changed;
}
-QString KexiTableDesignerViewPrivate::messageForSavingChanges(bool &emptyTable)
+QString KexiTableDesignerViewPrivate::messageForSavingChanges(bool &emptyTable, bool \
skipWarning) {
KexiDB::Connection *conn = designerView->mainWin()->project()->dbConnection();
bool ok;
emptyTable = conn->isEmpty( *designerView->tempData()->table, ok ) && ok;
return i18n("Do you want to save the design now?")
- + ( emptyTable ? QString::null :
+ + ( (emptyTable || skipWarning) ? QString::null :
(QString("\n\n") + designerView->part()->i18nMessage(":additional message before \
saving design", designerView->parentDialog())) );
}
--- branches/koffice/1.6/koffice/kexi/plugins/tables/kexitabledesignerview_p.h \
#650733:650734 @@ -57,6 +57,8 @@
void addCommand(KCommand *command, bool execute = true);
+ void clear();
+
public slots:
virtual void undo();
virtual void redo();
@@ -117,7 +119,11 @@
bool updatePropertiesVisibility(KexiDB::Field::Type fieldType, KoProperty::Set \
&set, CommandGroup *commandGroup = 0);
- QString messageForSavingChanges(bool &emptyTable);
+ /*! \return message used to ask user for accepting saving the design.
+ \a emptyTable is set to true if the table designed contains no rows.
+ If \a skipWarning is true, no warning about data loss is appended (useful when
+ only non-physical altering actions will be performed). */
+ QString messageForSavingChanges(bool &emptyTable, bool skipWarning = false);
/*! Updates icon in the first column, depending on property set \a set.
For example, when "rowSource" and "rowSourceType" propertiesa are not empty,
--- branches/koffice/1.6/koffice/kexi/plugins/tables/kexitablepartinstui.rc \
#650733:650734 @@ -1,5 +1,5 @@
<!DOCTYPE kpartgui>
-<kpartgui name="kexitablepartinst" version="5">
+<kpartgui name="kexitablepartinst" version="6">
<MenuBar>
<Menu name="edit" noMerge="0">
@@ -9,7 +9,7 @@
</Menu>
</MenuBar>
-<ToolBar name="design" fullWidth="false" noMerge="0">
+<ToolBar name="designToolBar" fullWidth="false" noMerge="0">
<text>Design</text>
<!-- Design View -->
<!-- TODO: reenable after shared toggle actions fix: Action \
name="tablepart_toggle_pkey"/ -->
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic