[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8749 - trunk/gnue-forms/src/uidrivers/qt3/widgets
From: |
johannes |
Subject: |
[gnue] r8749 - trunk/gnue-forms/src/uidrivers/qt3/widgets |
Date: |
Wed, 11 Oct 2006 04:09:49 -0500 (CDT) |
Author: johannes
Date: 2006-10-11 04:09:48 -0500 (Wed, 11 Oct 2006)
New Revision: 8749
Added:
trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
Log:
Added first replacement for old forms/*
Added: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-10 23:32:37 UTC
(rev 8748)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py 2006-10-11 09:09:48 UTC
(rev 8749)
@@ -0,0 +1,246 @@
+# GNU Enterprise Forms - QT3 driver - Form widget
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+"""
+Implementation of the UI layer for the <form> and <dialog> tag
+"""
+
+import qt
+
+from _base import UIHelper
+
+# =============================================================================
+# The form
+# =============================================================================
+
+class UIForm(UIHelper):
+ """
+ """
+
+ _TAB_STYLE = {'left': qt.QTabWidget.Top,
+ 'top' : qt.QTabWidget.Top,
+ 'right': qt.QTabWidget.Bottom,
+ 'bottom': qt.QTabWidget.Bottom}
+
+ _MBOX_KIND = {'Info' : {'style': qt.QMessageBox.information,
+ 'title': u_("Information")},
+ 'Warning' : {'style': qt.QMessageBox.warning,
+ 'title': u_("Warning")},
+ 'Question': {'style': qt.QMessageBox.question,
+ 'title': u_("Question")},
+ 'Error' : {'style': qt.QMessageBox.critical,
+ 'title': u_("Error")}}
+
+ # -------------------------------------------------------------------------
+ # Constructor
+ # -------------------------------------------------------------------------
+
+ def __init__(self, event):
+
+ UIHelper.__init__(self, event)
+
+ self.pages = []
+ self.main_window = None
+
+ self._form = None
+
+
+ # -------------------------------------------------------------------------
+ # Create a new window object
+ # -------------------------------------------------------------------------
+
+ def _create_widget(self, event, spacer):
+
+ if self._form.style != 'dialog':
+ self.main_window = self._uiDriver._parentContainer
+ if not self.main_window:
+ self.main_window = qt.QMainWindow()
+ else:
+ self.main_window = qt.QDialog()
+
+ self.main_window.setCaption(self._form.title)
+
+ self.main_widget = qt.QWidget(self.main_window)
+ self.main_window.setCentralWidget(self.main_widget)
+
+ base_sizer = qt.QVBoxLayout(self.main_widget)
+ base_sizer.setMargin(6)
+
+ if self._form.style != 'dialog':
+ pass
+
+ if self._form._layout.tabbed != 'none':
+ self._container = qt.QTabWidget(self.main_widget)
+ self._container.setTabPosition( \
+ self._TAB_STYLE[self._form._layout.tabbed])
+ base_sizer.addWidget(self._container)
+ else:
+ self._container = self.main_widget
+
+ return self.main_window
+
+ # -------------------------------------------------------------------------
+ # Show the form/dialog
+ # -------------------------------------------------------------------------
+
+ def show(self):
+ """
+ Show the form or dialog modeless
+ """
+
+ self.main_window.show()
+ self._uiDriver.hide_splash()
+
+
+ # -------------------------------------------------------------------------
+ # Show the form/dialog modal
+ # -------------------------------------------------------------------------
+
+ def show_modal(self):
+ """
+ Show the dialog modal. This seems only possible for QDialog instances.
+ """
+
+ self._uiDriver.hide_splash()
+ if isinstance(self.main_window, qt.QDialog):
+ self.main_window.setModal(True)
+ self.main_window.show()
+
+
+ # -------------------------------------------------------------------------
+ # Show a given page
+ # -------------------------------------------------------------------------
+
+ def show_page(self, page_index):
+ """
+ Show a given <page> in the current container
+
+ @param page_index: the zero-based index of the page to show
+ """
+
+ if isinstance(self._container, qt.QTabWidget):
+ self._container.setCurrentPage(page_index)
+ else:
+ self.main_window.setUpdatesEnabled(False)
+ try:
+ for (index, page) in enumerate(self.pages):
+ if index == page_index:
+ page.show()
+ else:
+ page.hide()
+ finally:
+ self.main_window.setUpdatesEnabled(True)
+ self.main_window.repaint()
+
+ # -------------------------------------------------------------------------
+ # User feedback functions
+ # -------------------------------------------------------------------------
+
+ def _ui_begin_wait(self):
+ """
+ Display the hourglass cursor on all windows of the application.
+ """
+ self.main_window.setCursor(qt.Qt.WaitCursor)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_end_wait(self):
+ """
+ Display the normal mouse cursor on all windows of the application.
+ """
+ self.main_window.setCursor(qt.Qt.ArrowCursor)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_beep_(self):
+ """
+ Ring the system bell
+ """
+ # TODO: QApplication.beep()
+ pass
+
+ # -------------------------------------------------------------------------
+
+ def _ui_update_status_(self, tip, record_status, insert_status,
+ record_number, record_count, page_number, page_count):
+ """
+ Update the apropriate section of the status bar with the given
+ information.
+
+ @param tip: message to be shown in the first section
+ @param record_status: message for the second section
+ @param insert_status: message for the third section
+ @param record_number: number of the current record
+ @param record_count: number of available records. Together with
+ record_number this will be set into the 4th section
+ @param page_number: number of the current page
+ @param page_count: number of available pages. Together with the
+ page_number this will be set into the 5th section
+ """
+ # TODO: add status bar
+ pass
+
+ # -------------------------------------------------------------------------
+
+ def _ui_goto_page(self, page):
+ """
+ Change to container to show the requested page
+
+ @param page: UIPage instance to show
+ """
+
+ self.show_page(page.page_index)
+
+ # -------------------------------------------------------------------------
+
+ def _ui_show_message_(self, message, kind, title, cancel):
+ """
+ This function creates a message box of a given kind and returns True,
+ False or None depending on the button pressed.
+
+ @param message: the text of the messagebox
+ @param kind: type of the message box.
+ Valid types are 'Info', 'Warning', 'Question', 'Error'
+ @param title: title of the message box
+ @param cancel: If True a cancel button will be added to the dialog
+
+ @return: True if the Ok-, Close-, or Yes-button was pressed, False if
+ the No-button was pressed or None if the Cancel-button was pressed.
+ """
+
+ boxClass = _MBOX_KIND[kind]['style']
+
+ if title is None:
+ title = _MBOX_KIND[kind]['title']
+
+ result = boxClass(None, title, message)
+
+
+# =============================================================================
+# Configuration
+# =============================================================================
+
+configuration = {
+ 'baseClass': UIForm,
+ 'provides': 'GFForm',
+ 'container': 1
+}
Property changes on: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py 2006-10-10 23:32:37 UTC
(rev 8748)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/page.py 2006-10-11 09:09:48 UTC
(rev 8749)
@@ -1,6 +1,9 @@
+# GNU Enterprise Forms - QT3 driver - Page widget
#
-# This file is part of GNU Enterprise.
+# Copyright 2001-2006 Free Software Foundation
#
+# This file is part of GNU Enterprise
+#
# GNU Enterprise is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
@@ -16,49 +19,66 @@
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
-# Copyright 2000-2006 Free Software Foundation
-#
-# FILE:
-# UIqt.py
-#
-# DESCRIPTION:
-# A QT-based user interface driver for GNUe forms.
-#
-# NOTES:
-#
-from qt import *
+# $Id: $
+import qt
-## from gnue.forms.GFForm import *
-## from gnue.forms.uidrivers._base.UIdriver import *
+from _base import UIHelper
-## from gnue.forms.uidrivers.qt.GFwxApp import *
-## from gnue.forms.uidrivers.qt.common import *
-from gnue.forms.uidrivers.qt3.common import _setDefaultEventHandlers
+# =============================================================================
+# UIPage implements a <page> tag
+# =============================================================================
-## #from gnue.forms.uidrivers.qt.UIWXSplashScreen import *
-from gnue.forms.uidrivers.qt3.widgets._base import UIHelper
-#from gnue.common import *
+class UIPage(UIHelper):
+ """
+ Implmenetation of the page tag
-#
-# UIPage
-#
-# Widget set specific function that creates a single instance of a page
-#
-# Note: The event trap for changing notebook pages is attached to the UIForm
-#
-class UIPage(UIHelper):
- def _create_widget(self, event, spacer):
+ @ivar page_index: zero-based index of the page within the form's
+ page-container (which is either a notebook or a panel).
+ """
+
+ page_index = 0
+
+ # -------------------------------------------------------------------------
+ # Create a new page widget
+ # -------------------------------------------------------------------------
+
+ def _create_widget(self, event, spacer):
+ """
+ Create the page widget and add it to the page-container. The spacer is
+ ignored for page tags.
+
+ @returns: the QWidget instance which is the parent for all child
+ widgets of this page. It has already a QLayout descendant set.
+ """
+
+ self.page_index = len(self._uiForm.pages)
+
+ parent = event.container
+
+ self._container = qt.QWidget(parent)
+ if self.managed:
+ page_sizer = qt.QVBoxLayout(self._container)
+ else:
+ page_sizer = qt.QGridLayout(self._container)
+
+ if isinstance(parent, qt.QTabWidget):
+ title = "%s" % (self._gfObject.caption or self._gfObject.name)
+ parent.addPage(self._container, title)
+ else:
+ parent.layout().addWidget(self._container)
+
+ self._uiForm.pages.append(self._container)
+
+ return self._container
+
- object = event.object
+# =============================================================================
+# Configuration
+# =============================================================================
- newWidget = self._uiForm._wrapper.createPage(object)
- _setDefaultEventHandlers(newWidget, event.eventHandler, event.initialize,
self._uiDriver)
- self._container = newWidget
- return newWidget
-
configuration = {
- 'baseClass' : UIPage,
- 'provides' : 'GFPage',
- 'container' : 1,
- }
+ 'baseClass': UIPage,
+ 'provides' : 'GFPage',
+ 'container': 1
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8749 - trunk/gnue-forms/src/uidrivers/qt3/widgets,
johannes <=