Added a line widget with embeddable buttons.

Sun, 26 Sep 2010 20:25:09 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 26 Sep 2010 20:25:09 +0200
changeset 643
719db11dd4df
parent 641
b06d4df23797
child 644
7c1c3abedf1c

Added a line widget with embeddable buttons.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Gui.E5LineEdit.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.E5Gui.E5LineEditButton.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.HelpWebSearchWidget.html file | annotate | diff | comparison | revisions
Documentation/Source/index-eric5.E5Gui.html file | annotate | diff | comparison | revisions
E5Gui/E5LineEdit.py file | annotate | diff | comparison | revisions
E5Gui/E5LineEditButton.py file | annotate | diff | comparison | revisions
Helpviewer/HelpWebSearchWidget.py file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
eric5.e4p file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Sun Sep 26 15:18:07 2010 +0200
+++ b/APIs/Python3/eric5.api	Sun Sep 26 20:25:09 2010 +0200
@@ -1146,10 +1146,28 @@
 eric5.E5Gui.E5Led.E5Led?1(parent = None, color = None, shape = E5LedCircular, rectRatio = 1)
 eric5.E5Gui.E5Led.E5LedCircular?7
 eric5.E5Gui.E5Led.E5LedRectangular?7
+eric5.E5Gui.E5LineEdit.E5LineEdit.LeftSide?7
+eric5.E5Gui.E5LineEdit.E5LineEdit.RightSide?7
+eric5.E5Gui.E5LineEdit.E5LineEdit._updateTextMargins?5()
+eric5.E5Gui.E5LineEdit.E5LineEdit.addWidget?4(widget, position)
+eric5.E5Gui.E5LineEdit.E5LineEdit.event?4(evt)
 eric5.E5Gui.E5LineEdit.E5LineEdit.inactiveText?4()
 eric5.E5Gui.E5LineEdit.E5LineEdit.paintEvent?4(evt)
+eric5.E5Gui.E5LineEdit.E5LineEdit.removeWidget?4(widget)
+eric5.E5Gui.E5LineEdit.E5LineEdit.resizeEvent?4(evt)
 eric5.E5Gui.E5LineEdit.E5LineEdit.setInactiveText?4(inactiveText)
+eric5.E5Gui.E5LineEdit.E5LineEdit.setWidgetSpacing?4(spacing)
+eric5.E5Gui.E5LineEdit.E5LineEdit.textMargin?4(position)
+eric5.E5Gui.E5LineEdit.E5LineEdit.widgetSpacing?4()
 eric5.E5Gui.E5LineEdit.E5LineEdit?1(parent = None, inactiveText = "")
+eric5.E5Gui.E5LineEdit.SideWidget.event?4(evt)
+eric5.E5Gui.E5LineEdit.SideWidget.sizeHintChanged?7
+eric5.E5Gui.E5LineEdit.SideWidget?1(parent = None)
+eric5.E5Gui.E5LineEditButton.E5LineEditButton.menu?4()
+eric5.E5Gui.E5LineEditButton.E5LineEditButton.paintEvent?4(evt)
+eric5.E5Gui.E5LineEditButton.E5LineEditButton.setIcon?4(icon)
+eric5.E5Gui.E5LineEditButton.E5LineEditButton.setMenu?4(menu)
+eric5.E5Gui.E5LineEditButton.E5LineEditButton?1(parent = None)
 eric5.E5Gui.E5ListView.E5ListView.keyPressEvent?4(evt)
 eric5.E5Gui.E5ListView.E5ListView.removeAll?4()
 eric5.E5Gui.E5ListView.E5ListView.removeSelected?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sun Sep 26 15:18:07 2010 +0200
+++ b/Documentation/Help/source.qhp	Sun Sep 26 20:25:09 2010 +0200
@@ -118,6 +118,7 @@
             <section title="eric5.E5Gui.E5FileDialog" ref="eric5.E5Gui.E5FileDialog.html" />
             <section title="eric5.E5Gui.E5Led" ref="eric5.E5Gui.E5Led.html" />
             <section title="eric5.E5Gui.E5LineEdit" ref="eric5.E5Gui.E5LineEdit.html" />
+            <section title="eric5.E5Gui.E5LineEditButton" ref="eric5.E5Gui.E5LineEditButton.html" />
             <section title="eric5.E5Gui.E5ListView" ref="eric5.E5Gui.E5ListView.html" />
             <section title="eric5.E5Gui.E5MessageBox" ref="eric5.E5Gui.E5MessageBox.html" />
             <section title="eric5.E5Gui.E5ModelMenu" ref="eric5.E5Gui.E5ModelMenu.html" />
@@ -2624,6 +2625,7 @@
       <keyword name="HelpWebSearchWidget.__searchNow" id="HelpWebSearchWidget.__searchNow" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.__searchNow" />
       <keyword name="HelpWebSearchWidget.__setupCompleterMenu" id="HelpWebSearchWidget.__setupCompleterMenu" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.__setupCompleterMenu" />
       <keyword name="HelpWebSearchWidget.__showEnginesMenu" id="HelpWebSearchWidget.__showEnginesMenu" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.__showEnginesMenu" />
+      <keyword name="HelpWebSearchWidget.__textChanged" id="HelpWebSearchWidget.__textChanged" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.__textChanged" />
       <keyword name="HelpWebSearchWidget.__textEdited" id="HelpWebSearchWidget.__textEdited" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.__textEdited" />
       <keyword name="HelpWebSearchWidget.clear" id="HelpWebSearchWidget.clear" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.clear" />
       <keyword name="HelpWebSearchWidget.openSearchManager" id="HelpWebSearchWidget.openSearchManager" ref="eric5.Helpviewer.HelpWebSearchWidget.html#HelpWebSearchWidget.openSearchManager" />
@@ -4099,10 +4101,22 @@
       <keyword name="E5SingleApplicationServer.handleCommand" id="E5SingleApplicationServer.handleCommand" ref="eric5.E5Gui.E5SingleApplication.html#E5SingleApplicationServer.handleCommand" />
       <keyword name="E5LineEdit (Module)" id="E5LineEdit (Module)" ref="eric5.E5Gui.E5LineEdit.html" />
       <keyword name="E5LineEdit" id="E5LineEdit" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit" />
+      <keyword name="SideWidget" id="SideWidget" ref="eric5.E5Gui.E5LineEdit.html#SideWidget" />
       <keyword name="E5LineEdit (Constructor)" id="E5LineEdit (Constructor)" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.__init__" />
+      <keyword name="E5LineEdit.__updateSideWidgetLocations" id="E5LineEdit.__updateSideWidgetLocations" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.__updateSideWidgetLocations" />
+      <keyword name="E5LineEdit._updateTextMargins" id="E5LineEdit._updateTextMargins" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit._updateTextMargins" />
+      <keyword name="E5LineEdit.addWidget" id="E5LineEdit.addWidget" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.addWidget" />
+      <keyword name="E5LineEdit.event" id="E5LineEdit.event" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.event" />
       <keyword name="E5LineEdit.inactiveText" id="E5LineEdit.inactiveText" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.inactiveText" />
       <keyword name="E5LineEdit.paintEvent" id="E5LineEdit.paintEvent" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.paintEvent" />
+      <keyword name="E5LineEdit.removeWidget" id="E5LineEdit.removeWidget" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.removeWidget" />
+      <keyword name="E5LineEdit.resizeEvent" id="E5LineEdit.resizeEvent" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.resizeEvent" />
       <keyword name="E5LineEdit.setInactiveText" id="E5LineEdit.setInactiveText" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.setInactiveText" />
+      <keyword name="E5LineEdit.setWidgetSpacing" id="E5LineEdit.setWidgetSpacing" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.setWidgetSpacing" />
+      <keyword name="E5LineEdit.textMargin" id="E5LineEdit.textMargin" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.textMargin" />
+      <keyword name="E5LineEdit.widgetSpacing" id="E5LineEdit.widgetSpacing" ref="eric5.E5Gui.E5LineEdit.html#E5LineEdit.widgetSpacing" />
+      <keyword name="SideWidget (Constructor)" id="SideWidget (Constructor)" ref="eric5.E5Gui.E5LineEdit.html#SideWidget.__init__" />
+      <keyword name="SideWidget.event" id="SideWidget.event" ref="eric5.E5Gui.E5LineEdit.html#SideWidget.event" />
       <keyword name="E5Led (Module)" id="E5Led (Module)" ref="eric5.E5Gui.E5Led.html" />
       <keyword name="E5Led" id="E5Led" ref="eric5.E5Gui.E5Led.html#E5Led" />
       <keyword name="E5Led (Constructor)" id="E5Led (Constructor)" ref="eric5.E5Gui.E5Led.html#E5Led.__init__" />
@@ -4384,6 +4398,14 @@
       <keyword name="E5ModelMenu.setSeparatorRole" id="E5ModelMenu.setSeparatorRole" ref="eric5.E5Gui.E5ModelMenu.html#E5ModelMenu.setSeparatorRole" />
       <keyword name="E5ModelMenu.setStatusBarTextRole" id="E5ModelMenu.setStatusBarTextRole" ref="eric5.E5Gui.E5ModelMenu.html#E5ModelMenu.setStatusBarTextRole" />
       <keyword name="E5ModelMenu.statusBarTextRole" id="E5ModelMenu.statusBarTextRole" ref="eric5.E5Gui.E5ModelMenu.html#E5ModelMenu.statusBarTextRole" />
+      <keyword name="E5LineEditButton (Module)" id="E5LineEditButton (Module)" ref="eric5.E5Gui.E5LineEditButton.html" />
+      <keyword name="E5LineEditButton" id="E5LineEditButton" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton" />
+      <keyword name="E5LineEditButton (Constructor)" id="E5LineEditButton (Constructor)" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.__init__" />
+      <keyword name="E5LineEditButton.__clicked" id="E5LineEditButton.__clicked" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.__clicked" />
+      <keyword name="E5LineEditButton.menu" id="E5LineEditButton.menu" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.menu" />
+      <keyword name="E5LineEditButton.paintEvent" id="E5LineEditButton.paintEvent" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.paintEvent" />
+      <keyword name="E5LineEditButton.setIcon" id="E5LineEditButton.setIcon" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.setIcon" />
+      <keyword name="E5LineEditButton.setMenu" id="E5LineEditButton.setMenu" ref="eric5.E5Gui.E5LineEditButton.html#E5LineEditButton.setMenu" />
       <keyword name="E5TableView (Module)" id="E5TableView (Module)" ref="eric5.E5Gui.E5TableView.html" />
       <keyword name="E5TableView" id="E5TableView" ref="eric5.E5Gui.E5TableView.html#E5TableView" />
       <keyword name="E5TableView.keyPressEvent" id="E5TableView.keyPressEvent" ref="eric5.E5Gui.E5TableView.html#E5TableView.keyPressEvent" />
@@ -9762,6 +9784,7 @@
       <file>eric5.E5Gui.E5FileDialog.html</file>
       <file>eric5.E5Gui.E5Led.html</file>
       <file>eric5.E5Gui.E5LineEdit.html</file>
+      <file>eric5.E5Gui.E5LineEditButton.html</file>
       <file>eric5.E5Gui.E5ListView.html</file>
       <file>eric5.E5Gui.E5MessageBox.html</file>
       <file>eric5.E5Gui.E5ModelMenu.html</file>
--- a/Documentation/Source/eric5.E5Gui.E5LineEdit.html	Sun Sep 26 15:18:07 2010 +0200
+++ b/Documentation/Source/eric5.E5Gui.E5LineEdit.html	Sun Sep 26 20:25:09 2010 +0200
@@ -33,6 +33,9 @@
 <tr>
 <td><a href="#E5LineEdit">E5LineEdit</a></td>
 <td>Class implementing a line edit widget showing some inactive text.</td>
+</tr><tr>
+<td><a href="#SideWidget">SideWidget</a></td>
+<td>Class implementing the side widgets for the line edit class.</td>
 </tr>
 </table>
 <h3>Functions</h3>
@@ -49,7 +52,7 @@
 QLineEdit
 <h3>Class Attributes</h3>
 <table>
-<tr><td>None</td></tr>
+<tr><td>LeftSide</td></tr><tr><td>RightSide</td></tr>
 </table>
 <h3>Methods</h3>
 <table>
@@ -57,14 +60,41 @@
 <td><a href="#E5LineEdit.__init__">E5LineEdit</a></td>
 <td>Constructor</td>
 </tr><tr>
+<td><a href="#E5LineEdit.__updateSideWidgetLocations">__updateSideWidgetLocations</a></td>
+<td>Private method to update the side widget locations.</td>
+</tr><tr>
+<td><a href="#E5LineEdit._updateTextMargins">_updateTextMargins</a></td>
+<td>Protected slot to update the text margins.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.addWidget">addWidget</a></td>
+<td>Public method to add a widget to a side.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.event">event</a></td>
+<td>Protected method to handle events.</td>
+</tr><tr>
 <td><a href="#E5LineEdit.inactiveText">inactiveText</a></td>
 <td>Public method to get the inactive text.</td>
 </tr><tr>
 <td><a href="#E5LineEdit.paintEvent">paintEvent</a></td>
 <td>Protected method handling a paint event.</td>
 </tr><tr>
+<td><a href="#E5LineEdit.removeWidget">removeWidget</a></td>
+<td>Public method to remove a widget from a side.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.resizeEvent">resizeEvent</a></td>
+<td>Protected method to handle resize events.</td>
+</tr><tr>
 <td><a href="#E5LineEdit.setInactiveText">setInactiveText</a></td>
 <td>Public method to set the inactive text.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.setWidgetSpacing">setWidgetSpacing</a></td>
+<td>Public method to set the side widget spacing.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.textMargin">textMargin</a></td>
+<td>Public method to get the text margin for a side.</td>
+</tr><tr>
+<td><a href="#E5LineEdit.widgetSpacing">widgetSpacing</a></td>
+<td>Public method to get the side widget spacing.</td>
 </tr>
 </table>
 <a NAME="E5LineEdit.__init__" ID="E5LineEdit.__init__"></a>
@@ -80,6 +110,44 @@
 <dd>
 text to be shown on inactivity (string)
 </dd>
+</dl><a NAME="E5LineEdit.__updateSideWidgetLocations" ID="E5LineEdit.__updateSideWidgetLocations"></a>
+<h4>E5LineEdit.__updateSideWidgetLocations</h4>
+<b>__updateSideWidgetLocations</b>(<i></i>)
+<p>
+        Private method to update the side widget locations.
+</p><a NAME="E5LineEdit._updateTextMargins" ID="E5LineEdit._updateTextMargins"></a>
+<h4>E5LineEdit._updateTextMargins</h4>
+<b>_updateTextMargins</b>(<i></i>)
+<p>
+        Protected slot to update the text margins.
+</p><a NAME="E5LineEdit.addWidget" ID="E5LineEdit.addWidget"></a>
+<h4>E5LineEdit.addWidget</h4>
+<b>addWidget</b>(<i>widget, position</i>)
+<p>
+        Public method to add a widget to a side.
+</p><dl>
+<dt><i>widget</i></dt>
+<dd>
+reference to the widget to add (QWidget)
+</dd><dt><i>position</i></dt>
+<dd>
+position to add to (E5LineEdit.LeftSide, E5LineEdit.RightSide)
+</dd>
+</dl><a NAME="E5LineEdit.event" ID="E5LineEdit.event"></a>
+<h4>E5LineEdit.event</h4>
+<b>event</b>(<i>evt</i>)
+<p>
+        Protected method to handle events.
+</p><dl>
+<dt><i>reference</i></dt>
+<dd>
+to the event (QEvent)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating, whether the event was recognized (boolean)
+</dd>
 </dl><a NAME="E5LineEdit.inactiveText" ID="E5LineEdit.inactiveText"></a>
 <h4>E5LineEdit.inactiveText</h4>
 <b>inactiveText</b>(<i></i>)
@@ -97,6 +165,26 @@
 <dd>
 reference to the paint event (QPaintEvent)
 </dd>
+</dl><a NAME="E5LineEdit.removeWidget" ID="E5LineEdit.removeWidget"></a>
+<h4>E5LineEdit.removeWidget</h4>
+<b>removeWidget</b>(<i>widget</i>)
+<p>
+        Public method to remove a widget from a side.
+</p><dl>
+<dt><i>widget</i></dt>
+<dd>
+reference to the widget to remove (QWidget)
+</dd>
+</dl><a NAME="E5LineEdit.resizeEvent" ID="E5LineEdit.resizeEvent"></a>
+<h4>E5LineEdit.resizeEvent</h4>
+<b>resizeEvent</b>(<i>evt</i>)
+<p>
+        Protected method to handle resize events.
+</p><dl>
+<dt><i>evt</i></dt>
+<dd>
+reference to the resize event (QResizeEvent)
+</dd>
 </dl><a NAME="E5LineEdit.setInactiveText" ID="E5LineEdit.setInactiveText"></a>
 <h4>E5LineEdit.setInactiveText</h4>
 <b>setInactiveText</b>(<i>inactiveText</i>)
@@ -107,6 +195,85 @@
 <dd>
 text to be shown on inactivity (string)
 </dd>
+</dl><a NAME="E5LineEdit.setWidgetSpacing" ID="E5LineEdit.setWidgetSpacing"></a>
+<h4>E5LineEdit.setWidgetSpacing</h4>
+<b>setWidgetSpacing</b>(<i>spacing</i>)
+<p>
+        Public method to set the side widget spacing.
+</p><dl>
+<dt><i>spacing</i></dt>
+<dd>
+side widget spacing (integer)
+</dd>
+</dl><a NAME="E5LineEdit.textMargin" ID="E5LineEdit.textMargin"></a>
+<h4>E5LineEdit.textMargin</h4>
+<b>textMargin</b>(<i>position</i>)
+<p>
+        Public method to get the text margin for a side.
+</p><dl>
+<dt><i>position</i></dt>
+<dd>
+side to get margin for (E5LineEdit.LeftSide, E5LineEdit.RightSide)
+</dd>
+</dl><a NAME="E5LineEdit.widgetSpacing" ID="E5LineEdit.widgetSpacing"></a>
+<h4>E5LineEdit.widgetSpacing</h4>
+<b>widgetSpacing</b>(<i></i>)
+<p>
+        Public method to get the side widget spacing.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+side widget spacing (integer)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
+<a NAME="SideWidget" ID="SideWidget"></a>
+<h2>SideWidget</h2>
+<p>
+    Class implementing the side widgets for the line edit class.
+</p>
+<h3>Derived from</h3>
+QWidget
+<h3>Class Attributes</h3>
+<table>
+<tr><td>sizeHintChanged</td></tr>
+</table>
+<h3>Methods</h3>
+<table>
+<tr>
+<td><a href="#SideWidget.__init__">SideWidget</a></td>
+<td>Constructor</td>
+</tr><tr>
+<td><a href="#SideWidget.event">event</a></td>
+<td>Protected method to handle events.</td>
+</tr>
+</table>
+<a NAME="SideWidget.__init__" ID="SideWidget.__init__"></a>
+<h4>SideWidget (Constructor)</h4>
+<b>SideWidget</b>(<i>parent = None</i>)
+<p>
+        Constructor
+</p><dl>
+<dt><i>parent</i></dt>
+<dd>
+reference to the parent widget (QWidget)
+</dd>
+</dl><a NAME="SideWidget.event" ID="SideWidget.event"></a>
+<h4>SideWidget.event</h4>
+<b>event</b>(<i>evt</i>)
+<p>
+        Protected method to handle events.
+</p><dl>
+<dt><i>reference</i></dt>
+<dd>
+to the event (QEvent)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating, whether the event was recognized (boolean)
+</dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Documentation/Source/eric5.E5Gui.E5LineEditButton.html	Sun Sep 26 20:25:09 2010 +0200
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
+'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
+<html><head>
+<title>eric5.E5Gui.E5LineEditButton</title>
+<style>
+body {
+    background: #EDECE6;
+    margin: 0em 1em 10em 1em;
+    color: black;
+}
+
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
+    
+a { color: #BA6D36; }
+
+</style>
+</head>
+<body><a NAME="top" ID="top"></a>
+<h1>eric5.E5Gui.E5LineEditButton</h1>
+<p>
+Module implementing a button class to be used with E5LineEdit.
+</p>
+<h3>Global Attributes</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<h3>Classes</h3>
+<table>
+<tr>
+<td><a href="#E5LineEditButton">E5LineEditButton</a></td>
+<td>Class implementing a button to be used with E5LineEdit.</td>
+</tr>
+</table>
+<h3>Functions</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<hr /><hr />
+<a NAME="E5LineEditButton" ID="E5LineEditButton"></a>
+<h2>E5LineEditButton</h2>
+<p>
+    Class implementing a button to be used with E5LineEdit.
+</p>
+<h3>Derived from</h3>
+QAbstractButton
+<h3>Class Attributes</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<h3>Methods</h3>
+<table>
+<tr>
+<td><a href="#E5LineEditButton.__init__">E5LineEditButton</a></td>
+<td>Constructor</td>
+</tr><tr>
+<td><a href="#E5LineEditButton.__clicked">__clicked</a></td>
+<td>Private slot to handle a button click.</td>
+</tr><tr>
+<td><a href="#E5LineEditButton.menu">menu</a></td>
+<td>Public method to get a reference to the menu.</td>
+</tr><tr>
+<td><a href="#E5LineEditButton.paintEvent">paintEvent</a></td>
+<td>Protected method handling a paint event.</td>
+</tr><tr>
+<td><a href="#E5LineEditButton.setIcon">setIcon</a></td>
+<td>Public method to set the button icon.</td>
+</tr><tr>
+<td><a href="#E5LineEditButton.setMenu">setMenu</a></td>
+<td>Public method to set the button menu.</td>
+</tr>
+</table>
+<a NAME="E5LineEditButton.__init__" ID="E5LineEditButton.__init__"></a>
+<h4>E5LineEditButton (Constructor)</h4>
+<b>E5LineEditButton</b>(<i>parent = None</i>)
+<p>
+        Constructor
+</p><dl>
+<dt><i>parent</i></dt>
+<dd>
+reference to the parent widget (QWidget)
+</dd>
+</dl><a NAME="E5LineEditButton.__clicked" ID="E5LineEditButton.__clicked"></a>
+<h4>E5LineEditButton.__clicked</h4>
+<b>__clicked</b>(<i></i>)
+<p>
+        Private slot to handle a button click.
+</p><a NAME="E5LineEditButton.menu" ID="E5LineEditButton.menu"></a>
+<h4>E5LineEditButton.menu</h4>
+<b>menu</b>(<i></i>)
+<p>
+        Public method to get a reference to the menu.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+reference to the associated menu (QMenu)
+</dd>
+</dl><a NAME="E5LineEditButton.paintEvent" ID="E5LineEditButton.paintEvent"></a>
+<h4>E5LineEditButton.paintEvent</h4>
+<b>paintEvent</b>(<i>evt</i>)
+<p>
+        Protected method handling a paint event.
+</p><dl>
+<dt><i>evt</i></dt>
+<dd>
+reference to the paint event (QPaintEvent)
+</dd>
+</dl><a NAME="E5LineEditButton.setIcon" ID="E5LineEditButton.setIcon"></a>
+<h4>E5LineEditButton.setIcon</h4>
+<b>setIcon</b>(<i>icon</i>)
+<p>
+        Public method to set the button icon.
+</p><dl>
+<dt><i>icon</i></dt>
+<dd>
+icon to be set (QIcon)
+</dd>
+</dl><a NAME="E5LineEditButton.setMenu" ID="E5LineEditButton.setMenu"></a>
+<h4>E5LineEditButton.setMenu</h4>
+<b>setMenu</b>(<i>menu</i>)
+<p>
+        Public method to set the button menu.
+</p><dl>
+<dt><i>menu</i></dt>
+<dd>
+reference to the menu (QMenu)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+</body></html>
\ No newline at end of file
--- a/Documentation/Source/eric5.Helpviewer.HelpWebSearchWidget.html	Sun Sep 26 15:18:07 2010 +0200
+++ b/Documentation/Source/eric5.Helpviewer.HelpWebSearchWidget.html	Sun Sep 26 20:25:09 2010 +0200
@@ -102,6 +102,9 @@
 <td><a href="#HelpWebSearchWidget.__showEnginesMenu">__showEnginesMenu</a></td>
 <td>Private slot to handle the display of the engines menu.</td>
 </tr><tr>
+<td><a href="#HelpWebSearchWidget.__textChanged">__textChanged</a></td>
+<td>Private slot to handle changes of the search text.</td>
+</tr><tr>
 <td><a href="#HelpWebSearchWidget.__textEdited">__textEdited</a></td>
 <td>Private slot to handle changes of the search text.</td>
 </tr><tr>
@@ -211,7 +214,17 @@
 <b>__showEnginesMenu</b>(<i></i>)
 <p>
         Private slot to handle the display of the engines menu.
-</p><a NAME="HelpWebSearchWidget.__textEdited" ID="HelpWebSearchWidget.__textEdited"></a>
+</p><a NAME="HelpWebSearchWidget.__textChanged" ID="HelpWebSearchWidget.__textChanged"></a>
+<h4>HelpWebSearchWidget.__textChanged</h4>
+<b>__textChanged</b>(<i>txt</i>)
+<p>
+        Private slot to handle changes of the search text.
+</p><dl>
+<dt><i>txt</i></dt>
+<dd>
+search text (string)
+</dd>
+</dl><a NAME="HelpWebSearchWidget.__textEdited" ID="HelpWebSearchWidget.__textEdited"></a>
 <h4>HelpWebSearchWidget.__textEdited</h4>
 <b>__textEdited</b>(<i>txt</i>)
 <p>
--- a/Documentation/Source/index-eric5.E5Gui.html	Sun Sep 26 15:18:07 2010 +0200
+++ b/Documentation/Source/index-eric5.E5Gui.html	Sun Sep 26 20:25:09 2010 +0200
@@ -49,6 +49,9 @@
 <td><a href="eric5.E5Gui.E5LineEdit.html">E5LineEdit</a></td>
 <td>Module implementing specialized line edits.</td>
 </tr><tr>
+<td><a href="eric5.E5Gui.E5LineEditButton.html">E5LineEditButton</a></td>
+<td>Module implementing a button class to be used with E5LineEdit.</td>
+</tr><tr>
 <td><a href="eric5.E5Gui.E5ListView.html">E5ListView</a></td>
 <td>Module implementing specialized list views.</td>
 </tr><tr>
--- a/E5Gui/E5LineEdit.py	Sun Sep 26 15:18:07 2010 +0200
+++ b/E5Gui/E5LineEdit.py	Sun Sep 26 20:25:09 2010 +0200
@@ -7,13 +7,42 @@
 Module implementing specialized line edits. 
 """
 
-from PyQt4.QtCore import Qt
-from PyQt4.QtGui import QLineEdit, QStyleOptionFrameV2, QStyle, QPainter, QPalette
+from PyQt4.QtCore import pyqtSignal, Qt, QEvent
+from PyQt4.QtGui import QLineEdit, QStyleOptionFrameV2, QStyle, QPainter, QPalette, \
+    QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy
+
+class SideWidget(QWidget):
+    """
+    Class implementing the side widgets for the line edit class.
+    """
+    sizeHintChanged = pyqtSignal()
+    
+    def __init__(self, parent = None):
+        """
+        Constructor
+        
+        @param parent reference to the parent widget (QWidget)
+        """
+        QWidget.__init__(self, parent)
+    
+    def event(self, evt):
+        """
+        Protected method to handle events.
+        
+        @param reference to the event (QEvent)
+        @return flag indicating, whether the event was recognized (boolean)
+        """
+        if evt.type() == QEvent.LayoutRequest:
+            self.sizeHintChanged.emit()
+        return QWidget.event(self, evt)
 
 class E5LineEdit(QLineEdit):
     """
     Class implementing a line edit widget showing some inactive text.
     """
+    LeftSide  = 0
+    RightSide = 1
+    
     def __init__(self, parent = None, inactiveText = ""):
         """
         Constructor
@@ -23,7 +52,184 @@
         """
         QLineEdit.__init__(self, parent)
         
+        self.setMinimumHeight(22)
+        
         self.__inactiveText = inactiveText
+        
+        self.__leftWidget = SideWidget(self)
+        self.__leftWidget.resize(0, 0)
+        self.__leftLayout = QHBoxLayout(self.__leftWidget)
+        self.__leftLayout.setContentsMargins(0, 0, 0, 0)
+        if QApplication.isRightToLeft():
+            self.__leftLayout.setDirection(QBoxLayout.RightToLeft)
+        else:
+            self.__leftLayout.setDirection(QBoxLayout.LeftToRight)
+        self.__leftLayout.setSizeConstraint(QLayout.SetFixedSize)
+        
+        self.__rightWidget = SideWidget(self)
+        self.__rightWidget.resize(0, 0)
+        self.__rightLayout = QHBoxLayout(self.__rightWidget)
+        self.__rightLayout.setContentsMargins(0, 0, 0, 0)
+        if self.isRightToLeft():
+            self.__rightLayout.setDirection(QBoxLayout.RightToLeft)
+        else:
+            self.__rightLayout.setDirection(QBoxLayout.LeftToRight)
+        horizontalSpacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
+        self.__rightLayout.addItem(horizontalSpacer)
+        
+        self.setWidgetSpacing(3)
+        self.__leftWidget.sizeHintChanged.connect(self._updateTextMargins)
+        self.__rightWidget.sizeHintChanged.connect(self._updateTextMargins)
+    
+    def event(self, evt):
+        """
+        Protected method to handle events.
+        
+        @param reference to the event (QEvent)
+        @return flag indicating, whether the event was recognized (boolean)
+        """
+        if evt.type() == QEvent.LayoutDirectionChange:
+            if self.isRightToLeft():
+                self.__leftLayout.setDirection(QBoxLayout.RightToLeft)
+                self.__rightLayout.setDirection(QBoxLayout.RightToLeft)
+            else:
+                self.__leftLayout.setDirection(QBoxLayout.LeftToRight)
+                self.__rightLayout.setDirection(QBoxLayout.LeftToRight)
+        return QLineEdit.event(self, evt)
+    
+    def resizeEvent(self, evt):
+        """
+        Protected method to handle resize events.
+        
+        @param evt reference to the resize event (QResizeEvent)
+        """
+        self.__updateSideWidgetLocations()
+        QLineEdit.resizeEvent(self, evt)
+    
+    def paintEvent(self, evt):
+        """
+        Protected method handling a paint event.
+        
+        @param evt reference to the paint event (QPaintEvent)
+        """
+        QLineEdit.paintEvent(self, evt)
+        if not self.text() and \
+           self.__inactiveText and \
+           not self.hasFocus():
+            panel = QStyleOptionFrameV2()
+            self.initStyleOption(panel)
+            textRect = \
+                self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
+            textRect.adjust(2, 0, 0, 0)
+            left = self.textMargin(self.LeftSide)
+            right = self.textMargin(self.RightSide)
+            textRect.adjust(left, 0, -right, 0)
+            painter = QPainter(self)
+            painter.setPen(self.palette().brush(QPalette.Disabled, QPalette.Text).color())
+            painter.drawText(
+                textRect, Qt.AlignLeft | Qt.AlignVCenter, self.__inactiveText)
+    
+    def __updateSideWidgetLocations(self):
+        """
+        Private method to update the side widget locations.
+        """
+        opt = QStyleOptionFrameV2()
+        self.initStyleOption(opt)
+        textRect = \
+            self.style().subElementRect(QStyle.SE_LineEditContents, opt, self)
+        textRect.adjust(2, 0, 0, 0)
+        
+        left = self.textMargin(self.LeftSide)
+        
+        midHeight = textRect.center().y() + 1
+        
+        if self.__leftLayout.count() > 0:
+            leftHeight = midHeight - self.__leftWidget.height() // 2
+            leftWidth = self.__leftWidget.width()
+            if leftWidth == 0:
+                leftHeight = midHeight - self.__leftWidget.sizeHint().height() // 2
+            self.__leftWidget.move(textRect.x(), leftHeight)
+        
+        textRect.setX(left)
+        textRect.setY(midHeight - self.__rightWidget.sizeHint().height() // 2)
+        textRect.setHeight(self.__rightWidget.sizeHint().height())
+        self.__rightWidget.setGeometry(textRect)
+    
+    def _updateTextMargins(self):
+        """
+        Protected slot to update the text margins.
+        """
+        left = self.textMargin(self.LeftSide)
+        right = self.textMargin(self.RightSide)
+        self.setTextMargins(left, 0, right, 0)
+        self.__updateSideWidgetLocations()
+    
+    def addWidget(self, widget, position):
+        """
+        Public method to add a widget to a side.
+        
+        @param widget reference to the widget to add (QWidget)
+        @param position position to add to (E5LineEdit.LeftSide, E5LineEdit.RightSide)
+        """
+        if widget is None:
+            return
+        
+        if self.isRightToLeft():
+            if position == self.LeftSide:
+                position = self.RightSide
+            else:
+                position = self.LeftSide
+        if position == self.LeftSide:
+            self.__leftLayout.addWidget(widget)
+        else:
+            self.__rightLayout.insertWidget(1, widget)
+    
+    def removeWidget(self, widget):
+        """
+        Public method to remove a widget from a side.
+        
+        @param widget reference to the widget to remove (QWidget)
+        """
+        if widget is None:
+            return
+        
+        self.__leftLayout.removeWidget(widget)
+        self.__rightLayout.removeWidget(widget)
+        widget.hide()
+    
+    def widgetSpacing(self):
+        """
+        Public method to get the side widget spacing.
+        
+        @return side widget spacing (integer)
+        """
+        return self.__leftLayout.spacing()
+    
+    def setWidgetSpacing(self, spacing):
+        """
+        Public method to set the side widget spacing.
+        
+        @param spacing side widget spacing (integer)
+        """
+        self.__leftLayout.setSpacing(spacing)
+        self.__rightLayout.setSpacing(spacing)
+        self._updateTextMargins()
+    
+    def textMargin(self, position):
+        """
+        Public method to get the text margin for a side.
+        
+        @param position side to get margin for (E5LineEdit.LeftSide, E5LineEdit.RightSide)
+        """
+        spacing = self.__rightLayout.spacing()
+        w = 0
+        if position == self.LeftSide:
+            w = self.__leftWidget.sizeHint().width()
+        else:
+            w = self.__rightWidget.sizeHint().width()
+        if w == 0:
+            return 0
+        return w + spacing * 2
     
     def inactiveText(self):
         """
@@ -41,22 +247,3 @@
         """
         self.__inactiveText = inactiveText
         self.update()
-    
-    def paintEvent(self, evt):
-        """
-        Protected method handling a paint event.
-        
-        @param evt reference to the paint event (QPaintEvent)
-        """
-        QLineEdit.paintEvent(self, evt)
-        if not self.text() and \
-           self.__inactiveText and \
-           not self.hasFocus():
-            panel = QStyleOptionFrameV2()
-            self.initStyleOption(panel)
-            textRect = \
-                self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
-            textRect.adjust(2, 0, 0, 0)
-            painter = QPainter(self)
-            painter.setPen(self.palette().brush(QPalette.Disabled, QPalette.Text).color())
-            painter.drawText(textRect, Qt.AlignLeft | Qt.AlignVCenter, self.__inactiveText)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/E5Gui/E5LineEditButton.py	Sun Sep 26 20:25:09 2010 +0200
@@ -0,0 +1,94 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a button class to be used with E5LineEdit.
+"""
+
+from PyQt4.QtCore import Qt, QPoint, QPointF
+from PyQt4.QtGui import QAbstractButton, QPainter, QPainterPath
+
+class E5LineEditButton(QAbstractButton):
+    """
+    Class implementing a button to be used with E5LineEdit.
+    """
+    def __init__(self, parent = None):
+        """
+        Constructor
+        
+        @param parent reference to the parent widget (QWidget)
+        """
+        QAbstractButton.__init__(self, parent)
+        
+        self.__menu = None
+        self.__image = None
+        
+        self.setFocusPolicy(Qt.NoFocus)
+        self.setCursor(Qt.ArrowCursor)
+        self.setMinimumSize(16, 16)
+        
+        self.clicked[()].connect(self.__clicked)
+    
+    def setMenu(self, menu):
+        """
+        Public method to set the button menu.
+        
+        @param menu reference to the menu (QMenu)
+        """
+        self.__menu = menu
+        self.update()
+    
+    def menu(self):
+        """
+        Public method to get a reference to the menu.
+        
+        @return reference to the associated menu (QMenu)
+        """
+        return self.__menu
+    
+    def setIcon(self, icon):
+        """
+        Public method to set the button icon.
+        
+        @param icon icon to be set (QIcon)
+        """
+        if icon.isNull():
+            self.__image = None
+        else:
+            self.__image = icon.pixmap(16, 16).toImage()
+        QAbstractButton.setIcon(self, icon)
+    
+    def __clicked(self):
+        """
+        Private slot to handle a button click.
+        """
+        if self.__menu:
+            pos = self.mapToGlobal(QPoint(0, self.height()))
+            self.__menu.exec_(pos)
+    
+    def paintEvent(self, evt):
+        """
+        Protected method handling a paint event.
+        
+        @param evt reference to the paint event (QPaintEvent)
+        """
+        painter = QPainter(self)
+        
+        if self.__image is not None and not self.__image.isNull():
+            x = (self.width() - self.__image.width()) // 2 - 1
+            y = (self.height() - self.__image.height()) // 2 - 1
+            painter.drawImage(x, y, self.__image)
+        
+        if self.__menu is not None:
+            triagPath = QPainterPath()
+            startPos = QPointF(self.width() - 5, self.height() - 3)
+            triagPath.moveTo(startPos)
+            triagPath.lineTo(startPos.x() + 4, startPos.y())
+            triagPath.lineTo(startPos.x() + 2, startPos.y() + 2)
+            triagPath.closeSubpath()
+            painter.setPen(Qt.black)
+            painter.setBrush(Qt.black)
+            painter.setRenderHint(QPainter.Antialiasing, False)
+            painter.drawPath(triagPath)
--- a/Helpviewer/HelpWebSearchWidget.py	Sun Sep 26 15:18:07 2010 +0200
+++ b/Helpviewer/HelpWebSearchWidget.py	Sun Sep 26 20:25:09 2010 +0200
@@ -16,6 +16,7 @@
 import Preferences
 
 from E5Gui.E5LineEdit import E5LineEdit
+from E5Gui.E5LineEditButton import E5LineEditButton
 
 from .OpenSearch.OpenSearchManager import OpenSearchManager
 from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction
@@ -50,21 +51,21 @@
         
         self.__enginesMenu = QMenu(self)
         
-        self.__engineButton = QToolButton(self)
-        self.__engineButton.setPopupMode(QToolButton.InstantPopup)
-        self.__engineButton.setMenu(self.__enginesMenu)
-        self.__layout.addWidget(self.__engineButton)
-        
-        self.__searchButton = QToolButton(self)
-        self.__searchButton.setIcon(UI.PixmapCache.getIcon("webSearch.png"))
-        self.__layout.addWidget(self.__searchButton)
-        
         self.__searchEdit = E5LineEdit(parent = self)
         self.__layout.addWidget(self.__searchEdit)
         
-        self.__clearButton = QToolButton(self)
+        self.__engineButton = E5LineEditButton(self)
+        self.__engineButton.setMenu(self.__enginesMenu)
+        self.__searchEdit.addWidget(self.__engineButton, E5LineEdit.LeftSide)
+        
+        self.__searchButton = E5LineEditButton(self)
+        self.__searchButton.setIcon(UI.PixmapCache.getIcon("webSearch.png"))
+        self.__searchEdit.addWidget(self.__searchButton, E5LineEdit.LeftSide)
+        
+        self.__clearButton = E5LineEditButton(self)
         self.__clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png"))
-        self.__layout.addWidget(self.__clearButton)
+        self.__searchEdit.addWidget(self.__clearButton, E5LineEdit.RightSide)
+        self.__clearButton.setVisible(False)
         
         self.__model = QStandardItemModel(self)
         self.__completer = QCompleter()
@@ -73,8 +74,9 @@
         self.__completer.setWidget(self.__searchEdit)
         
         self.__searchButton.clicked[()].connect(self.__searchButtonClicked)
+        self.__clearButton.clicked[()].connect(self.__searchEdit.clear)
         self.__searchEdit.textEdited.connect(self.__textEdited)
-        self.__clearButton.clicked[()].connect(self.__searchEdit.clear)
+        self.__searchEdit.textChanged.connect(self.__textChanged)
         self.__searchEdit.returnPressed[()].connect(self.__searchNow)
         self.__completer.activated[QModelIndex].connect(self.__completerActivated)
         self.__completer.highlighted[QModelIndex].connect(self.__completerHighlighted)
@@ -207,6 +209,14 @@
             self.__completer.setCompletionPrefix(txt)
             self.__completer.complete()
     
+    def __textChanged(self, txt):
+        """
+        Private slot to handle changes of the search text.
+        
+        @param txt search text (string)
+        """
+        self.__clearButton.setVisible(txt != "")
+    
     def __getSuggestions(self):
         """
         Private slot to get search suggestions from the configured search engine.
--- a/changelog	Sun Sep 26 15:18:07 2010 +0200
+++ b/changelog	Sun Sep 26 20:25:09 2010 +0200
@@ -4,6 +4,7 @@
 - bug fixes
 - added configuration options for the web browser cache policy
 - added tab previews to the web browser
+- added a line widget with embeddable buttons
 
 Version 5.1-snapshot-20100918:
 - bug fixes
--- a/eric5.e4p	Sun Sep 26 15:18:07 2010 +0200
+++ b/eric5.e4p	Sun Sep 26 20:25:09 2010 +0200
@@ -818,6 +818,7 @@
     <Source>Helpviewer/HelpTabBar.py</Source>
     <Source>Helpviewer/HelpSnap.py</Source>
     <Source>Helpviewer/HelpTabWidget.py</Source>
+    <Source>E5Gui/E5LineEditButton.py</Source>
   </Sources>
   <Forms>
     <Form>PyUnit/UnittestDialog.ui</Form>

eric ide

mercurial