[QGIS Commit] r12126 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Nov 15 13:03:16 EST 2009


Author: jef
Date: 2009-11-15 13:03:16 -0500 (Sun, 15 Nov 2009)
New Revision: 12126

Modified:
   trunk/qgis/src/app/qgspythondialog.cpp
   trunk/qgis/src/app/qgspythondialog.h
   trunk/qgis/src/ui/qgspythondialog.ui
Log:
add eval button to python console that evaluated single line commands and shows the result

Modified: trunk/qgis/src/app/qgspythondialog.cpp
===================================================================
--- trunk/qgis/src/app/qgspythondialog.cpp	2009-11-15 17:45:45 UTC (rev 12125)
+++ trunk/qgis/src/app/qgspythondialog.cpp	2009-11-15 18:03:16 UTC (rev 12126)
@@ -67,11 +67,11 @@
   }
 }
 
-void QgsPythonDialog::on_pbnExecute_clicked()
+void QgsPythonDialog::execute( bool single )
 {
   QString command = edtCmdLine->toPlainText();
 
-  QgsDebugMsg( QString( "command: |%1|" ).arg( command ) );
+  QgsDebugMsg( QString( "command: |%1| %2" ).arg( command ).arg( single ) );
 
   if ( !command.isEmpty() )
   {
@@ -83,7 +83,7 @@
 
   // when using Py_single_input the return value will be always null
   // we're using custom hooks for output and exceptions to show output in console
-  if ( mPythonUtils->runStringUnsafe( command, false ) )
+  if ( mPythonUtils->runStringUnsafe( command, single ) )
   {
     mPythonUtils->evalString( "sys.stdout.get_and_clean_data()", output );
     QString result = mPythonUtils->getResult();
@@ -112,6 +112,16 @@
   txtHistory->ensureCursorVisible();
 }
 
+void QgsPythonDialog::on_pbnExecute_clicked()
+{
+  execute( false );
+}
+
+void QgsPythonDialog::on_pbnEval_clicked()
+{
+  execute( true );
+}
+
 void QgsPythonDialog::showEvent( QShowEvent* event )
 {
   QDialog::showEvent( event );

Modified: trunk/qgis/src/app/qgspythondialog.h
===================================================================
--- trunk/qgis/src/app/qgspythondialog.h	2009-11-15 17:45:45 UTC (rev 12125)
+++ trunk/qgis/src/app/qgspythondialog.h	2009-11-15 18:03:16 UTC (rev 12126)
@@ -39,6 +39,7 @@
 
     void on_pbnPrev_clicked();
     void on_pbnExecute_clicked();
+    void on_pbnEval_clicked();
     void on_pbnNext_clicked();
 
   protected:
@@ -47,6 +48,7 @@
     void showEvent( QShowEvent *event );
 
   private:
+    void execute( bool single );
 
     QgisInterface* mIface;
     QgsPythonUtils* mPythonUtils;

Modified: trunk/qgis/src/ui/qgspythondialog.ui
===================================================================
--- trunk/qgis/src/ui/qgspythondialog.ui	2009-11-15 17:45:45 UTC (rev 12125)
+++ trunk/qgis/src/ui/qgspythondialog.ui	2009-11-15 18:03:16 UTC (rev 12126)
@@ -6,56 +6,82 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>483</width>
-    <height>305</height>
+    <width>625</width>
+    <height>641</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Python console</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="3" column="3">
-    <widget class="QPushButton" name="pbnExecute">
+   <item row="0" column="0" colspan="5">
+    <widget class="QLabel" name="lblInfo">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
      <property name="text">
-      <string>&amp;Execute</string>
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To access Quantum GIS environment from this python console use qgis.utils.iface object which is an instance of QgisInterface class.&lt;br /&gt;Usage e.g.: qgis.utils.iface.zoomFull()&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
      </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
-   <item row="2" column="3">
+   <item row="2" column="4">
     <widget class="QPushButton" name="pbnPrev">
      <property name="text">
       <string>&amp;Previous</string>
      </property>
+     <property name="shortcut">
+      <string comment="Ctrl+Up"/>
+     </property>
     </widget>
    </item>
-   <item row="4" column="3">
+   <item row="3" column="4">
+    <widget class="QPushButton" name="pbnExecute">
+     <property name="text">
+      <string>E&amp;xecute</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="4">
+    <widget class="QPushButton" name="pbnEval">
+     <property name="text">
+      <string>&amp;Eval</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="4">
     <widget class="QPushButton" name="pbnNext">
      <property name="text">
       <string>&amp;Next</string>
      </property>
+     <property name="shortcut">
+      <string/>
+     </property>
     </widget>
    </item>
-   <item row="0" column="0" colspan="4">
-    <widget class="QLabel" name="lblInfo">
+   <item row="2" column="1" rowspan="4" colspan="2">
+    <widget class="QLabel" name="lblPrompt">
      <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
      <property name="text">
-      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To access Quantum GIS environment from this python console use qgis.utils.iface object which is an instance of QgisInterface class.&lt;br /&gt;Usage e.g.: qgis.utils.iface.zoomFull()&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      <string>&gt;&gt;&gt;</string>
      </property>
-     <property name="wordWrap">
-      <bool>true</bool>
-     </property>
     </widget>
    </item>
-   <item row="1" column="0" colspan="4">
+   <item row="1" column="0" colspan="5">
     <widget class="QTextBrowser" name="txtHistory">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -67,25 +93,12 @@
       <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
 &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
 p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
 &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="1">
-    <widget class="QLabel" name="lblPrompt">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="text">
-      <string>&gt;&gt;&gt;</string>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="2" rowspan="3">
+   <item row="2" column="3" rowspan="4">
     <widget class="QTextEdit" name="edtCmdLine">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -98,10 +111,6 @@
   </layout>
  </widget>
  <tabstops>
-  <tabstop>edtCmdLine</tabstop>
-  <tabstop>pbnPrev</tabstop>
-  <tabstop>pbnExecute</tabstop>
-  <tabstop>pbnNext</tabstop>
   <tabstop>txtHistory</tabstop>
  </tabstops>
  <resources/>



More information about the QGIS-commit mailing list