Diff
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro (14283 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-17 20:42:24 UTC (rev 14283)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-17 20:54:08 UTC (rev 14284)
@@ -10,7 +10,8 @@
src/server_manager.cpp \
src/esl_connection.cpp \
src/consolepage.cpp \
- src/preferencesdialog.cpp
+ src/preferencesdialog.cpp \
+ src/completers.cpp
INCLUDEPATH += ../../../libs/esl/src/include \
src/include
HEADERS += src/include/fs_gui.h \
@@ -18,11 +19,12 @@
src/include/esl_connection.h \
src/include/consolepage.h \
src/include/global_defines.h \
- src/include/preferencesdialog.h
+ src/include/preferencesdialog.h \
+ src/include/completers.h
FORMS += resources/fs_gui.ui \
resources/server_manager.ui \
resources/consolepage.ui \
resources/preferencesdialog.ui
LIBS += -L../../../libs/esl \
-lesl
-RESOURCES += resources/images.qrc
+RESOURCES += resources/resources.qrc
Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/resources/images.qrc
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/resources/preferencesdialog.ui (14283 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/preferencesdialog.ui 2009-07-17 20:42:24 UTC (rev 14283)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/preferencesdialog.ui 2009-07-17 20:54:08 UTC (rev 14284)
@@ -47,7 +47,7 @@
<string>Console</string>
</property>
<property name="icon">
- <iconset resource="images.qrc">
+ <iconset resource="resources.qrc">
<normaloff>:/preferences/images/utilities-terminal.svg</normaloff>:/preferences/images/utilities-terminal.svg</iconset>
</property>
</item>
Added: freeswitch/trunk/contrib/jmesquita/fsgui/resources/resources.qrc (0 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/resources.qrc (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/resources.qrc 2009-07-17 20:54:08 UTC (rev 14284)
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/preferences" >
+ <file>images/utilities-terminal.svg</file>
+ </qresource>
+ <qresource prefix="/history" >
+ <file>history.txt</file>
+ </qresource>
+</RCC>
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp (0 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp 2009-07-17 20:54:08 UTC (rev 14284)
@@ -0,0 +1,51 @@
+#include <QtGui>
+#include "completers.h"
+
+cmdHistory::cmdHistory()
+{
+ this->setModel(modelFromFile(":/resources/history.txt"));
+}
+cmdHistory::~cmdHistory()
+{
+ writeHistoryFile(":/resources/history.txt");
+}
+void cmdHistory::addStringToModel(QString cmd)
+{
+ QStringList list = listModel->stringList();
+ if (!list.contains(cmd, Qt::CaseInsensitive))
+ list << cmd;
+
+ listModel->setStringList(list);
+ qDebug() << list;
+}
+QAbstractItemModel *cmdHistory::modelFromFile(const QString& fileName)
+ {
+ QFile file(fileName);
+ if (!file.open(QFile::ReadOnly))
+ {
+ listModel = new QStringListModel(this);
+ return listModel;
+ }
+
+ QStringList words;
+
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine();
+ if (!line.isEmpty())
+ words << line.trimmed();
+ }
+ listModel = new QStringListModel(words, this);
+ return listModel;
+ }
+void cmdHistory::writeHistoryFile(const QString& fileName)
+{
+ /*QFile file(fileName);
+ file.remove(fileName);
+ file.open(QFile::WriteOnly);
+ QStringList list = listModel->stringList();
+ for (int i = 0; i < list.size(); i++)
+ {
+ file.write(list[i].toAscii());
+ qDebug() << list[i];
+ }*/
+}
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (14283 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp 2009-07-17 20:42:24 UTC (rev 14283)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp 2009-07-17 20:54:08 UTC (rev 14284)
@@ -37,6 +37,7 @@
*/
#include <QtGui>
#include "consolepage.h"
+#include "completers.h"
#include "ui_consolepage.h"
#include "esl_connection.h"
#include "esl.h"
@@ -44,12 +45,14 @@
consolePage::consolePage(QWidget *parent) :
QWidget(parent),
- m_ui(new Ui::consolePage)
+ m_ui(new Ui::consolePage),
+ histCompleter(new cmdHistory)
{
m_ui->setupUi(this);
setConsoleBackground();
connect(m_ui->comboLogLevel, SIGNAL(currentIndexChanged(int)),
this, SLOT(loglevelChanged(int)));
+ m_ui->lineCmd->setCompleter(histCompleter);
}
consolePage::~consolePage()
{
@@ -60,6 +63,7 @@
eslConnection->wait();
}
delete eslConnection;
+ delete histCompleter;
delete m_ui;
}
void consolePage::setConsoleBackground()
@@ -137,6 +141,7 @@
}
ESLevent *e = new ESLevent(eslConnection->bgapi(cmdList[0].toAscii(), args.toAscii()));
gotEventSlot(e);
+ histCompleter->addStringToModel(m_ui->lineCmd->text());
m_ui->lineCmd->clear();
}
void consolePage::gotConnectedSlot()
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h (0 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h 2009-07-17 20:54:08 UTC (rev 14284)
@@ -0,0 +1,22 @@
+#ifndef COMPLETERS_H
+#define COMPLETERS_H
+
+#include <QCompleter>
+
+class QStringListModel;
+
+class cmdHistory : public QCompleter
+{
+ Q_OBJECT
+
+public:
+ cmdHistory();
+ ~cmdHistory();
+ void addStringToModel(QString);
+private:
+ QStringListModel *listModel;
+ QAbstractItemModel *modelFromFile(const QString& fileName);
+ void writeHistoryFile(const QString& fileName);
+};
+
+#endif // COMPLETERS_H
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (14283 => 14284)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h 2009-07-17 20:42:24 UTC (rev 14283)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h 2009-07-17 20:54:08 UTC (rev 14284)
@@ -1,7 +1,7 @@
#ifndef CONSOLEPAGE_H
#define CONSOLEPAGE_H
-#include <QtGui/QWidget>
+#include <QtGui>
namespace Ui {
class consolePage;
@@ -11,6 +11,7 @@
class ESLevent;
class ESLeventLog;
class ESLconnection;
+class cmdHistory;
class consolePage : public QWidget {
Q_OBJECT
@@ -38,9 +39,12 @@
private:
void writeSettings();
void readSettings();
+ QAbstractItemModel *modelFromFile(const QString& fileName);
Ui::consolePage *m_ui;
ESLconnection *eslConnection;
QString host;
+ cmdHistory *histCompleter;
+
};
#endif // CONSOLEPAGE_H