[kde-doc-english] [calligra/kexi-wip-tanis] kexi: Show message when no database server drivers are found, when trying to

Dimitrios T. Tanis dimitrios.tanis at kdemail.net
Sun Oct 28 23:41:43 UTC 2012


Git commit ce715f9e501ab01984e08e39192176d188b74036 by Dimitrios T. Tanis.
Committed on 29/10/2012 at 00:31.
Pushed by tanis into branch 'kexi-wip-tanis'.

Show message when no database server drivers are found, when trying to
create/open/import project.

When trying to create/open/import a project that requires a database
server driver, if none is found display a message informing about it and
giving general instructions what to do.

GUI: New warning messages added.

M  +36   -15   kexi/main/startup/KexiNewProjectAssistant.cpp
M  +2    -0    kexi/main/startup/KexiNewProjectAssistant.h
M  +53   -21   kexi/main/startup/KexiOpenProjectAssistant.cpp
M  +2    -0    kexi/main/startup/KexiOpenProjectAssistant.h
M  +37   -19   kexi/widget/KexiConnectionSelectorWidget.cpp
M  +2    -0    kexi/widget/KexiConnectionSelectorWidget.h

http://commits.kde.org/calligra/ce715f9e501ab01984e08e39192176d188b74036

diff --git a/kexi/main/startup/KexiNewProjectAssistant.cpp b/kexi/main/startup/KexiNewProjectAssistant.cpp
index 75efbc1..fc7d8d6 100644
--- a/kexi/main/startup/KexiNewProjectAssistant.cpp
+++ b/kexi/main/startup/KexiNewProjectAssistant.cpp
@@ -321,21 +321,42 @@ KexiProjectConnectionSelectionPage::KexiProjectConnectionSelectionPage(QWidget*
 {
     setBackButtonVisible(true);
     setNextButtonVisible(true);
-
-    QVBoxLayout *lyr = new QVBoxLayout;
-    connSelector = new KexiConnectionSelectorWidget(
-        Kexi::connset(),
-        "kfiledialog:///OpenExistingOrCreateNewProject",
-        KAbstractFileWidget::Saving);
-    lyr->addWidget(connSelector);
-    connSelector->showAdvancedConn();
-    connect(connSelector, SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)),
-            this, SLOT(next()));
-    connSelector->layout()->setContentsMargins(0, 0, 0, 0);
-    connSelector->hideHelpers();
-    connSelector->hideDescription();
-    setContents(lyr);
-    setFocusWidget(connSelector->connectionsList());
+	if (!((Kexi::driverManager().driverNames().length() > 1) && Kexi::driverManager().driverNames().contains("sqlite3"))) {
+		setDescription(QString());
+		setNextButtonVisible(false);
+
+		KexiContextMessage msg(
+				i18nc("Warning", "No database server drivers found.\n"
+				"In order to connect to a database server please check that you have at least one database driver installed.\n"
+				"\n"
+				"Search and install packages named like \"calligra-kexi-xxxx-driver\".\n"
+				"Please note that your package names could vary slightly according to the distribution you use."
+				));
+		m_errorMessagePopup = new KexiContextMessageWidget(this, 0, 0, msg);
+		m_errorMessagePopup->setMessageType(KMessageWidget::Warning);
+		m_errorMessagePopup->setCalloutPointerDirection(KMessageWidget::NoPointer);
+		m_errorMessagePopup->setWordWrap(true);
+		m_errorMessagePopup->setClickClosesMessage(false);
+	// 			m_errorMessagePopup->resizeToContents();
+		m_errorMessagePopup->KexiContextMessageWidget::setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+		setContents(m_errorMessagePopup);
+		m_errorMessagePopup->animatedShow();
+	} else {
+		QVBoxLayout *lyr = new QVBoxLayout;
+		connSelector = new KexiConnectionSelectorWidget(
+			Kexi::connset(),
+			"kfiledialog:///OpenExistingOrCreateNewProject",
+			KAbstractFileWidget::Saving);
+		lyr->addWidget(connSelector);
+		connSelector->showAdvancedConn();
+		connect(connSelector, SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)),
+				this, SLOT(next()));
+		connSelector->layout()->setContentsMargins(0, 0, 0, 0);
+		connSelector->hideHelpers();
+		connSelector->hideDescription();
+		setContents(lyr);
+		setFocusWidget(connSelector->connectionsList());
+	}
 }
 
 KexiProjectConnectionSelectionPage::~KexiProjectConnectionSelectionPage()
diff --git a/kexi/main/startup/KexiNewProjectAssistant.h b/kexi/main/startup/KexiNewProjectAssistant.h
index af89ef2..d2de00e 100644
--- a/kexi/main/startup/KexiNewProjectAssistant.h
+++ b/kexi/main/startup/KexiNewProjectAssistant.h
@@ -108,6 +108,8 @@ public:
     virtual ~KexiProjectConnectionSelectionPage();
 
     KexiConnectionSelectorWidget* connSelector;
+private:
+	QPointer<KexiContextMessageWidget> m_errorMessagePopup;
 };
 
 class KexiServerDBNamePage;
diff --git a/kexi/main/startup/KexiOpenProjectAssistant.cpp b/kexi/main/startup/KexiOpenProjectAssistant.cpp
index 6af1e01..55ee41a 100644
--- a/kexi/main/startup/KexiOpenProjectAssistant.cpp
+++ b/kexi/main/startup/KexiOpenProjectAssistant.cpp
@@ -70,6 +70,7 @@ KexiMainOpenProjectPage::KexiMainOpenProjectPage(QWidget* parent)
     setFocusWidget(tabWidget);
     setContents(tabWidget);
     
+    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
     // delayed opening:
     QTimer::singleShot(500, this, SLOT(init()));
 }
@@ -82,27 +83,58 @@ void KexiMainOpenProjectPage::init()
     fileSelectorLayout->addWidget(fileSelector);
     fileSelector->show();
                       
-    // server-based:
-    QVBoxLayout* connSelectorLayout = new QVBoxLayout(m_connSelectorWidget);
-    connSelectorLayout->setContentsMargins(0, KDialog::marginHint() * 2, 0, 0);
-    QLabel* connSelectorLabel = new QLabel(
-        i18n("Select database server's connection with project you wish to open. "
-            "<p>Here you may also add, edit or remove connections "
-            "from the list."));
-    connSelectorLayout->addWidget(connSelectorLabel);
-    connSelectorLayout->addSpacing(KDialog::marginHint());
-    connSelector = new KexiConnectionSelectorWidget(
-        Kexi::connset(),
-        "kfiledialog:///OpenExistingOrCreateNewProject",
-        KAbstractFileWidget::Opening);
-    connSelectorLayout->addWidget(connSelector);
-    
-    connSelector->showAdvancedConn();
-    connSelector->layout()->setContentsMargins(0, 0, 0, 0);
-    connSelector->hideHelpers();
-    connSelector->hideDescription();
-    connect(connSelector, SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)),
-            this, SLOT(next()));
+}
+
+void KexiMainOpenProjectPage::tabChanged(int index)
+{
+	if (index == 1){
+        if (!((Kexi::driverManager().driverNames().length() > 1) && Kexi::driverManager().driverNames().contains("sqlite3"))) {
+			setNextButtonVisible(false);
+			setDescription(QString());
+
+			KexiContextMessage msg(
+					i18nc("Warning", "No database server drivers found.\n"
+					"In order to connect to a database server please check that you have at least one database driver installed.\n"
+					"\n"
+					"Search and install packages named like \"calligra-kexi-xxxx-driver\".\n"
+					"Please note that your package names could vary slightly according to the distribution you use."
+					));
+			m_errorMessagePopup = new KexiContextMessageWidget(m_connSelectorWidget, 0, 0, msg);
+			m_errorMessagePopup->setMessageType(KMessageWidget::Warning);
+			m_errorMessagePopup->setCalloutPointerDirection(KMessageWidget::NoPointer);
+			m_errorMessagePopup->setWordWrap(true);
+			m_errorMessagePopup->setClickClosesMessage(false);
+			m_errorMessagePopup->KexiContextMessageWidget::setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+			setContents(m_errorMessagePopup);
+			m_errorMessagePopup->animatedShow();
+		} else {
+			// server-based:
+			QVBoxLayout* connSelectorLayout = new QVBoxLayout(m_connSelectorWidget);
+			connSelectorLayout->setContentsMargins(0, KDialog::marginHint() * 2, 0, 0);
+			QLabel* connSelectorLabel = new QLabel(
+				i18n("Select database server's connection with project you wish to open. "
+					"<p>Here you may also add, edit or remove connections "
+					"from the list."));
+			connSelectorLayout->addWidget(connSelectorLabel);
+			connSelectorLayout->addSpacing(KDialog::marginHint());
+			connSelector = new KexiConnectionSelectorWidget(
+				Kexi::connset(),
+				"kfiledialog:///OpenExistingOrCreateNewProject",
+				KAbstractFileWidget::Opening);
+			connSelectorLayout->addWidget(connSelector);
+			
+			connSelector->showAdvancedConn();
+			connSelector->layout()->setContentsMargins(0, 0, 0, 0);
+			connSelector->hideHelpers();
+			connSelector->hideDescription();
+			connect(connSelector, SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)),
+					this, SLOT(next()));
+		}
+	} else {
+		if (m_errorMessagePopup) {
+			m_errorMessagePopup->close();
+		}
+	}
 }
 
 KexiMainOpenProjectPage::~KexiMainOpenProjectPage()
diff --git a/kexi/main/startup/KexiOpenProjectAssistant.h b/kexi/main/startup/KexiOpenProjectAssistant.h
index 595b0bb..99fdb73 100644
--- a/kexi/main/startup/KexiOpenProjectAssistant.h
+++ b/kexi/main/startup/KexiOpenProjectAssistant.h
@@ -48,9 +48,11 @@ public:
     KexiConnectionSelectorWidget* connSelector;
 private slots:
     void init();
+	void tabChanged(int index);
 private:
     QWidget* m_fileSelectorWidget;
     QWidget* m_connSelectorWidget;
+	QPointer<KexiContextMessageWidget> m_errorMessagePopup;
 };
 
 //! A page for selecting existing server database project
diff --git a/kexi/widget/KexiConnectionSelectorWidget.cpp b/kexi/widget/KexiConnectionSelectorWidget.cpp
index fd5c414..b91c24f 100644
--- a/kexi/widget/KexiConnectionSelectorWidget.cpp
+++ b/kexi/widget/KexiConnectionSelectorWidget.cpp
@@ -204,25 +204,43 @@ void KexiConnectionSelectorWidget::slotPrjTypeSelected(int id)
     if (id == 1) {//file-based prj type
         showSimpleConn();
     } else if (id == 2) {//server-based prj type
-        if (!d->conn_sel_shown) {
-            d->conn_sel_shown = true;
-
-            //show connections (on demand):
-            foreach(KexiDB::ConnectionData* connData, d->conn_set->list()) {
-                addConnectionData(connData);
-                //   else {
-                //this error should be more verbose:
-                //    kWarning() << "no driver found for '" << it.current()->driverName << "'!";
-                //   }
-            }
-            if (d->remote->list->topLevelItemCount() > 0) {
-                d->remote->list->topLevelItem(0)->setSelected(true);
-            }
-            d->remote->descGroupBox->layout()->setMargin(2);
-            d->remote->list->setFocus();
-            slotConnectionSelectionChanged();
-        }
-        d->stack->setCurrentWidget(d->remote);
+        if (!((Kexi::driverManager().driverNames().length() > 1) && Kexi::driverManager().driverNames().contains("sqlite3"))) {
+			KexiContextMessage msg(
+					i18nc("Warning", "No database server drivers found.\n"
+					"In order to connect to a database server please check that you have at least one database driver installed.\n"
+					"\n"
+					"Search and install packages named like \"calligra-kexi-xxxx-driver\".\n"
+					"Please note that your package names could vary slightly according to the distribution you use."
+					));
+			m_errorMessagePopup = new KexiContextMessageWidget(d->stack, 0, 0, msg);
+			m_errorMessagePopup->setMessageType(KMessageWidget::Warning);
+			m_errorMessagePopup->setCalloutPointerDirection(KMessageWidget::NoPointer);
+			m_errorMessagePopup->setWordWrap(true);
+			m_errorMessagePopup->setClickClosesMessage(false);
+			m_errorMessagePopup->KexiContextMessageWidget::setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+			d->stack->addWidget(m_errorMessagePopup);
+			d->stack->setCurrentWidget(m_errorMessagePopup);
+			m_errorMessagePopup->animatedShow();
+		} else {
+			if (!d->conn_sel_shown) {
+				d->conn_sel_shown = true;
+				//show connections (on demand):
+				foreach(KexiDB::ConnectionData* connData, d->conn_set->list()) {
+					addConnectionData(connData);
+					//   else {
+					//this error should be more verbose:
+					//    kWarning() << "no driver found for '" << it.current()->driverName << "'!";
+					//   }
+				}
+				if (d->remote->list->topLevelItemCount() > 0) {
+					d->remote->list->topLevelItem(0)->setSelected(true);
+				}
+				d->remote->descGroupBox->layout()->setMargin(2);
+				d->remote->list->setFocus();
+				slotConnectionSelectionChanged();
+			}
+			d->stack->setCurrentWidget(d->remote);
+		}
     }
 }
 
diff --git a/kexi/widget/KexiConnectionSelectorWidget.h b/kexi/widget/KexiConnectionSelectorWidget.h
index 43bd7cc..ed65628 100644
--- a/kexi/widget/KexiConnectionSelectorWidget.h
+++ b/kexi/widget/KexiConnectionSelectorWidget.h
@@ -22,6 +22,7 @@
 
 #include <kexidbconnectionset.h>
 #include <db/driver.h>
+#include <kexiutils/KexiContextMessage.h>
 
 #include <KDialog>
 #include <kabstractfilewidget.h>
@@ -144,6 +145,7 @@ protected slots:
 private:
     ConnectionDataLVItem* addConnectionData(KexiDB::ConnectionData* data);
     ConnectionDataLVItem* selectedConnectionDataItem() const;
+    QPointer<KexiContextMessageWidget> m_errorMessagePopup;
     
     class Private;
     Private * const d;



More information about the kde-doc-english mailing list