[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kexi] src/plugins/tables: Table designer: Improve warning box about losing data when table schema s
From:       Jaroslaw Staniek <staniek () kde ! org>
Date:       2016-02-29 23:12:16
Message-ID: E1aaWzA-0000sv-Kh () scm ! kde ! org
[Download RAW message or body]

Git commit 2a916fd80a52510eefd838065ed1cb4d33be89eb by Jaroslaw Staniek.
Committed on 29/02/2016 at 23:07.
Pushed by staniek into branch 'master'.

Table designer: Improve warning box about losing data when table schema should be \
altered

Summary:
There's the "Saving changes for existing table design is now required.
Do you want to save the design now?

Warning! Any data in this table will be removed upon design's saving!"

Improvements:
- better button texts, "Save" and "Discard" were apparently not enough for some \
                users, see e.g. \
                https://forum.kde.org/viewtopic.php?f=220&t=131143&p=351981#p351973
- Fix the issue with displaying HTML tags due to joining parts of messages, now we're \
using KLocalizedString more for lazy evaluation

Test Plan: Create a test table with at least 1 record, add/remove one column from the \
design, switch to the data view. Observe the message.

Reviewers: piggz, wkosowicz, kpawlowski, wicik

Subscribers: Kexi-Devel-list

Projects: #kexi

Differential Revision: https://phabricator.kde.org/D1001

M  +18   -5    src/plugins/tables/kexitabledesignerview.cpp
M  +6    -5    src/plugins/tables/kexitabledesignerview_p.cpp
M  +1    -1    src/plugins/tables/kexitabledesignerview_p.h
M  +1    -1    src/plugins/tables/kexitablepart.cpp

http://commits.kde.org/kexi/2a916fd80a52510eefd838065ed1cb4d33be89eb

diff --git a/src/plugins/tables/kexitabledesignerview.cpp \
b/src/plugins/tables/kexitabledesignerview.cpp index 7670fcc..d907d93 100644
--- a/src/plugins/tables/kexitabledesignerview.cpp
+++ b/src/plugins/tables/kexitabledesignerview.cpp
@@ -576,12 +576,25 @@ tristate KexiTableDesignerView::beforeSwitchTo(Kexi::ViewMode \
mode, bool *dontSt  //   cancelled = (KMessageBox::No == \
KMessageBox::questionYesNo(this, xi18n("Saving changes for existing table design is \
not yet supported.\nDo you want to discard your changes now?")));  //   KDbConnection \
*conn = KexiMainWindowIface::global()->project()->dbConnection();  bool emptyTable;
+            bool isPhysicalAlteringNeeded = this->isPhysicalAlteringNeeded();
+            KLocalizedString message(
+                kxi18nc("@info", "<para>Saving changes for existing table design is \
now required.</para>%1") +                       \
.subs(d->messageForSavingChanges(&emptyTable, /*skip \
warning?*/!isPhysicalAlteringNeeded))); +            if (emptyTable) {
+                isPhysicalAlteringNeeded = false; // eventually, not needed because \
there's no data +            }
+            KGuiItem saveItem(KStandardGuiItem::save());
+            saveItem.setToolTip(QString());
+            KGuiItem discardItem(KStandardGuiItem::discard());
+            discardItem.setToolTip(QString());
+            if (isPhysicalAlteringNeeded) {
+                saveItem.setText(xi18nc("@action:button", "Save Design and Remove \
Table Data")); +                discardItem.setText(xi18nc("@action:button", "Discard \
Design")); +            }
             const KMessageBox::ButtonCode r = KMessageBox::warningYesNoCancel(this,
-                xi18n("Saving changes for existing table design is now required.")
-                + "\n"
-                + d->messageForSavingChanges(&emptyTable, /*skip \
warning?*/!isPhysicalAlteringNeeded()), +                message.toString(),
                 QString(),
-                KStandardGuiItem::save(), KStandardGuiItem::discard(), \
KStandardGuiItem::cancel(), +                saveItem, discardItem, \
KStandardGuiItem::cancel(),  QString(),
                 KMessageBox::Notify | KMessageBox::Dangerous);
             if (r == KMessageBox::Cancel)
@@ -1427,7 +1440,7 @@ tristate KexiTableDesignerView::storeData(bool dontAsk)
             // - inform about removing the current table and ask for confirmation
             if (!d->dontAskOnStoreData && !dontAsk) {
                 bool emptyTable;
-                const QString msg = d->messageForSavingChanges(&emptyTable);
+                const QString msg = \
d->messageForSavingChanges(&emptyTable).toString();  if (!emptyTable) {
                     if (KMessageBox::No == KMessageBox::questionYesNo(this, msg))
                         res = cancelled;
diff --git a/src/plugins/tables/kexitabledesignerview_p.cpp \
b/src/plugins/tables/kexitabledesignerview_p.cpp index 0e0d945..5c650b9 100644
--- a/src/plugins/tables/kexitabledesignerview_p.cpp
+++ b/src/plugins/tables/kexitabledesignerview_p.cpp
@@ -222,15 +222,16 @@ bool \
KexiTableDesignerViewPrivate::updatePropertiesVisibility(KDbField::Type fie  return \
changed;  }
 
-QString KexiTableDesignerViewPrivate::messageForSavingChanges(bool *emptyTable, bool \
skipWarning) +KLocalizedString \
KexiTableDesignerViewPrivate::messageForSavingChanges(bool *emptyTable, bool \
skipWarning)  {
     Q_ASSERT(emptyTable);
     KDbConnection *conn = KexiMainWindowIface::global()->project()->dbConnection();
     *emptyTable = true == conn->isEmpty(designerView->tempData()->table);
-    return xi18n("Do you want to save the design now?")
-           + ((*emptyTable || skipWarning) ? QString() :
-              (QString("\n\n") + designerView->part()->i18nMessage(":additional \
                message before saving design",
-                      designerView->window()).toString()));
+    return kxi18nc("@info", "<para>Do you want to save the design now?</para>%1")
+           .subs((*emptyTable || skipWarning)
+                  ? KLocalizedString()
+                  : (designerView->part()->i18nMessage(":additional message before \
saving design", +                                                       \
designerView->window())));  }
 
 void KexiTableDesignerViewPrivate::updateIconForRecord(KDbRecordData *data, \
                KPropertySet *set)
diff --git a/src/plugins/tables/kexitabledesignerview_p.h \
b/src/plugins/tables/kexitabledesignerview_p.h index 7c3ae1a..7ac362d 100644
--- a/src/plugins/tables/kexitabledesignerview_p.h
+++ b/src/plugins/tables/kexitabledesignerview_p.h
@@ -91,7 +91,7 @@ public:
      \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);
+    KLocalizedString 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,
diff --git a/src/plugins/tables/kexitablepart.cpp \
b/src/plugins/tables/kexitablepart.cpp index ea697d6..4fabd92 100644
--- a/src/plugins/tables/kexitablepart.cpp
+++ b/src/plugins/tables/kexitablepart.cpp
@@ -211,7 +211,7 @@ KLocalizedString KexiTablePart::i18nMessage(
 
     if (window->currentViewMode() == Kexi::DesignViewMode && !window->neverSaved()
             && englishMessage == ":additional message before saving design")
-        return kxi18nc(I18NC_NOOP("@info", "Warning! Any data in this table will be \
removed upon design's saving!")); +        return kxi18nc(I18NC_NOOP("@info", \
"<warning>Any data in this table will be removed upon design's saving!</warning>"));  \
  return Part::i18nMessage(englishMessage, window);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic