Author: jsmeix Date: Tue Mar 3 15:06:02 2009 New Revision: 55890 URL: http://svn.opensuse.org/viewcvs/yast?rev=55890&view=rev Log: - Fixed a few bugs in the "More Drivers" functionality. In particular it works now always based on the current visible search string and no longer on whatever obsure other stuff. - The DriverItems function in Printer.ycp searches the model name now also in the 1284DeviceID entry in the PPDs because this entry should contain the exact model name how it is autodetected while the NickName entry (which is still searched) may contain a different model name (e.g. what is labeled on the device). - 2.18.9 Modified: trunk/printer/VERSION trunk/printer/package/yast2-printer.changes trunk/printer/src/Printer.ycp trunk/printer/src/basicadd.ycp trunk/printer/src/basicmodify.ycp Modified: trunk/printer/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=55890&r1=55889&r2=55890&view=diff ============================================================================== --- trunk/printer/VERSION (original) +++ trunk/printer/VERSION Tue Mar 3 15:06:02 2009 @@ -1 +1 @@ -2.18.8 +2.18.9 Modified: trunk/printer/package/yast2-printer.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=55890&r1=55889&r2=55890&view=diff ============================================================================== --- trunk/printer/package/yast2-printer.changes (original) +++ trunk/printer/package/yast2-printer.changes Tue Mar 3 15:06:02 2009 @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Tue Mar 3 14:55:40 CET 2009 - jsmeix@suse.de + +- Fixed a few bugs in the "More Drivers" functionality. + In particular it works now always based on the current visible + search string and no longer on whatever obsure other stuff. +- The DriverItems function in Printer.ycp searches the model name + now also in the 1284DeviceID entry in the PPDs because this entry + should contain the exact model name how it is autodetected + while the NickName entry (which is still searched) may contain + a different model name (e.g. what is labeled on the device). +- 2.18.9 + +------------------------------------------------------------------- Fri Feb 27 15:35:16 CET 2009 - jsmeix@suse.de - Added the functionality to basicadd.ycp and basicmodify.ycp to Modified: trunk/printer/src/Printer.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/Printer.ycp?rev=55890&r1=55889&r2=55890&view=diff ============================================================================== --- trunk/printer/src/Printer.ycp (original) +++ trunk/printer/src/Printer.ycp Tue Mar 3 15:06:02 2009 @@ -1283,9 +1283,17 @@ } else { // If the driver_filter_string is a non-empty string, - // test whether the nickname matches to the driver_filter_string: - string unified_nickname = filterchars( tolower( nickname ), lower_alnum_chars ); - if( regexpmatch( unified_nickname, driver_filter_string ) ) + // test whether nickname or deviceID matches to the driver_filter_string. + // Only the special character '+' is also taken into account because + // this is sometimes also a meaningful character in the model name + // for example the '+' at the end of a Kyocera model name + // indicates that this model has a built-in PostScript interpreter + // while the model without the '+' understands only PCL. + string unified_nickname = filterchars( tolower( nickname ), lower_alnum_chars + "+" ); + string unified_deviceID = filterchars( tolower( deviceID ), lower_alnum_chars + "+" ); + if( regexpmatch( unified_nickname, driver_filter_string ) + || regexpmatch( unified_deviceID, driver_filter_string ) + ) { driver_items = add( driver_items, `item( `id( ppds_index ), driver_string ) ); } } Modified: trunk/printer/src/basicadd.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicadd.ycp?rev=55890&r1=55889&r2=55890&view=diff ============================================================================== --- trunk/printer/src/basicadd.ycp (original) +++ trunk/printer/src/basicadd.ycp Tue Mar 3 15:06:02 2009 @@ -478,23 +478,28 @@ { driver_filter_string = ""; boolean valid_driver_found = false; list driver_items = []; - // Use the existing value of model because for each subsequent run of this more_drivers section - // the existing value of model is shortened at the end (the last word is removed) to get - // more and mor derivers for each subsequent run of this more_drivers section. - y2milestone( "More drivers for '%1'", model ); - if( "" != model - && "unknown" != tolower( model ) + // Use the existing value of driver_filter_input_text + // which is by default set to the autodetected model name + // but it could be any string which was entered before by the user. + // The "more drivers" functionality must work based on the current search string + // and when nothing is found based on the current search string + // it falls back to show all drivers so that there is a valid result in any case. + driver_filter_input_text = (string)UI::QueryWidget( `id(`driver_filter_input), `Value ); + y2milestone( "More drivers for '%1'", driver_filter_input_text ); + if( "" != driver_filter_input_text + && "unknown" != tolower( driver_filter_input_text ) ) - { // If the model string does not contain a space, - // model_words is a singleton list which contains only model. - list <string> model_words = splitstring( model, " " ); - if( size( model_words ) >= 2 ) - { // If there are less than two words the following does not make sense. + { // If the driver_filter_input_text string does not contain a space, + // words is a singleton list which contains only one word. + list <string> words = splitstring( driver_filter_input_text, " " ); + if( size( words ) >= 1 ) + { // Even if it is only one word, the following makes sense + // because the one word could already be the model_number_word. // Try to find the word which contains a model number. // This is usually the first word which contains a number. string model_number_word = ""; foreach( string word, - model_words, + words, { if( "" != filterchars( word, Printer::number_chars ) ) { model_number_word = word; break; @@ -531,63 +536,59 @@ } } } - } - // Use the manufacturer when the existing value of model cannot be used - // or when nothing was found above: - if( ! valid_driver_found ) - { driver_filter_string = ""; - string model = Printer::connections[Printer::selected_connections_index,"model"]:""; - if( "" != model - && "unknown" != tolower( model ) - ) - { // The first word in the driver_filter_string is usually the first word of the manufacturer name. + // Try to use the manufacturer when nothing was found above: + if( ! valid_driver_found ) + { driver_filter_string = ""; + // The first word in the driver_filter_input_text is usually the first word of the manufacturer name. // This fuzzy match is intended so that e.g. "Kyocera" and "Kyocera Mita" are the same. - string manufacturer = splitstring( model, " " )[0]:""; + string manufacturer = splitstring( driver_filter_input_text, " " )[0]:""; if( "" != manufacturer ) { // Even more fuzziness for very ambiguous manufacturer names: - if( "hewlett" == substring( tolower( driver_filter_string ), 0, 7 ) ) + if( "hewlett" == substring( tolower( driver_filter_input_text ), 0, 7 ) ) { // Let "Hewlett-Packard", "Hewlett Packard", and "HP be the same: manufacturer = "HP"; } - if( "oki" == substring( tolower( driver_filter_string ), 0, 3 ) ) + if( "oki" == substring( tolower( driver_filter_input_text ), 0, 3 ) ) { // Let "Oki", "Okidata", and "Okipage" be the same: manufacturer = "Oki"; } - driver_filter_string = tolower( manufacturer ); - // Match at the beginning only if the driver_filter_string is actually a known manufacturer: - foreach( string known_manufacturer, - Printer::known_manufacturers, - { if( driver_filter_string == tolower( known_manufacturer ) ) - { driver_filter_string = "^" + driver_filter_string; - break; - } - } - ); // Provide visible feeback what is going on: UI::ReplaceWidget( `id(`driver_filter_input_replace_point), `InputField ( `id(`driver_filter_input), `opt(`hstretch), // No InputField header because there is the "Caption for a printer driver selection": - "", + "", manufacturer ) ); - driver_items = Printer::DriverItems( driver_filter_string, true ); - // Printer::DriverItems may result a driver_items list with one single element - // [ `item( `id( -1 ), _("No matching driver found.") ) ] - // to show at least a meaningful text as fallback entry to the user - // or Printer::DriverItems may result a driver_items list with the first item - // [ `item( `id( -1 ), _("Select a driver.") ), ... ] - // when Printer::DriverItems could not preselect a driver item. - // If a valid driver was found (but perhaps none was preselected), - // there would be a non-negative id value of the first or second element - // which is driver_items[0,0,0] or driver_items[1,0,0] - // (id[0] is the value of the id, see the comment in Printer::DriverItems). - if( driver_items[0,0,0]:-1 >= 0 - || driver_items[1,0,0]:-1 >= 0 - ) - { valid_driver_found = true; + driver_filter_string = filterchars( tolower( manufacturer ), Printer::lower_alnum_chars ); + if( "" != driver_filter_string ) + { // Match at the beginning only if the driver_filter_string is actually a known manufacturer: + foreach( string known_manufacturer, + Printer::known_manufacturers, + { if( driver_filter_string == tolower( known_manufacturer ) ) + { driver_filter_string = "^" + driver_filter_string; + break; + } + } + ); + driver_items = Printer::DriverItems( driver_filter_string, true ); + // Printer::DriverItems may result a driver_items list with one single element + // [ `item( `id( -1 ), _("No matching driver found.") ) ] + // to show at least a meaningful text as fallback entry to the user + // or Printer::DriverItems may result a driver_items list with the first item + // [ `item( `id( -1 ), _("Select a driver.") ), ... ] + // when Printer::DriverItems could not preselect a driver item. + // If a valid driver was found (but perhaps none was preselected), + // there would be a non-negative id value of the first or second element + // which is driver_items[0,0,0] or driver_items[1,0,0] + // (id[0] is the value of the id, see the comment in Printer::DriverItems). + if( driver_items[0,0,0]:-1 >= 0 + || driver_items[1,0,0]:-1 >= 0 + ) + { valid_driver_found = true; + } } } } Modified: trunk/printer/src/basicmodify.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/basicmodify.ycp?rev=55890&r1=55889&r2=55890&view=diff ============================================================================== --- trunk/printer/src/basicmodify.ycp (original) +++ trunk/printer/src/basicmodify.ycp Tue Mar 3 15:06:02 2009 @@ -920,7 +920,11 @@ boolean valid_driver_found = false; list driver_items = []; // Use the existing value of driver_filter_input_text - // which is usually set to nick_name and to model as fallback. + // which is usually set to nick_name and to model as fallback + // but it could be any string which was entered before by the user. + // The "more drivers" functionality must work based on the current search string + // and when nothing is found based on the current search string + // it falls back to show all drivers so that there is a valid result in any case. driver_filter_input_text = (string)UI::QueryWidget( `id(`driver_filter_input), `Value ); y2milestone( "More drivers for '%1'", driver_filter_input_text ); if( "" != driver_filter_input_text @@ -929,8 +933,9 @@ { // If the driver_filter_input_text string does not contain a space, // words is a singleton list which contains only one word. list <string> words = splitstring( driver_filter_input_text, " " ); - if( size( words ) >= 2 ) - { // If there are less than two words the following does not make sense. + if( size( words ) >= 1 ) + { // Even if it is only one word, the following makes sense + // because the one word could already be the model_number_word. // Try to find the word which contains a model number. // This is usually the first word which contains a number. string model_number_word = ""; @@ -972,38 +977,22 @@ } } } - } - // Use the manufacturer when the existing value of model cannot be used - // or when nothing was found above: - if( ! valid_driver_found ) - { driver_filter_string = ""; - string model = Printer::connections[Printer::selected_connections_index,"model"]:""; - if( "" != model - && "unknown" != tolower( model ) - ) - { // The first word in the driver_filter_string is usually the first word of the manufacturer name. + // Try to use the manufacturer when nothing was found above: + if( ! valid_driver_found ) + { driver_filter_string = ""; + // The first word in the driver_filter_input_text is usually the first word of the manufacturer name. // This fuzzy match is intended so that e.g. "Kyocera" and "Kyocera Mita" are the same. - string manufacturer = splitstring( model, " " )[0]:""; + string manufacturer = splitstring( driver_filter_input_text, " " )[0]:""; if( "" != manufacturer ) { // Even more fuzziness for very ambiguous manufacturer names: - if( "hewlett" == substring( tolower( driver_filter_string ), 0, 7 ) ) + if( "hewlett" == substring( tolower( driver_filter_input_text ), 0, 7 ) ) { // Let "Hewlett-Packard", "Hewlett Packard", and "HP be the same: manufacturer = "HP"; } - if( "oki" == substring( tolower( driver_filter_string ), 0, 3 ) ) + if( "oki" == substring( tolower( driver_filter_input_text ), 0, 3 ) ) { // Let "Oki", "Okidata", and "Okipage" be the same: manufacturer = "Oki"; } - driver_filter_string = tolower( manufacturer ); - // Match at the beginning only if the driver_filter_string is actually a known manufacturer: - foreach( string known_manufacturer, - Printer::known_manufacturers, - { if( driver_filter_string == tolower( known_manufacturer ) ) - { driver_filter_string = "^" + driver_filter_string; - break; - } - } - ); // Provide visible feeback what is going on: UI::ReplaceWidget( `id(`driver_filter_input_replace_point), `InputField @@ -1014,21 +1003,33 @@ manufacturer ) ); - driver_items = Printer::DriverItems( driver_filter_string, true ); - // Printer::DriverItems may result a driver_items list with one single element - // [ `item( `id( -1 ), _("No matching driver found.") ) ] - // to show at least a meaningful text as fallback entry to the user - // or Printer::DriverItems may result a driver_items list with the first item - // [ `item( `id( -1 ), _("Select a driver.") ), ... ] - // when Printer::DriverItems could not preselect a driver item. - // If a valid driver was found (but perhaps none was preselected), - // there would be a non-negative id value of the first or second element - // which is driver_items[0,0,0] or driver_items[1,0,0] - // (id[0] is the value of the id, see the comment in Printer::DriverItems). - if( driver_items[0,0,0]:-1 >= 0 - || driver_items[1,0,0]:-1 >= 0 - ) - { valid_driver_found = true; + driver_filter_string = filterchars( tolower( manufacturer ), Printer::lower_alnum_chars ); + if( "" != driver_filter_string ) + { // Match at the beginning only if the driver_filter_string is actually a known manufacturer: + foreach( string known_manufacturer, + Printer::known_manufacturers, + { if( driver_filter_string == tolower( known_manufacturer ) ) + { driver_filter_string = "^" + driver_filter_string; + break; + } + } + ); + driver_items = Printer::DriverItems( driver_filter_string, true ); + // Printer::DriverItems may result a driver_items list with one single element + // [ `item( `id( -1 ), _("No matching driver found.") ) ] + // to show at least a meaningful text as fallback entry to the user + // or Printer::DriverItems may result a driver_items list with the first item + // [ `item( `id( -1 ), _("Select a driver.") ), ... ] + // when Printer::DriverItems could not preselect a driver item. + // If a valid driver was found (but perhaps none was preselected), + // there would be a non-negative id value of the first or second element + // which is driver_items[0,0,0] or driver_items[1,0,0] + // (id[0] is the value of the id, see the comment in Printer::DriverItems). + if( driver_items[0,0,0]:-1 >= 0 + || driver_items[1,0,0]:-1 >= 0 + ) + { valid_driver_found = true; + } } } } @@ -1049,17 +1050,18 @@ driver_items = Printer::DriverItems( "", true ); } UI::ReplaceWidget( `id(`driver_selection_replace_point), - `SelectionBox( `id(`driver_selection), - // By default there is no UserInput() - // if only something was selected in the SelectionBox - // (without clicking additionally a button) - // but the notify option forces UserInput() in this case: - `opt(`notify), - "", - prepend( driver_items, - current_driver - ) - ) + `SelectionBox + ( `id(`driver_selection), + // By default there is no UserInput() + // if only something was selected in the SelectionBox + // (without clicking additionally a button) + // but the notify option forces UserInput() in this case: + `opt(`notify), + "", + prepend( driver_items, + current_driver + ) + ) ); continue; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org