[kde-doc-english] [calligra] kexi/main: GUI: Main Window: Added "Import, Export or Send" menu item and assistant

Jaroslaw Staniek staniek at kde.org
Fri Sep 30 00:00:31 UTC 2011


Git commit f667ec9f54fb3336137dc36ffc63775773c3faf7 by Jaroslaw Staniek.
Committed on 30/09/2011 at 01:22.
Pushed by staniek into branch 'master'.

GUI: Main Window: Added "Import, Export or Send" menu item and assistant

*Rearranged Kexi menu items for usability
*Settings menu item disabled for now

DIGEST: Added "Import, Export or Send" menu item and assistant for Kexi

M  +2    -50   kexi/main/CMakeLists.txt
M  +22   -17   kexi/main/KexiMainWindow.cpp
M  +1    -1    kexi/main/KexiMainWindow.h
M  +6    -6    kexi/main/KexiMainWindow_p.h
A  +119  -0    kexi/main/startup/KexiImportExportAssistant.cpp     [License: LGPL (v2+)]
A  +68   -0    kexi/main/startup/KexiImportExportAssistant.h     [License: LGPL (v2+)]
A  +61   -0    kexi/main/startup/KexiMainImportExportPage.ui

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

diff --git a/kexi/main/CMakeLists.txt b/kexi/main/CMakeLists.txt
index 313f2c0..8154f5d 100644
--- a/kexi/main/CMakeLists.txt
+++ b/kexi/main/CMakeLists.txt
@@ -11,8 +11,6 @@ ADD_DEFINITIONS(
 
 ########### next target ###############
 
-#find_package(QImageBlitz REQUIRED)
-
 set(keximain_LIB_SRCS 
 KexiMainWindow.cpp 
 KexiMenuWidget.cpp
@@ -26,6 +24,7 @@ startup/KexiConnSelector.cpp
 startup/KexiNewProjectAssistant.cpp
 startup/KexiOpenProjectAssistant.cpp
 startup/KexiRecentProjectsAssistant.cpp
+startup/KexiImportExportAssistant.cpp
 startup/KexiProjectSelector.cpp
 startup/KexiStartupFileWidget.cpp
 startup/KexiStartupFileHandler.cpp
@@ -51,6 +50,7 @@ kde4_add_ui_files(keximain_LIB_SRCS
   startup/KexiOpenExistingFile.ui
   startup/KexiProjectSelector.ui
   startup/KexiServerDBNamePage.ui
+  startup/KexiMainImportExportPage.ui
 )
 
 kde4_add_library(keximain SHARED ${keximain_LIB_SRCS})
@@ -68,55 +68,7 @@ target_link_libraries(
     ${KDE4_KFILE_LIBS}
     ${KDE4_KDE3SUPPORT_LIBS}
     ${QT_QT3SUPPORT_LIBRARY}
-#    ${QIMAGEBLITZ_LIBRARIES}
 )
 
 set_target_properties(keximain PROPERTIES VERSION ${GENERIC_CALLIGRA_LIB_VERSION} SOVERSION ${GENERIC_CALLIGRA_LIB_SOVERSION} )
 install(TARGETS keximain  ${INSTALL_TARGETS_DEFAULT_ARGS})
-
-
-########### install files ###############
-
-
-
-
-
-
-#original Makefile.am contents follow:
-
-#include $(top_srcdir)/kexi/Makefile.global
-#
-#lib_LTLIBRARIES = libkeximain.la
-#libkeximain_la_SOURCES = \
-#	keximainwindowimpl.cpp \
-#	kexibrowser.cpp kexibrowseritem.cpp \
-#	kexistatusbar.cpp \
-#	kexinamewidget.cpp kexinamedialog.cpp \
-#	kexinewstuff.cpp
-#
-#libkeximain_la_LDFLAGS = -no-undefined $(KDE_RPATH) $(all_libraries) \
-#	$(VER_INFO) -Wnounresolved
-#
-#SUBDIRS = startup printing .
-#
-#libkeximain_la_LIBADD =  $(top_builddir)/kexi/kexidb/libkexidb.la $(top_builddir)/kexi/core/libkexicore.la \
-#	$(top_builddir)/kexi/kexiutils/libkexiutils.la \
-#	$(top_builddir)/kexi/main/startup/libkeximainstartup.la \
-#	$(top_builddir)/kexi/main/printing/libkeximainprinting.la \
-#	$(top_builddir)/lib/koproperty/libkoproperty.la \
-#	$(top_builddir)/kexi/widget/libkexiextendedwidgets.la \
-#	$(LIB_KFEEDBACK) $(LIB_KEXI_KMDI) $(LIB_KNEWSTUFF) $(LIB_KIO) $(LIB_KDEPRINT)
-#
-##disabled	../migration/libkeximigrate.la
-#
-#INCLUDES = $(INC_KFEEDBACK) $(LIB_KEXI_KMDI_INCLUDES) \
-#	-I$(top_builddir)/lib/ -I$(top_srcdir)/lib/ \
-#	-I$(top_srcdir)/kexi -I$(top_srcdir)/kexi/core \
-#	-I$(top_srcdir)/kexi/main \
-#	-I$(top_srcdir)/kexi/main/startup -I$(top_srcdir)/kexi/widget \
-#	-I$(top_srcdir)/kexi/migration -I$(top_srcdir)/lib -I$(top_srcdir)/lib/komain \
-#	$(all_includes)
-#
-#noinst_HEADERS = ksplitter.h kexibrowser_p.h keximainwindowimpl_p.h
-#
-#METASOURCES = AUTO
diff --git a/kexi/main/KexiMainWindow.cpp b/kexi/main/KexiMainWindow.cpp
index 19cadc3..cd1eb06 100644
--- a/kexi/main/KexiMainWindow.cpp
+++ b/kexi/main/KexiMainWindow.cpp
@@ -110,6 +110,7 @@
 #include "startup/KexiNewProjectAssistant.h"
 #include "startup/KexiOpenProjectAssistant.h"
 #include "startup/KexiRecentProjectsAssistant.h"
+#include "startup/KexiImportExportAssistant.h"
 #include "startup/KexiStartupDialog.h"
 #include "startup/KexiStartupFileWidget.h"
 #include "kexinamedialog.h"
@@ -717,7 +718,6 @@ void KexiMainWindow::setupActions()
     d->action_project_properties = d->dummy_action;
 #endif
 
-#ifndef KEXI_NO_UNFINISHED
 #ifdef __GNUC__
 #warning replace document-import icon with something other
 #else
@@ -731,13 +731,10 @@ void KexiMainWindow::setupActions()
         i18n("Imports, exports or sends project."));
     connect(action, SIGNAL(triggered()), this, SLOT(slotProjectImportExportOrSend()));
     setupMainMenuActionShortcut(action, SLOT(slotProjectImportExportOrSend()));
-#else
-    d->action_project_import_export_send = d->dummy_action;
-#endif
 
     ac->addAction("project_close",
         action = d->action_close = new KexiMenuWidgetAction(
-            KIcon("window-close"), i18n("&Close Project"), this));
+            KIcon("window-close"), i18nc("Close Project", "&Close"), this));
     action->setToolTip(i18n("Close the current project"));
     action->setWhatsThis(i18n("Closes the current project."));
     connect(action, SIGNAL(triggered()), this, SLOT(slotProjectClose()));
@@ -763,13 +760,13 @@ void KexiMainWindow::setupActions()
     d->action_project_relations = d->dummy_action;
 #endif
     ac->addAction("tools_import_project",
-                  d->action_tools_data_migration = new KAction(
+                  d->action_tools_import_project = new KAction(
         KIcon("document_import_database"), i18n("&Import Database..."), this));
-    d->action_tools_data_migration->setToolTip(i18n("Import entire database as a Kexi project"));
-    d->action_tools_data_migration->setWhatsThis(
+    d->action_tools_import_project->setToolTip(i18n("Import entire database as a Kexi project"));
+    d->action_tools_import_project->setWhatsThis(
         i18n("Imports entire database as a Kexi project."));
-    connect(d->action_tools_data_migration, SIGNAL(triggered()),
-            this, SLOT(slotToolsProjectMigration()));
+    connect(d->action_tools_import_project, SIGNAL(triggered()),
+            this, SLOT(slotToolsImportProject()));
 
     d->action_tools_data_import = new KAction(KIcon("document-import"), i18n("Import Tables"), this);
     d->action_tools_data_import->setToolTip(i18n("Import data from an external source into this database"));
@@ -808,9 +805,9 @@ void KexiMainWindow::setupActions()
         i18nc("Export->Table or Query Data to File...", "Export Data to &File..."), this));
 //orig:        i18nc("Export->Table or Query Data to File...", "Table or Query Data to &File..."), this));
     d->action_project_export_data_table->setToolTip(
-        i18n("Export data from the active table or query data to a file"));
+        i18n("Export data from the active table or query to a file"));
     d->action_project_export_data_table->setWhatsThis(
-        i18n("Exports data from the active table or query data to a file."));
+        i18n("Exports data from the active table or query to a file."));
     connect(d->action_project_export_data_table, SIGNAL(triggered()),
             this, SLOT(slotProjectExportDataTable()));
 
@@ -1046,7 +1043,7 @@ void KexiMainWindow::setupActions()
     //d->action_data_execute->setToolTip(i18n("")); //TODO
     //d->action_data_execute->setWhatsThis(i18n("")); //TODO
 
-#ifndef KEXI_NO_UNFINISHED
+#ifndef KEXI_SHOW_UNIMPLEMENTED
     action = createSharedAction(i18n("&Filter"), "view-filter", KShortcut(), "data_filter");
     setActionVolatile(action, true);
 #endif
@@ -1177,6 +1174,7 @@ void KexiMainWindow::setupActions()
     Kexi::tempShowScripts() = false;
 #endif
 
+#ifdef KEXI_SHOW_UNIMPLEMENTED
 //! @todo 2.0 - implement settings window in a specific way
     ac->addAction("settings",
                   action = d->action_settings = new KexiMenuWidgetAction(
@@ -1187,6 +1185,9 @@ void KexiMainWindow::setupActions()
     action->setWhatsThis(i18n("Lets you to view and change Kexi settings."));
     connect(action, SIGNAL(triggered()), this, SLOT(slotSettings()));
     setupMainMenuActionShortcut(action, SLOT(slotSettings()));
+#else
+    d->action_settings = d->dummy_action;
+#endif
 
 #if 0//js: todo reenable later
     KStandardAction::tipOfDay(this, SLOT(slotTipOfTheDayAction()), actionCollection())
@@ -3464,9 +3465,11 @@ void KexiMainWindow::slotProjectImportExportOrSend()
     if (!d->tabbedToolBar)
         return;
     d->tabbedToolBar->showMainMenu("project_import_export_send");
-    // dummy
-    QLabel *dummy = KEXI_UNFINISHED_LABEL(actionCollection()->action("project_import_export_send")->text());
-    d->tabbedToolBar->setMainMenuContent(dummy);
+    KexiImportExportAssistant* assistant = new KexiImportExportAssistant(
+        d->action_project_import_export_send,
+        d->action_tools_import_project);
+    connect(assistant, SIGNAL(importProject()), this, SLOT(slotToolsImportProject()));
+    d->tabbedToolBar->setMainMenuContent(assistant);
 }
 
 void
@@ -4849,8 +4852,10 @@ KexiMainWindow::setupUserActions()
 #endif
 }
 
-void KexiMainWindow::slotToolsProjectMigration()
+void KexiMainWindow::slotToolsImportProject()
 {
+    if (d->tabbedToolBar)
+        d->tabbedToolBar->hideMainMenu();
     showProjectMigrationWizard(QString(), QString());
 }
 
diff --git a/kexi/main/KexiMainWindow.h b/kexi/main/KexiMainWindow.h
index f0b263d..0abb0f1 100644
--- a/kexi/main/KexiMainWindow.h
+++ b/kexi/main/KexiMainWindow.h
@@ -626,7 +626,7 @@ protected slots:
     void slotSettings();
     void slotConfigureKeys();
     void slotConfigureToolbars();
-    void slotToolsProjectMigration();
+    void slotToolsImportProject();
     void slotToolsImportTables();
     void slotToolsCompactDatabase();
 
diff --git a/kexi/main/KexiMainWindow_p.h b/kexi/main/KexiMainWindow_p.h
index dfbec68..5837303 100644
--- a/kexi/main/KexiMainWindow_p.h
+++ b/kexi/main/KexiMainWindow_p.h
@@ -407,22 +407,22 @@ protected:
             topmargin += m_topLineHeight;
             m_menuWidget->setContentsMargins(leftmargin, topmargin, rightmargin, bottommargin);
 
-            m_menuWidget->addAction(ac->action("project_new"));
+            m_menuWidget->addAction(ac->action("project_open_recent"));
             m_menuWidget->addAction(ac->action("project_open"));
             //menu->addAction(new KexiMenuWidgetAction(KStandardAction::New, this));
             //menu->addAction(new KexiMenuWidgetAction(KStandardAction::Open, this));
             //menu->setActiveAction(ac->action("project_open"));
-            m_menuWidget->addAction(ac->action("project_open_recent"));
-            m_menuWidget->addSeparator();
-            //menu->addAction(ac->action("project_save"));
-            //menu->addAction(ac->action("project_saveas"));
             m_menuWidget->addAction(ac->action("project_close"));
             m_menuWidget->addSeparator();
+            m_menuWidget->addAction(ac->action("project_new"));
             //menu->addAction(ac->action("tools_import_project"));
+            //menu->addAction(ac->action("project_save"));
+            //menu->addAction(ac->action("project_saveas"));
             m_menuWidget->addAction(ac->action("project_import_export_send"));
             m_menuWidget->addAction(ac->action("project_properties"));
             // todo: project information
             m_menuWidget->addAction(ac->action("settings"));
+            m_menuWidget->addSeparator();
             m_menuWidget->addAction(ac->action("quit"));
             //menu->setFixedWidth(300);
             hlyr->addWidget(m_menuWidget);
@@ -1977,7 +1977,7 @@ public:
     KAction *action_format_font;
 
     //! tools menu
-    KAction *action_tools_data_migration, *action_tools_compact_database, *action_tools_data_import;
+    KAction *action_tools_import_project, *action_tools_compact_database, *action_tools_data_import;
     KActionMenu *action_tools_scripts;
 
     //! window menu
diff --git a/kexi/main/startup/KexiImportExportAssistant.cpp b/kexi/main/startup/KexiImportExportAssistant.cpp
new file mode 100644
index 0000000..d3379ff
--- /dev/null
+++ b/kexi/main/startup/KexiImportExportAssistant.cpp
@@ -0,0 +1,119 @@
+/* This file is part of the KDE project
+   Copyright (C) 2011 Jarosław Staniek <staniek at kde.org>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "KexiImportExportAssistant.h"
+
+#include <KAction>
+#include <QPointer>
+
+static QString stripText(const QString &text)
+{
+    return QString(text).replace('&', "").replace("...", "");
+}
+
+KexiMainImportExportPage::KexiMainImportExportPage(
+    KexiImportExportAssistant *assistant,
+    QWidget* parent)
+ : KexiAssistantPage(stripText(assistant->action_project_import_export_send->text()),
+                     QString(),
+                     parent)
+{
+    setNextButtonVisible(false);
+
+    QWidget* contents = new QWidget;
+    setupUi(contents);
+    btn_import->setText(stripText(assistant->action_import_project->text()));
+    btn_import->setDescription(assistant->action_import_project->toolTip());
+    connect(btn_import, SIGNAL(clicked()), assistant, SIGNAL(importProject()));
+
+    setFocusWidget(contents);
+    setContents(contents);
+}
+
+KexiMainImportExportPage::~KexiMainImportExportPage()
+{
+}
+
+// ----
+
+class KexiImportExportAssistant::Private
+{
+public:
+    Private(KexiImportExportAssistant *qq)
+     : q(qq)
+    {
+    }
+    
+    ~Private()
+    {
+    }
+    
+    KexiMainImportExportPage* mainPage() {
+        return page<KexiMainImportExportPage>(&m_mainImportExportPage, q);
+    }
+    
+    template <class C>
+    C* page(QPointer<C>* p, KexiImportExportAssistant *parent = 0) {
+        if (p->isNull()) {
+            *p = new C(parent);
+            q->addPage(*p);
+        }
+        return *p;
+    }
+
+    QPointer<KexiMainImportExportPage> m_mainImportExportPage;
+    
+    KexiImportExportAssistant *q;
+};
+
+// ----
+
+KexiImportExportAssistant::KexiImportExportAssistant(
+    const KAction *action_project_import_export_send_,
+    const KAction *action_import_project_,
+    QWidget* parent)
+ : KexiAssistantWidget(parent)
+ , action_project_import_export_send(action_project_import_export_send_)
+ , action_import_project(action_import_project_)
+ , d(new Private(this))
+{
+    setCurrentPage(d->mainPage());
+    setFocusProxy(d->mainPage());
+}
+
+KexiImportExportAssistant::~KexiImportExportAssistant()
+{
+    delete d;
+}
+       
+void KexiImportExportAssistant::previousPageRequested(KexiAssistantPage* page)
+{
+    Q_UNUSED(page);
+}
+
+void KexiImportExportAssistant::nextPageRequested(KexiAssistantPage* page)
+{
+    Q_UNUSED(page);
+}
+
+void KexiImportExportAssistant::cancelRequested(KexiAssistantPage* page)
+{
+    Q_UNUSED(page);
+    //TODO?
+}
diff --git a/kexi/main/startup/KexiImportExportAssistant.h b/kexi/main/startup/KexiImportExportAssistant.h
new file mode 100644
index 0000000..b55d94b
--- /dev/null
+++ b/kexi/main/startup/KexiImportExportAssistant.h
@@ -0,0 +1,68 @@
+/* This file is part of the KDE project
+   Copyright (C) 2011 Jarosław Staniek <staniek at kde.org>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KEXIIMPORTEXPORTASSISTANT_H
+#define KEXIIMPORTEXPORTASSISTANT_H
+
+#include <kexiutils/KexiAssistantPage.h>
+#include <kexiutils/KexiAssistantWidget.h>
+
+#include "ui_KexiMainImportExportPage.h"
+
+class KAction;
+class KexiImportExportAssistant;
+
+class KexiMainImportExportPage : public KexiAssistantPage,
+                                 public Ui::KexiMainImportExportPage
+{
+    Q_OBJECT
+public:
+    KexiMainImportExportPage(KexiImportExportAssistant *assistant,
+                             QWidget* parent = 0);
+    ~KexiMainImportExportPage();
+};
+
+class KexiImportExportAssistant : public KexiAssistantWidget
+{
+    Q_OBJECT
+public:
+    KexiImportExportAssistant(
+        const KAction *action_project_import_export_send_,
+        const KAction *action_import_project_,
+        QWidget* parent = 0);
+    ~KexiImportExportAssistant();
+
+    const KAction *action_project_import_export_send;
+    const KAction *action_import_project;
+
+public slots:
+    virtual void previousPageRequested(KexiAssistantPage* page);
+    virtual void nextPageRequested(KexiAssistantPage* page);
+    virtual void cancelRequested(KexiAssistantPage* page);
+
+signals:
+    void importProject();
+
+private:
+
+    class Private;
+    Private* const d;
+};
+
+#endif
diff --git a/kexi/main/startup/KexiMainImportExportPage.ui b/kexi/main/startup/KexiMainImportExportPage.ui
new file mode 100644
index 0000000..c93531c
--- /dev/null
+++ b/kexi/main/startup/KexiMainImportExportPage.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>KexiMainImportExportPage</class>
+ <widget class="QWidget" name="KexiMainImportExportPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>512</width>
+    <height>194</height>
+   </rect>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <layout class="QGridLayout" name="_2" columnstretch="0">
+     <item row="0" column="0">
+      <widget class="KexiCommandLinkButton" name="btn_import"/>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="1">
+    <widget class="QWidget" name="widget" native="true">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>58</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KexiCommandLinkButton</class>
+   <extends>QCommandLinkButton</extends>
+   <header location="global">kexiutils/KexiCommandLinkButton.h</header>
+  </customwidget>
+ </customwidgets>
+ <includes>
+  <include location="local">k3listview.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>



More information about the kde-doc-english mailing list