Author: sh-sh-sh Date: Mon Nov 12 17:35:40 2007 New Revision: 41984 URL: http://svn.opensuse.org/viewcvs/yast?rev=41984&view=rev Log: ported YDownloadProgress Modified: branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.cc branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.h branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h branches/tmp/sh/mod-ui/core/libyui/src/YTypes.h branches/tmp/sh/mod-ui/core/libyui/src/YUI.h branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.cc branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.h branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.h branches/tmp/sh/mod-ui/qt/src/YQUI.h branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Modified: branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml (original) +++ branches/tmp/sh/mod-ui/core/libyui/doc/YCPDialogParser.xml Mon Nov 12 17:35:40 2007 @@ -296,6 +296,25 @@ <variablelist> <varlistentry> <term> + <type>list<integer></type> + <parameter>Values</parameter> + </term> + <listitem> + <para>The numerical value for each segment.</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>list<string></type> + <parameter>Labels</parameter> + </term> + <listitem> + <para>Text label for each segment ('\n' allowed). +Use %1 as a placeholder for the current value.</para> + </listitem> + </varlistentry> + <varlistentry> + <term> <type>integer-list</type> <parameter>Values</parameter> </term> @@ -728,6 +747,15 @@ </varlistentry> <varlistentry> <term> + <type>itemList</type> + <parameter>Items</parameter> + </term> + <listitem> + <para>All items</para> + </listitem> + </varlistentry> + <varlistentry> + <term> <type>string</type> <parameter>ValidChars</parameter> </term> @@ -744,6 +772,15 @@ <para>maximum number of input characters</para> </listitem> </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>IconPath</parameter> + </term> + <listitem> + <para>Base path for icons</para> + </listitem> + </varlistentry> </variablelist> </refsect1> <refsect1> @@ -797,13 +834,13 @@ </informalexample> </refsect1> </refentry> - <refentry id="Date_widget"> + <refentry id="DateField_widget"> <refmeta> - <refentrytitle>Date</refentrytitle> + <refentrytitle>DateField</refentrytitle> <manvolnum>3</manvolnum> </refmeta> <refnamediv> - <refname>Date</refname> + <refname>DateField</refname> <refpurpose>Date input field</refpurpose> </refnamediv> <refsynopsisdiv> @@ -811,12 +848,16 @@ <funcprototype> <funcdef> <type></type> - <function>Date</function> + <function>DateField</function> </funcdef> <paramdef> <type>string</type> <parameter>label</parameter> </paramdef> + <paramdef choice="opt"> + <type>string</type> + <parameter>initialDate</parameter> + </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> @@ -835,6 +876,20 @@ </variablelist> </refsect1> <refsect1> + <title>Optional Arguments</title> + <variablelist> + <varlistentry> + <term> + <type>string</type> + <parameter>initialDate</parameter> + </term> + <listitem> + <para></para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + <refsect1> <title>Properties</title> <variablelist> <varlistentry> @@ -843,7 +898,16 @@ <parameter>Value</parameter> </term> <listitem> - <para>the date </para> + <para>the date (the field's contents) as "YYYY-MM-DD"</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>Label</parameter> + </term> + <listitem> + <para>caption above the input field</para> </listitem> </varlistentry> </variablelist> @@ -851,13 +915,17 @@ <refsect1> <title>Description</title> <para> - <para> A Date input widget for entering dates. This widget is available in the Qt interface only</para> + <para> An input field for entering a date.</para> </para> + <note> + <para>This is a "special" widget, i.e. not all UIs necessarily support it. Check for availability with <replaceable>HasSpecialWidget( `TimeField)</replaceable> before using it.</para> + </note> </refsect1> <refsect1> <title>Usage</title> <programlisting> - `Date( "Date:", "2004-10-12" ) + if ( HasSpecialWidget( `DateField ) {... + `DateField( "Date:", "2004-10-12" ) </programlisting> </refsect1> </refentry> @@ -2132,7 +2200,25 @@ <parameter>Value</parameter> </term> <listitem> - <para>the numerical value</para> + <para>the field's contents (the user input)</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>MinValue</parameter> + </term> + <listitem> + <para>the minimum value</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>MaxValue</parameter> + </term> + <listitem> + <para>the maximum value</para> </listitem> </varlistentry> <varlistentry> @@ -2141,7 +2227,7 @@ <parameter>Label</parameter> </term> <listitem> - <para>the slider label</para> + <para>caption above the field</para> </listitem> </varlistentry> </variablelist> @@ -2603,8 +2689,7 @@ <parameter>Value</parameter> </term> <listitem> - <para>All log lines. Set this property to replace or clear the entire contents. -Can only be set, not queried.</para> + <para>All log lines.</para> </listitem> </varlistentry> <varlistentry> @@ -2613,8 +2698,25 @@ <parameter>LastLine</parameter> </term> <listitem> - <para>The last log line. Set this property to append one or more line(s) to the log. -Can only be set, not queried.</para> + <para>The last log line(s). Use this to append lines.</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>VisibleLines</parameter> + </term> + <listitem> + <para>Number of lines to display. Call RecalcLayout() afterwards.</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>MaxLines</parameter> + </term> + <listitem> + <para>Number of lines to store (0 for all).</para> </listitem> </varlistentry> <varlistentry> @@ -2623,7 +2725,7 @@ <parameter>Label</parameter> </term> <listitem> - <para>The label above the log text.</para> + <para>Caption above the log text</para> </listitem> </varlistentry> </variablelist> @@ -2818,7 +2920,25 @@ <parameter>Label</parameter> </term> <listitem> - <para>the text on the MenuButton</para> + <para>Label on the menu button</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>itemList</type> + <parameter>Items</parameter> + </term> + <listitem> + <para>All menu items and submenus</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>IconPath</parameter> + </term> + <listitem> + <para>Base path for icons (on menu items)</para> </listitem> </varlistentry> </variablelist> @@ -3564,11 +3684,11 @@ <variablelist> <varlistentry> <term> - <type>integer</type> + <type>string</type> <parameter>Value</parameter> </term> <listitem> - <para>the numerical value</para> + <para>the value (the size of the new partition)</para> </listitem> </varlistentry> </variablelist> @@ -4482,7 +4602,16 @@ <parameter>Label</parameter> </term> <listitem> - <para>caption above the selection box</para> + <para>Caption above the selection box</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>IconPath</parameter> + </term> + <listitem> + <para>Base path for icons</para> </listitem> </varlistentry> </variablelist> @@ -4676,7 +4805,25 @@ <parameter>Value</parameter> </term> <listitem> - <para>the numerical value</para> + <para>the slider value</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>MinValue</parameter> + </term> + <listitem> + <para>the minimum value</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>integer</type> + <parameter>MaxValue</parameter> + </term> + <listitem> + <para>the maximum value</para> </listitem> </varlistentry> <varlistentry> @@ -4685,7 +4832,7 @@ <parameter>Label</parameter> </term> <listitem> - <para>the slider label</para> + <para>caption above the slider</para> </listitem> </varlistentry> </variablelist> @@ -4816,39 +4963,83 @@ <variablelist> <varlistentry> <term> - <type>integer</type> + <type>itemID</type> + <parameter>Value</parameter> + </term> + <listitem> + <para>The currently selected item</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>itemID</type> <parameter>CurrentItem</parameter> </term> <listitem> - <para>the ID of the currently selected item -Alias: Value</para> + <para>The currently selected item</para> </listitem> </varlistentry> <varlistentry> <term> - <type>list(item)</type> + <type>itemList</type> <parameter>Items</parameter> </term> <listitem> - <para>a list of all table items</para> + <para>All items</para> </listitem> </varlistentry> <varlistentry> <term> - <type>item</type> - <parameter>Item(id)</parameter> + <type>string</type> + <parameter>Cell</parameter> </term> <listitem> - <para>read: a single item (string or term)</para> + <para>One cell (one column of one item)</para> </listitem> </varlistentry> <varlistentry> <term> - <type>integer|string</type> - <parameter>Item(id,column)</parameter> + <type>integer</type> + <parameter>Cell</parameter> + </term> + <listitem> + <para>(ChangeWidget only) One cell as integer</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>`icon(...)</type> + <parameter>Cell</parameter> </term> <listitem> - <para>write: replacement for one specific cell ( see example )</para> + <para>Icon for one one cell</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>Item</parameter> + </term> + <listitem> + <para>Alias for Cell</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>Item</parameter> + </term> + <listitem> + <para>QueryWidget only: Return one complete item</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>IconPath</parameter> + </term> + <listitem> + <para>Base path for icons</para> </listitem> </varlistentry> </variablelist> @@ -4856,10 +5047,46 @@ <refsect1> <title>Description</title> <para> - <para> A Table widget is a generalization of the SelectionBox. Information is displayed in a number of columns. Each column has a header. The number of columns and their titles are described by the first argument, which is a term with the symbol <replaceable>header</replaceable>. For each column you add a string specifying its title. For example <replaceable>`header( "Name", "Price" )</replaceable> creates the two columns "Name" and "Price".</para> + <para> The Table widget is a selection list with multiple columns. The user can select exactly one row (with all its columns) from that list.</para> + </para> + <para> + <para> Each cell (each column within each row) has a label text and an optional icon.</para> + </para> + <para> + <para> (Note: Not all UIs (in particular not text-based UIs) support displaying icons, so an icon should never be an exclusive means to display any kind of information).</para> + </para> + <para> + <para> This widget is similar to SelectionBox, but it has several columns for each item (each row). If just one column is desired, consider using SelectionBox instead.</para> + </para> + <para> + <para> Note: This is not something like a spread sheet, and it doesn't pretend or want to be. Actions are performed on rows, not on individual cells (columns within one row).</para> + </para> + <para> + <para> The first argument (after `opt() and `id() which both are optional) is `header() which specifies the column headers (and implicitly the number of columns) and optionally the alignment for each column. Default alignment is left.</para> + </para> + <para> + <para> In the list of items, an ID is specified for each item. Each item can have less cells (columns) than the table has columns (from `header()), in which case any missing cells are assumed to be empty. If an item has more cells than the table has columns, any extra cells are ignored.</para> + </para> + <para> + <para> Each cell has a text label (which might also be an empty string) and optionally an icon. If a cell has an icon, it has to be specified with `cell(`icon("myiconname.png", "Label text")).</para> + </para> + <para> + <para> A simple table is specified like this:</para> + </para> + <para> + <para> `Table(`id(`players), `header("Nick", "Age", "Role"), [ `item(`id("Bluebird"), "Bluebird, 18, "Scout" ), `item(`id("Ozzz" ), "Ozzz", 23, "Wizard" ), `item(`id("Wannabe" ), "Wannabe", 17 ), `item(`id("Coxxan" ), "Coxxan", 26, "Warrior") ] )</para> + </para> + <para> + <para> This will create a 3-column table. The first column ("Nick") and the third column ("Role") will be left aligned. The second column ("Age") will be right aligned. note that "Wannabe" doesn't have a Role. This field will be empty.</para> + </para> + <para> + <para> A table that uses icons is specified like this:</para> + </para> + <para> + <para> `Table(`id(`players), `header("Nick", "Age", "Role"), [ `item(`id("Bluebird"), "Bluebird, 18, `cell(`icon("scout.png"), "Scout" ) ), `item(`id("Ozzz" ), "Ozzz", 23, "Wizard" ), `item(`id("Wannabe" ), "Wannabe", `cell(`icon("underage.png", 17 ) ), `item(`id("Coxxan" ), "Coxxan", `cell(`icon("oldman.png", 26 ), "Warrior" ) ] )</para> </para> <para> - <para> The second argument is an optional list of items (rows) that are inserted in the table. Each item has the form <replaceable>`item( `id( </replaceable> id <replaceable> ), first column, second column, ... )</replaceable>. For each column one argument has to be specified, which must be of type void, string or integer. Strings are being left justified, integer right and a nil denote an empty cell, just as the empty string.</para> + <para> In this example, "Bluebird" has an additional icon in his "Role" column, and "Wannabe" and "Coxxan" both have additional icons in their "Age" columns.</para> </para> </refsect1> <refsect1> @@ -4916,13 +5143,13 @@ </informalexample> </refsect1> </refentry> - <refentry id="Time_widget"> + <refentry id="TimeField_widget"> <refmeta> - <refentrytitle>Time</refentrytitle> + <refentrytitle>TimeField</refentrytitle> <manvolnum>3</manvolnum> </refmeta> <refnamediv> - <refname>Time</refname> + <refname>TimeField</refname> <refpurpose>Time input field</refpurpose> </refnamediv> <refsynopsisdiv> @@ -4930,12 +5157,16 @@ <funcprototype> <funcdef> <type></type> - <function>Time</function> + <function>TimeField</function> </funcdef> <paramdef> <type>string</type> <parameter>label</parameter> </paramdef> + <paramdef choice="opt"> + <type>string</type> + <parameter>initialTime</parameter> + </paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> @@ -4954,6 +5185,20 @@ </variablelist> </refsect1> <refsect1> + <title>Optional Arguments</title> + <variablelist> + <varlistentry> + <term> + <type>string</type> + <parameter>initialTime</parameter> + </term> + <listitem> + <para></para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + <refsect1> <title>Properties</title> <variablelist> <varlistentry> @@ -4962,7 +5207,16 @@ <parameter>Value</parameter> </term> <listitem> - <para>the date </para> + <para>the time (the field's contents) as "hh:mm:ss"</para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <type>string</type> + <parameter>Label</parameter> + </term> + <listitem> + <para>caption above the input field</para> </listitem> </varlistentry> </variablelist> @@ -4970,13 +5224,17 @@ <refsect1> <title>Description</title> <para> - <para> A Time input widget for entering time. This widget is available in the Qt interface only</para> + <para> An input field for entering a time of day in 24 hour format.</para> </para> + <note> + <para>This is a "special" widget, i.e. not all UIs necessarily support it. Check for availability with <replaceable>HasSpecialWidget( `TimeField)</replaceable> before using it.</para> + </note> </refsect1> <refsect1> <title>Usage</title> <programlisting> - `Time( "Time:" , "20:20:20" ) + if ( HasSpecialWidget( `TimeField ) {... + `TimeField( "Time:" , "20:20:20" ) </programlisting> </refsect1> </refentry> @@ -5107,58 +5365,16 @@ <parameter>Label</parameter> </term> <listitem> - <para>caption above the tree</para> + <para>Caption above the tree</para> </listitem> </varlistentry> <varlistentry> <term> <type>string</type> - <parameter>Label</parameter> - </term> - <listitem> - <para>the label above the Tree</para> - </listitem> - </varlistentry> - <varlistentry> - <term> - <type>itemId</type> - <parameter>CurrentItem</parameter> - </term> - <listitem> - <para>the currently selected item -Alias: Value</para> - </listitem> - </varlistentry> - <varlistentry> - <term> - <type>YTreeItem</type> - <parameter>list</parameter> - </term> - <listitem> - <para>Items -The items that are displayed</para> - </listitem> - </varlistentry> - <varlistentry> - <term> - <type>OpenItems</type> - <parameter>a</parameter> + <parameter>IconPath</parameter> </term> <listitem> - <para>map of open items - can only be queried, not set</para> - </listitem> - </varlistentry> - <varlistentry> - <term> - <type>CurrentBranch</type> - <parameter>a</parameter> - </term> - <listitem> - <para>list of the current item and all its ancestors -from the root item to the current item- either the respective IDs or, -for items that don't have IDs, the item text. If no item is currently -selected, 'nil' is returned. -This property can only be queried, not set.</para> + <para>Base path for icons</para> </listitem> </varlistentry> </variablelist> @@ -5462,7 +5678,7 @@ <para> A wizard widget always has ID `wizard.<p> The ID of the single replace point within the wizard is always `contents.</para> </para> <note> - <para>This is a "special" widget, i.e. not all UIs necessarily support it. Check for availability with <replaceable>HasSpecialWidget( `PartitionSplitter )</replaceable> before using it.</para> + <para>This is a "special" widget, i.e. not all UIs necessarily support it. Check for availability with <replaceable>HasSpecialWidget( `Wizard)</replaceable> before using it.</para> </note> </refsect1> <refsect1> Modified: branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog Mon Nov 12 17:35:40 2007 @@ -419,3 +419,9 @@ * Ported YBarGraph * Ported YPartitionSplitter + +2007-11-12 sh@suse.de + +* Enforced creating YWidget and derived classes with new (on the heap) +* Ported YDownloadProgress + Modified: branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/UIBuiltinCalls.h Mon Nov 12 17:35:40 2007 @@ -1,31 +1,30 @@ // This file is generated by generateYCPwrappers from Y2UINamespace.h - static const char * err_fmt = "Parameter %d is nil, %s is required"; case 0: // SetLanguage - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->SetLanguage (m_param1->asString()); case 1: // SetLanguage - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} return m_instance->SetLanguage (m_param1->asString(), m_param2->asString()); case 2: // GetProductName return m_instance->GetProductName (); case 3: // SetProductName - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->SetProductName (m_param1->asString()); case 4: // SetConsoleFont - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} - if (m_param3->isVoid()) {ycp2error(err_fmt, 3, "String"); return YCPVoid();} - if (m_param4->isVoid()) {ycp2error(err_fmt, 4, "String"); return YCPVoid();} - if (m_param5->isVoid()) {ycp2error(err_fmt, 5, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} + if (m_param3->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 3, "String"); return YCPVoid();} + if (m_param4->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 4, "String"); return YCPVoid();} + if (m_param5->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 5, "String"); return YCPVoid();} return m_instance->SetConsoleFont (m_param1->asString(), m_param2->asString(), m_param3->asString(), m_param4->asString(), m_param5->asString()); case 5: // SetKeyboard return m_instance->SetKeyboard (); case 6: // GetLanguage - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Boolean"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Boolean"); return YCPVoid();} return m_instance->GetLanguage (m_param1->asBoolean()); case 7: // UserInput @@ -34,71 +33,71 @@ return m_instance->PollInput (); case 9: // TimeoutUserInput - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Integer"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Integer"); return YCPVoid();} return m_instance->TimeoutUserInput (m_param1->asInteger()); case 10: // WaitForEvent return m_instance->WaitForEvent (); case 11: // WaitForEvent - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Integer"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Integer"); return YCPVoid();} return m_instance->WaitForEvent (m_param1->asInteger()); case 12: // OpenDialog - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} return m_instance->OpenDialog (m_param1->asTerm()); case 13: // OpenDialog - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} return m_instance->OpenDialog (m_param1->asTerm(), m_param2->asTerm()); case 14: // CloseDialog return m_instance->CloseDialog (); case 15: // ChangeWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Symbol"); return YCPVoid();} // m_param3 may be nil return m_instance->ChangeWidget (m_param1->asSymbol(), m_param2->asSymbol(), m_param3->asValue()); case 16: // ChangeWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Symbol"); return YCPVoid();} // m_param3 may be nil return m_instance->ChangeWidget (m_param1->asTerm(), m_param2->asSymbol(), m_param3->asValue()); case 17: // ChangeWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} - if (m_param3->isVoid()) {ycp2error(err_fmt, 3, "Value"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} + if (m_param3->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 3, "Value"); return YCPVoid();} return m_instance->ChangeWidget (m_param1->asTerm(), m_param2->asTerm(), m_param3->asValue()); case 18: // QueryWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Symbol"); return YCPVoid();} return m_instance->QueryWidget (m_param1->asSymbol(), m_param2->asSymbol()); case 19: // QueryWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} return m_instance->QueryWidget (m_param1->asSymbol(), m_param2->asTerm()); case 20: // QueryWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Symbol"); return YCPVoid();} return m_instance->QueryWidget (m_param1->asTerm(), m_param2->asSymbol()); case 21: // QueryWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} return m_instance->QueryWidget (m_param1->asTerm(), m_param2->asTerm()); case 22: // ReplaceWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} return m_instance->ReplaceWidget (m_param1->asSymbol(), m_param2->asTerm()); case 23: // ReplaceWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "Term"); return YCPVoid();} return m_instance->ReplaceWidget (m_param1->asTerm(), m_param2->asTerm()); case 24: // SetFocus - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} return m_instance->SetFocus (m_param1->asSymbol()); case 25: // SetFocus - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} return m_instance->SetFocus (m_param1->asTerm()); case 26: // RunInTerminal - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->RunInTerminal (m_param1->asString()); case 27: // BusyCursor @@ -110,7 +109,7 @@ return m_instance->NormalCursor (); case 30: // MakeScreenShot - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->MakeScreenShot (m_param1->asString()); case 31: // MakeScreenShot @@ -122,22 +121,22 @@ return m_instance->Beep (); case 34: // RecordMacro - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->RecordMacro (m_param1->asString()); case 35: // StopRecordMacro return m_instance->StopRecordMacro (); case 36: // PlayMacro - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->PlayMacro (m_param1->asString()); case 37: // FakeUserInput return m_instance->FakeUserInput (); case 38: // FakeUserInput - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Value"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Value"); return YCPVoid();} return m_instance->FakeUserInput (m_param1->asValue()); case 39: // Glyph - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} return m_instance->Glyph (m_param1->asSymbol()); case 40: // GetDisplayInfo @@ -152,42 +151,42 @@ return m_instance->CheckShortcuts (); case 44: // WidgetExists - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} return m_instance->WidgetExists (m_param1->asSymbol()); case 45: // WidgetExists - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} return m_instance->WidgetExists (m_param1->asTerm()); case 46: // RunPkgSelection - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Value"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Value"); return YCPVoid();} return m_instance->RunPkgSelection (m_param1->asValue()); case 47: // AskForExistingDirectory - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} return m_instance->AskForExistingDirectory (m_param1->asString(), m_param2->asString()); case 48: // AskForExistingFile - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} - if (m_param3->isVoid()) {ycp2error(err_fmt, 3, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} + if (m_param3->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 3, "String"); return YCPVoid();} return m_instance->AskForExistingFile (m_param1->asString(), m_param2->asString(), m_param3->asString()); case 49: // AskForSaveFileName - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} - if (m_param3->isVoid()) {ycp2error(err_fmt, 3, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} + if (m_param3->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 3, "String"); return YCPVoid();} return m_instance->AskForSaveFileName (m_param1->asString(), m_param2->asString(), m_param3->asString()); case 50: // SetFunctionKeys - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Map"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Map"); return YCPVoid();} return m_instance->SetFunctionKeys (m_param1->asMap()); case 51: // Recode - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} - if (m_param2->isVoid()) {ycp2error(err_fmt, 2, "String"); return YCPVoid();} - if (m_param3->isVoid()) {ycp2error(err_fmt, 3, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} + if (m_param2->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 2, "String"); return YCPVoid();} + if (m_param3->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 3, "String"); return YCPVoid();} return m_instance->Recode (m_param1->asString(), m_param2->asString(), m_param3->asString()); case 52: // SetModulename - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "String"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "String"); return YCPVoid();} return m_instance->SetModulename (m_param1->asString()); case 53: // HasSpecialWidget - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Symbol"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Symbol"); return YCPVoid();} return m_instance->HasSpecialWidget (m_param1->asSymbol()); case 54: // WizardCommand - if (m_param1->isVoid()) {ycp2error(err_fmt, 1, "Term"); return YCPVoid();} + if (m_param1->isVoid()) {ycp2error("Parameter %d is nil, %s is required", 1, "Term"); return YCPVoid();} return m_instance->WizardCommand (m_param1->asTerm()); Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Mon Nov 12 17:35:40 2007 @@ -49,6 +49,7 @@ #include "YCheckBoxFrame.h" #include "YComboBox.h" #include "YDateField.h" +#include "YDownloadProgress.h" #include "YDumbTab.h" #include "YEmpty.h" #include "YFrame.h" @@ -2621,10 +2622,6 @@ * automatically updates the display as required even if the download is taking * place in the foreground. * - * Please notice that this will work only if the UI runs on the same machine as - * the file to download which may not taken for granted (but which is so for - * most users). - * * @note This is a "special" widget, i.e. not all UIs necessarily support it. Check * for availability with <tt>HasSpecialWidget( `DownloadProgress )</tt> before using it. * @@ -2648,23 +2645,12 @@ } rejectAllOptions( term,optList ); - YWidget *downloadProgress; - - if ( YUI::ui()->hasDownloadProgress() ) - { - YCPString label = term->value( argnr )->asString(); - YCPString filename = term->value( argnr+1 )->asString(); - int expectedSize = term->value( argnr+2 )->asInteger()->value(); - downloadProgress = YUI::ui()->createDownloadProgress( parent, opt, label, filename, expectedSize ); - } - else - { - y2error( "This UI does not support the DownloadProgress widget." ); - return 0; - } + string label = term->value( argnr )->asString()->value(); + string filename = term->value( argnr+1 )->asString()->value(); + YFileSize_t expectedSize = term->value( argnr+2 )->asInteger()->value(); - return downloadProgress; + return YUI::optionalWidgetFactory()->createDownloadProgress( parent, label, filename, expectedSize ); } Modified: branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.cc Mon Nov 12 17:35:40 2007 @@ -27,135 +27,167 @@ #include "YDownloadProgress.h" -YDownloadProgress::YDownloadProgress( const YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ) - : YWidget( opt ) - , _label( label ) - , _filename( filename ) - , _expectedSize( expectedSize ) + +struct YDownloadProgressPrivate +{ + YDownloadProgressPrivate( const string & label, + const string & filename, + YFileSize_t expectedSize ) + : label( label ) + , filename( filename ) + , expectedSize( expectedSize ) + {} + + string label; + string filename; + YFileSize_t expectedSize; +}; + + +YDownloadProgress::YDownloadProgress( YWidget * parent, + const string & label, + const string & filename, + YFileSize_t expectedSize ) + : YWidget( parent ) + , priv( new YDownloadProgressPrivate( label, filename, expectedSize ) ) { + YUI_CHECK_NEW( priv ); + setDefaultStretchable( YD_HORIZ, true ); setStretchable( YD_VERT, false ); } -void YDownloadProgress::setLabel( const YCPString & newLabel ) +YDownloadProgress::~YDownloadProgress() { - _label = newLabel; + // NOP } -void YDownloadProgress::setFilename( const YCPString & newFilename ) +string +YDownloadProgress::label() const { - _filename = newFilename; + return priv->label; } -void YDownloadProgress::setExpectedSize( int newExpectedSize ) +void +YDownloadProgress::setLabel( const string & label ) { - _expectedSize = newExpectedSize; + priv->label = label; } -YCPValue YDownloadProgress::changeWidget( const YCPSymbol & property, - const YCPValue & newValue ) +string +YDownloadProgress::filename() const { - string sym = property->symbol(); + return priv->filename; +} - /** - * @property string Label the label above the progress indicator - */ - if ( sym == YUIProperty_Label ) - { - if ( newValue->isString() ) - { - setLabel( newValue->asString() ); - return YCPBoolean( true ); - } - else - { - y2error( "YDownloadProgress::changeWidget( `Value ): " - "Error: Expecting string, not %s", - newValue->toString().c_str() ); - return YCPBoolean( false ); - } - } - /** - * @property string Filename file name with full path of the file to poll - */ - else if ( sym == YUIProperty_Filename ) - { - if ( newValue->isString() ) - { - setFilename( newValue->asString() ); - return YCPBoolean( true ); - } - else - { - y2error( "YDownloadProgress::changeWidget( `Filename ): " - "Error: Expecting string, not %s", - newValue->toString().c_str() ); +void +YDownloadProgress::setFilename( const string & filename ) +{ + priv->filename = filename; +} - return YCPBoolean( false ); - } - } - /** - * @property integer ExpectedSize expected final size of the file in bytes - */ - else if ( sym == YUIProperty_ExpectedSize ) - { - if ( newValue->isInteger() ) - { - int val = newValue->asInteger()->value(); - - if ( val < 1 ) - { - y2warning( "YDownloadProgress::changeWidget( `expectedSize ): " - "Warning: New value %d below minValue ( %d )", - val, 0 ); - setExpectedSize(0); - } - else - { - setExpectedSize( val ); - } - - return YCPBoolean( true ); - } - else - { - y2error( "YDownloadProgress::changeWidget( `expectedSize ): " - "Error: Expecting integer value, not %s", - newValue->toString().c_str() ); - return YCPBoolean( false ); - } - } - else return YWidget::changeWidget( property, newValue ); +YFileSize_t +YDownloadProgress::expectedSize() const +{ + return priv->expectedSize; } +void +YDownloadProgress::setExpectedSize( YFileSize_t newSize ) +{ + priv->expectedSize = newSize; +} -YCPValue YDownloadProgress::queryWidget( const YCPSymbol & property ) + +int +YDownloadProgress::currentPercent() const { - string s = property->symbol(); - if ( s == YUIProperty_ExpectedSize ) return YCPInteger( expectedSize() ); - else if ( s == YUIProperty_Label ) return label(); - else if ( s == YUIProperty_Filename ) return filename(); - else return YWidget::queryWidget( property ); + if ( priv->expectedSize == 0 ) // Avoid division by zero + return 0; + + YFileSize_t currentSize = currentFileSize(); + + if ( currentSize >= priv->expectedSize ) + return 100; + else + return (int) ( (100 * currentSize ) / priv->expectedSize ); } -long YDownloadProgress::currentFileSize() +YFileSize_t +YDownloadProgress::currentFileSize() const { struct stat stat_info; - if ( stat( filename()->value().c_str(), & stat_info ) == 0 ) - return (long) stat_info.st_size; + if ( stat( priv->filename.c_str(), & stat_info ) == 0 ) + return (YFileSize_t) stat_info.st_size; + else + return 0; +} + + +const YPropertySet & +YDownloadProgress::propertySet() +{ + static YPropertySet propSet; + + if ( propSet.isEmpty() ) + { + /* + * @property string Label text above the progress bar + * @property string Filename name of the file that is monitored + * @property integer ExpectedSize expected size of the file in bytes + * @property integer CurrentSize current size of the file in bytes (read-only!) + * @property integer Value current percent of the download (read-only!) + */ + propSet.add( YProperty( YUIProperty_Label, YStringProperty ) ); + propSet.add( YProperty( YUIProperty_Filename, YStringProperty ) ); + propSet.add( YProperty( YUIProperty_ExpectedSize, YIntegerProperty ) ); + propSet.add( YProperty( YUIProperty_CurrentSize, YIntegerProperty, true ) ); // read-only + propSet.add( YProperty( YUIProperty_Value, YIntegerProperty, true ) ); // read-only + propSet.add( YWidget::propertySet() ); + } + + return propSet; +} + + +bool +YDownloadProgress::setProperty( const string & propertyName, const YPropertyValue & val ) +{ + propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch + + if ( propertyName == YUIProperty_Label ) setLabel ( val.stringVal() ); + if ( propertyName == YUIProperty_Filename ) setFilename ( val.stringVal() ); + if ( propertyName == YUIProperty_ExpectedSize ) setExpectedSize( val.integerVal() ); else - return 0L; + { + YWidget::setProperty( propertyName, val ); + } + + return true; // success -- no special handling necessary } + +YPropertyValue +YDownloadProgress::getProperty( const string & propertyName ) +{ + propertySet().check( propertyName ); // throws exceptions if not found + + if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() ); + if ( propertyName == YUIProperty_Filename ) return YPropertyValue( filename() ); + if ( propertyName == YUIProperty_ExpectedSize ) return YPropertyValue( expectedSize() ); + if ( propertyName == YUIProperty_CurrentSize ) return YPropertyValue( currentFileSize()); + if ( propertyName == YUIProperty_Value ) return YPropertyValue( currentPercent() ); + else + { + return YWidget::getProperty( propertyName ); + } +} Modified: branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YDownloadProgress.h Mon Nov 12 17:35:40 2007 @@ -20,81 +20,133 @@ #define YDownloadProgress_h #include "YWidget.h" -#include <ycp/YCPString.h> -#include <ycp/YCPInteger.h> +class YDownloadProgressPrivate; + +/** + * DownloadProgress: A progress bar that monitors downloading a file by + * repeatedly polling its size up to its expected size. + **/ class YDownloadProgress : public YWidget { protected: /** - * Constructor + * Constructor. + * + * 'label' is the label above the progress bar. + * + * 'filename' is the name (with path) of the file being monitored. + * + * 'expectedSize' is the expected size of the file in bytes. **/ - YDownloadProgress( const YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ); - + YDownloadProgress( YWidget * parent, + const string & label, + const string & filename, + YFileSize_t expectedSize ); public: /** + * Destructor. + **/ + virtual ~YDownloadProgress(); + + /** * Returns a descriptive name of this widget class for logging, * debugging etc. **/ virtual const char * widgetClass() const { return "YDownloadProgress"; } /** - * Implements the ChangeWidget() UI command. + * Get the label (the text above the progress bar). **/ - YCPValue changeWidget( const YCPSymbol & property, - const YCPValue & newValue ); + string label() const; /** - * Implements the QueryWidget() UI command. + * Set the label (the text above the progress bar). + * + * Derived classes are free to reimplement this, but they should call this + * base class method at the end of the overloaded function. **/ - YCPValue queryWidget( const YCPSymbol & property ); + virtual void setLabel( const string & label ); /** - * Change the label above the progress indicator. + * Return the name of the file that is being monitored. + **/ + string filename() const; + + /** + * Set the name of a new file to monitor. * - * Overwrite this, but call YDownloadProgress::setLabel - * at the end of your own method. + * Derived classes are free to reimplement this, but they should call this + * base class method at the end of the overloaded function. + **/ + virtual void setFilename( const string & filename ); + + /** + * Return the expected file size. **/ - virtual void setLabel( const YCPString & label ); + YFileSize_t expectedSize() const; /** - * Change the filename. + * Set the expected file size. * - * Overwrite this, but call YDownloadProgress::setFilename() - * at the end of your own method. + * Derived classes are free to reimplement this, but they should call this + * base class method at the end of the overloaded function. **/ - virtual void setFilename( const YCPString & newFilename ); + virtual void setExpectedSize( YFileSize_t newSize ); /** - * Change the expected size of the file being downloaded. + * Return the current size of the file that is being downloaded + * or 0 if this file doesn't exist (yet). * - * Overwrite this, but call YDownloadProgress::setExpectedSize() - * at the end of your own method. + * This default implementation returns the 'st_size' field of a stat() + * system call on the file. This should be useful for most implementations. **/ - virtual void setExpectedSize( int newExpectedSize ); + virtual YFileSize_t currentFileSize() const; + /** + * Return the percentage (0..100) of the file being downloaded so far. + **/ + int currentPercent() const; - YCPString label() { return _label; } - YCPString filename() { return _filename; } - int expectedSize() { return _expectedSize; } + /** + * Alias for currentPercent(). + **/ + int value() const { return currentPercent(); } + + /** + * Set a property. + * Reimplemented from YWidget. + * + * This function may throw YUIPropertyExceptions. + * + * This function returns 'true' if the value was successfully set and + * 'false' if that value requires special handling (not in error cases: + * those are covered by exceptions). + **/ + virtual bool setProperty( const string & propertyName, + const YPropertyValue & val ); + /** + * Get a property. + * Reimplemented from YWidget. + * + * This method may throw YUIPropertyExceptions. + **/ + virtual YPropertyValue getProperty( const string & propertyName ); /** - * Returns the current size of the file that is being downloaded. - * Returns 0 if this file doesn't exist ( yet ). + * Return this class's property set. + * This also initializes the property upon the first call. + * + * Reimplemented from YWidget. **/ - long currentFileSize(); + virtual const YPropertySet & propertySet(); private: - YCPString _label; - YCPString _filename; - int _expectedSize; + ImplPtr<YDownloadProgressPrivate> priv; }; Modified: branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.cc Mon Nov 12 17:35:40 2007 @@ -225,7 +225,7 @@ YOptionalWidgetFactory::createDownloadProgress( YWidget * parent, const string & label, const string & filename, - long expectedFileSize ) + YFileSize_t expectedFileSize ) { THROW_UNSUPPORTED( "YDownloadProgress" ); } Modified: branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YOptionalWidgetFactory.h Mon Nov 12 17:35:40 2007 @@ -116,7 +116,7 @@ virtual YDownloadProgress * createDownloadProgress ( YWidget * parent, const string & label, const string & filename, - long expectedFileSize ); + YFileSize_t expectedFileSize ); bool hasDummySpecialWidget(); YWidget * createDummySpecialWidget( YWidget * parent ); Modified: branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h Mon Nov 12 17:35:40 2007 @@ -47,7 +47,7 @@ virtual const char * widgetClass() const { return "YPushButton"; } /** - * Get the label (the text on the RadioButton). + * Get the label (the text on the button). **/ string label() const; Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTypes.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YTypes.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YTypes.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YTypes.h Mon Nov 12 17:35:40 2007 @@ -25,7 +25,8 @@ #include <list> -typedef double YLayoutSize_t; +typedef double YLayoutSize_t; +typedef long long YFileSize_t; class YWidget; Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Mon Nov 12 17:35:40 2007 @@ -459,20 +459,6 @@ // Widget creation methods - OBSOLETE, use widgetFactories instead /** - * Creates a DownloadProgress widget. - * - * This is a special widget that the UI may or may not support. - * Overwrite this method at your own discretion. - * If you do, remember to overwrite the has...() method as well! - **/ - virtual YWidget * createDownloadProgress( YWidget *parent, YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ); - - virtual bool hasDownloadProgress() { return false; } - - /** * Creates a DumbTab. * * This is a special widget that the UI may or may not support. Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h Mon Nov 12 17:35:40 2007 @@ -150,6 +150,7 @@ #define YUIProperty_Cell "Cell" #define YUIProperty_CurrentBranch "CurrentBranch" #define YUIProperty_CurrentButton "CurrentButton" +#define YUIProperty_CurrentSize "CurrentSize" #define YUIProperty_CurrentItem "CurrentItem" #define YUIProperty_DebugLabel "DebugLabel" #define YUIProperty_DialogDebugLabel "DialogDebugLabel" Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc Mon Nov 12 17:35:40 2007 @@ -87,7 +87,7 @@ if ( symbol == YUISpecialWidget_DummySpecialWidget ) hasWidget = fact->hasDummySpecialWidget(); else if ( symbol == YUISpecialWidget_BarGraph ) hasWidget = fact->hasBarGraph(); else if ( symbol == YUISpecialWidget_DumbTab ) hasWidget = hasDumbTab(); - else if ( symbol == YUISpecialWidget_DownloadProgress ) hasWidget = hasDownloadProgress(); + else if ( symbol == YUISpecialWidget_DownloadProgress ) hasWidget = fact->hasDownloadProgress(); else if ( symbol == YUISpecialWidget_HMultiProgressMeter ) hasWidget = fact->hasMultiProgressMeter(); else if ( symbol == YUISpecialWidget_VMultiProgressMeter ) hasWidget = fact->hasMultiProgressMeter(); else if ( symbol == YUISpecialWidget_Slider ) hasWidget = fact->hasSlider(); Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc Mon Nov 12 17:35:40 2007 @@ -34,25 +34,6 @@ * * UIs that overwrite any of those should overwrite the corresponding * has...() method as well! - **/ - -YWidget * YUI::createDownloadProgress( YWidget *parent, YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ) -{ - y2error( "Default createDownloadProgress() method called - " - "forgot to call HasSpecialWidget()?" ); - - return 0; -} - - -/** - * Default low level specific UI implementations for optional widgets. - * - * UIs that overwrite any of those should overwrite the corresponding - * has...() method as well! */ Modified: branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.cc (original) +++ branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.cc Mon Nov 12 17:35:40 2007 @@ -29,85 +29,101 @@ #include "YQWidgetCaption.h" -YQDownloadProgress::YQDownloadProgress( QWidget * parent, - const YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ) - : QVBox( parent ) - , YDownloadProgress( opt, label, filename, expectedSize ) +YQDownloadProgress::YQDownloadProgress( YWidget * parent, + const string & label, + const string & filename, + YFileSize_t expectedSize ) + : QVBox( (QWidget *) parent->widgetRep() ) + , YDownloadProgress( parent, label, filename, expectedSize ) { setWidgetRep( this ); setMargin( YQWidgetMargin ); - _caption = new YQWidgetCaption( this, label->value() ); + _caption = new YQWidgetCaption( this, label ); YUI_CHECK_NEW( _caption ); - - _qt_progress = new QProgressBar( this ); - YUI_CHECK_NEW( _qt_progress ); - - _qt_progress->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - _qt_progress->setTotalSteps( expectedSize ); - _qt_progress->setProgress( currentFileSize() ); + + _qt_progressBar = new QProgressBar( this ); + YUI_CHECK_NEW( _qt_progressBar ); + + _qt_progressBar->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + _qt_progressBar->setTotalSteps( 100 ); // Using percent + _qt_progressBar->setProgress( currentPercent() ); _timer = new QTimer( this ); - connect( _timer, SIGNAL( timeout() ), this, SLOT( pollFileSize() ) ); + + connect( _timer, SIGNAL( timeout() ), + this, SLOT ( pollFileSize() ) ); _timer->start( 250, // millisec false ); // single shot? } -void YQDownloadProgress::setEnabled( bool enabled ) +YQDownloadProgress::~YQDownloadProgress() { - _caption->setEnabled( enabled ); - _qt_progress->setEnabled( enabled ); - YWidget::setEnabled( enabled ); + // NOP } -int YQDownloadProgress::preferredWidth() +void +YQDownloadProgress::setLabel( const string & label ) { - return sizeHint().width(); + _caption->setText( label ); + YDownloadProgress::setLabel( label ); } -int YQDownloadProgress::preferredHeight() +void +YQDownloadProgress::setFilename( const string & filename ) { - return sizeHint().height(); + YDownloadProgress::setFilename( filename ); + _qt_progressBar->setProgress( currentPercent() ); } -void YQDownloadProgress::setSize( int newWidth, int newHeight ) +void +YQDownloadProgress::setExpectedSize( YFileSize_t expectedSize ) { - resize( newWidth, newHeight ); + _qt_progressBar->setProgress( currentPercent() ); + YDownloadProgress::setExpectedSize( expectedSize ); } -void YQDownloadProgress::setLabel( const YCPString & label ) +void +YQDownloadProgress::pollFileSize() { - _caption->setText( label->value() ); - YDownloadProgress::setLabel( label ); + _qt_progressBar->setProgress( currentPercent() ); } -void YQDownloadProgress::setExpectedSize( int expectedSize ) +void +YQDownloadProgress::setEnabled( bool enabled ) { - _qt_progress->setTotalSteps( expectedSize ); - _qt_progress->setProgress( currentFileSize() ); - YDownloadProgress::setExpectedSize( expectedSize ); + _caption->setEnabled( enabled ); + _qt_progressBar->setEnabled( enabled ); + YWidget::setEnabled( enabled ); } -void YQDownloadProgress::pollFileSize() +int +YQDownloadProgress::preferredWidth() { - long size = currentFileSize(); + return sizeHint().width(); +} + - if ( size > (long) expectedSize() ) - size = (long) expectedSize(); - _qt_progress->setProgress( size ); +int +YQDownloadProgress::preferredHeight() +{ + return sizeHint().height(); } +void +YQDownloadProgress::setSize( int newWidth, int newHeight ) +{ + resize( newWidth, newHeight ); +} + #include "YQDownloadProgress.moc" Modified: branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.h (original) +++ branches/tmp/sh/mod-ui/qt/src/YQDownloadProgress.h Mon Nov 12 17:35:40 2007 @@ -21,7 +21,6 @@ #define YQDownloadProgress_h #include <qvbox.h> -#include <ycp/YCPString.h> #include "YDownloadProgress.h" class YQWidgetCaption; @@ -37,11 +36,36 @@ /** * Constructor. **/ - YQDownloadProgress( QWidget * parent, - const YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ); + YQDownloadProgress( YWidget * parent, + const string & label, + const string & filename, + YFileSize_t expectedSize ); + + /** + * Destructor. + **/ + virtual ~YQDownloadProgress(); + + /** + * Set the label (the text above the progress bar). + * + * Reimplemented from YDownloadProgress. + **/ + virtual void setLabel( const string & label ); + + /** + * Set the name of a new file to monitor. + * + * Reimplemented from YDownloadProgress. + **/ + virtual void setFilename( const string & filename ); + + /** + * Change the expected file size. + * + * Reimplemented from YDownloadProgress. + **/ + virtual void setExpectedSize( YFileSize_t expectedSize ); /** * Set enabled/disabled state. @@ -71,21 +95,6 @@ **/ virtual void setSize( int newWidth, int newHeight ); - /** - * Change the label. - * Calls YDownloadProgress::setLabel at the end. - * Inherited from YDownloadProgress. - **/ - void setLabel( const YCPString & label ); - - - /** - * Change the expected file size. - * Calls YDownloadProgress::setExpectedSize() at the end. - * Inherited from YDownloadProgress. - **/ - void setExpectedSize( int expectedSize ); - public slots: /** @@ -97,7 +106,7 @@ protected: YQWidgetCaption * _caption; - QProgressBar * _qt_progress; + QProgressBar * _qt_progressBar; QTimer * _timer; }; Modified: branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc (original) +++ branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc Mon Nov 12 17:35:40 2007 @@ -236,15 +236,21 @@ bool YQOptionalWidgetFactory::hasDownloadProgress() { - return false; + return true; } YQDownloadProgress * YQOptionalWidgetFactory::createDownloadProgress( YWidget * parent, const string & label, const string & filename, - long expectedFileSize ) + YFileSize_t expectedSize ) { - THROW_UNSUPPORTED( "YQDownloadProgress" ); + YQDownloadProgress * downloadProgress = new YQDownloadProgress( parent, + label, + filename, + expectedSize ); + YUI_CHECK_NEW( downloadProgress ); + + return downloadProgress; } Modified: branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.h (original) +++ branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.h Mon Nov 12 17:35:40 2007 @@ -107,7 +107,7 @@ virtual YQDownloadProgress * createDownloadProgress ( YWidget * parent, const string & label, const string & filename, - long expectedFileSize ); + YFileSize_t expectedFileSize ); protected: Modified: branches/tmp/sh/mod-ui/qt/src/YQUI.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI.h?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original) +++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Mon Nov 12 17:35:40 2007 @@ -432,40 +432,10 @@ /*** Widget creation methods for optional widgets, all reimplemented from YUI ***/ - bool hasDownloadProgress(); - YWidget * createDownloadProgress ( YWidget * parent, - YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize ); - bool hasDumbTab(); YWidget * createDumbTab ( YWidget * parent, YWidgetOpt & opt ); - bool hasSlider(); - YWidget * createSlider ( YWidget * parent, - YWidgetOpt & opt, - const YCPString & label, - int minValue, - int maxValue, - int initialValue ); - - bool hasPartitionSplitter(); - YWidget * createPartitionSplitter( YWidget * parent, - YWidgetOpt & opt, - int usedSize, - int totalFreeSize, - int newPartSize, - int minNewPartSize, - int minFreeSize, - const YCPString & usedLabel, - const YCPString & freeLabel, - const YCPString & newPartLabel, - const YCPString & freeFieldLabel, - const YCPString & newPartFieldLabel ); - - /*** END widget creation methods ***/ Modified: branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc?rev=41984&r1=41983&r2=41984&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original) +++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Mon Nov 12 17:35:40 2007 @@ -52,24 +52,6 @@ //========= Optional widgets ================================================== -bool YQUI::hasDownloadProgress() -{ - return true; -} - -YWidget * YQUI::createDownloadProgress ( YWidget * parent, - YWidgetOpt & opt, - const YCPString & label, - const YCPString & filename, - int expectedSize) -{ - return new YQDownloadProgress( (QWidget *) ( parent->widgetRep() ), - opt, - label, - filename, - expectedSize ); -} - bool YQUI::hasDumbTab() { -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org