Revision
14485
Author
jmesquita
Date
2009-08-11 00:17:14 -0500 (Tue, 11 Aug 2009)

Log Message

Add basic find feature.

Modified Paths

Added Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/centralWidget.ui	2009-08-11 05:17:14 UTC (rev 14485)
@@ -69,7 +69,6 @@
     <property name="title">
      <string>&amp;Edit</string>
     </property>
-    <addaction name="action_Find"/>
     <addaction name="action_Clear"/>
     <addaction name="separator"/>
    </widget>
@@ -112,14 +111,6 @@
     <string>&amp;Clear</string>
    </property>
   </action>
-  <action name="action_Find">
-   <property name="text">
-    <string>&amp;Find</string>
-   </property>
-   <property name="visible">
-    <bool>false</bool>
-   </property>
-  </action>
  </widget>
  <resources>
   <include location="../../resources/resources.qrc"/>

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.cpp	2009-08-11 05:17:14 UTC (rev 14485)
@@ -25,8 +25,6 @@
                      this, SLOT(connect()));
     QObject::connect(consoleWindow->action_Disconnect, SIGNAL(triggered()),
                      this, SLOT(disconnect()));
-    QObject::connect(consoleWindow->action_Find, SIGNAL(triggered()),
-                     this, SLOT(find()));
     QObject::connect(consoleWindow->action_Clear, SIGNAL(triggered()),
                      this, SLOT(clearLogContents()));
 }
@@ -106,12 +104,6 @@
                      this, SLOT(newConnection()));
 }
 
-void ConsolePlugin::find()
-{
-   ConsoleTabWidget *tab = qobject_cast<ConsoleTabWidget*>(consoleWindow->tabConsole->currentWidget());
-   tab->find();
-}
-
 void ConsolePlugin::newConnection()
 {
     if (serverManager->exec())

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoleplugin.h	2009-08-11 05:17:14 UTC (rev 14485)
@@ -28,7 +28,6 @@
     void setServerManager(ServerManager *manager);
 
 private slots:
-    void find();
     void connectionStateChanged();
     void connect();
     void disconnect();

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.cpp	2009-08-11 05:17:14 UTC (rev 14485)
@@ -5,7 +5,8 @@
 ConsoleTabWidget::ConsoleTabWidget(QWidget *parent, ESLconnection *eslconnection) :
     QWidget(parent),
     m_ui(new Ui::ConsoleTabWidget),
-    esl(eslconnection)
+    esl(eslconnection),
+    findNext(false)
 {
     m_ui->setupUi(this);
     sourceModel = new QStandardItemModel(this);
@@ -33,6 +34,11 @@
     QObject::connect(m_ui->checkDebug, SIGNAL(clicked(bool)),
                      this, SLOT(checkDebug(bool)));
 
+    QObject::connect(m_ui->btnFind, SIGNAL(clicked()),
+                     this, SLOT(find()));
+    QObject::connect(m_ui->lineFind, SIGNAL(textChanged(QString)),
+                     this, SLOT(findStringChanged(QString)));
+
     QObject::connect(esl, SIGNAL(connected()),
                      this, SLOT(connected()));
     QObject::connect(esl, SIGNAL(connectionFailed(QString)),
@@ -69,8 +75,47 @@
 
 void ConsoleTabWidget::find()
 {
+    if (m_ui->lineFind->text().isEmpty())
+        return;
+
+    QModelIndexList index;
+    if (m_ui->consoleListView->currentIndex().isValid())
+    {
+        index = model->match(m_ui->consoleListView->currentIndex(), Qt::DisplayRole, m_ui->lineFind->text(), -1, Qt::MatchContains|Qt::MatchWrap);
+    }
+    else
+    {
+        index =  model->match(model->index(0,0), Qt::DisplayRole, m_ui->lineFind->text(), -1, Qt::MatchContains|Qt::MatchWrap);
+    }
+
+    if (index.isEmpty())
+    {
+        QMessageBox::warning(this, tr("No match"), tr("No match found!"));
+    }
+    else
+    {
+        if (findNext == true && index.count() > 1)
+        {
+            m_ui->consoleListView->scrollTo(index.at(1));
+            m_ui->consoleListView->setCurrentIndex(index.at(1));
+        }
+        else
+        {
+            m_ui->consoleListView->scrollTo(index.at(0));
+            m_ui->consoleListView->setCurrentIndex(index.at(0));
+        }
+        findNext = true;
+        m_ui->btnFind->setText(tr("Find Next"));
+    }
 }
 
+void ConsoleTabWidget::findStringChanged(QString findString)
+{
+    m_ui->btnFind->setDisabled(findString.isEmpty());
+    m_ui->btnFind->setText(tr("Find"));
+    findNext = false;
+}
+
 void ConsoleTabWidget::connected()
 {
     m_ui->btnSend->setEnabled(true);

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.h	2009-08-11 05:17:14 UTC (rev 14485)
@@ -18,7 +18,6 @@
 public:
     ConsoleTabWidget(QWidget *parent, ESLconnection *eslconnection);
     ~ConsoleTabWidget();
-    void find();
 
 public slots:
     void clearConsoleContents();
@@ -27,6 +26,8 @@
     void changeEvent(QEvent *e);
 
 private slots:
+    void find();
+    void findStringChanged(QString);
     void connected();
     void disconnected();
     void connectionFailed(QString);
@@ -45,8 +46,10 @@
 private:
     Ui::ConsoleTabWidget *m_ui;
     QStandardItemModel *sourceModel;
+    QModelIndexList foundItems;
     SortFilterProxyModel *model;
     ESLconnection *esl;
+    bool findNext;
 };
 
 #endif // CONSOLETABWIDGET_H

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.ui (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.ui	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/consoletabwidget.ui	2009-08-11 05:17:14 UTC (rev 14485)
@@ -6,183 +6,209 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>391</width>
-    <height>344</height>
+    <width>630</width>
+    <height>499</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_3">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
-    <layout class="QVBoxLayout" name="verticalLayout_2">
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Find</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_3">
+      <item>
+       <widget class="QLineEdit" name="lineFind"/>
+      </item>
+      <item>
+       <widget class="QPushButton" name="btnFind">
+        <property name="enabled">
+         <bool>false</bool>
+        </property>
+        <property name="text">
+         <string>Find</string>
+        </property>
+        <property name="icon">
+         <iconset resource="../../resources/resources.qrc">
+          <normaloff>:/icons/find_icon.png</normaloff>:/icons/find_icon.png</iconset>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
-      <layout class="QHBoxLayout" name="horizontalLayout_2">
-       <item>
-        <widget class="QListView" name="consoleListView"/>
-       </item>
-       <item>
-        <widget class="QGroupBox" name="groupBox">
-         <property name="maximumSize">
-          <size>
-           <width>120</width>
-           <height>16777215</height>
-          </size>
-         </property>
-         <property name="title">
-          <string>Log Level</string>
-         </property>
-         <layout class="QVBoxLayout" name="verticalLayout">
-          <item>
-           <widget class="QCheckBox" name="checkEmerg">
-            <property name="text">
-             <string>Console</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkAlert">
-            <property name="text">
-             <string>Alert</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkCrit">
-            <property name="text">
-             <string>Critical</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkError">
-            <property name="text">
-             <string>Error</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkWarn">
-            <property name="text">
-             <string>Warning</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkNotice">
-            <property name="text">
-             <string>Notice</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkInfo">
-            <property name="text">
-             <string>Info</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QCheckBox" name="checkDebug">
-            <property name="text">
-             <string>Debug</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <spacer name="verticalSpacer">
-            <property name="orientation">
-             <enum>Qt::Vertical</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>20</width>
-              <height>18</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </widget>
-       </item>
-      </layout>
+      <widget class="QListView" name="consoleListView"/>
      </item>
      <item>
-      <layout class="QHBoxLayout" name="horizontalLayout">
-       <item>
-        <widget class="QLineEdit" name="lineCmd">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>16777215</width>
-           <height>26</height>
-          </size>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="btnSend">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>28</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>85</width>
-           <height>28</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>Send</string>
-         </property>
-         <property name="shortcut">
-          <string>Return</string>
-         </property>
-         <property name="autoDefault">
-          <bool>true</bool>
-         </property>
-         <property name="default">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-      </layout>
+      <widget class="QGroupBox" name="groupBox">
+       <property name="maximumSize">
+        <size>
+         <width>120</width>
+         <height>16777215</height>
+        </size>
+       </property>
+       <property name="title">
+        <string>Log Level</string>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout">
+        <item>
+         <widget class="QCheckBox" name="checkEmerg">
+          <property name="text">
+           <string>Console</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkAlert">
+          <property name="text">
+           <string>Alert</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkCrit">
+          <property name="text">
+           <string>Critical</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkError">
+          <property name="text">
+           <string>Error</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkWarn">
+          <property name="text">
+           <string>Warning</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkNotice">
+          <property name="text">
+           <string>Notice</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkInfo">
+          <property name="text">
+           <string>Info</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkDebug">
+          <property name="text">
+           <string>Debug</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="verticalSpacer">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>20</width>
+            <height>18</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </widget>
      </item>
     </layout>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLineEdit" name="lineCmd">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>16777215</width>
+         <height>26</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="btnSend">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>28</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>85</width>
+         <height>28</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Send</string>
+       </property>
+       <property name="shortcut">
+        <string>Return</string>
+       </property>
+       <property name="autoDefault">
+        <bool>true</bool>
+       </property>
+       <property name="default">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
   </layout>
  </widget>
- <resources/>
+ <resources>
+  <include location="../../resources/resources.qrc"/>
+  <include location="../../resources/resources.qrc"/>
+  <include location="../../resources/resources.qrc"/>
+ </resources>
  <connections/>
 </ui>

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/resources/find_icon.png


(Binary files differ)
Property changes on: freeswitch/trunk/contrib/jmesquita/fsgui/src/resources/find_icon.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/resources/resources.qrc (14484 => 14485)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/resources/resources.qrc	2009-08-11 01:26:51 UTC (rev 14484)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/resources/resources.qrc	2009-08-11 05:17:14 UTC (rev 14485)
@@ -7,5 +7,6 @@
         <file>save.png</file>
         <file>server_icon.png</file>
         <file>edit_icon.png</file>
+        <file>find_icon.png</file>
     </qresource>
 </RCC>