summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-10-24 20:40:24 (UTC)
committer wazlaf <wazlaf>2002-10-24 20:40:24 (UTC)
commit0fc598a0ee9151f82f5a78383645a758d5f6cad9 (patch) (side-by-side diff)
treed7b6df2344aafe89f914d796d941ef6fd705cff4
parentb3d13ad799eebbee3a1a73c4fe5b38167070ab87 (diff)
downloadopie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.zip
opie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.tar.gz
opie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.tar.bz2
only use .script files, set DocLnk names correctly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 888ab90..ccecdf8 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,22 +1,23 @@
#include <assert.h>
#include <qaction.h>
#include <qmenubar.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qtoolbar.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
+#include <qfileinfo.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpe/filemanager.h>
#include <qpe/mimetype.h>
#include <opie/ofiledialog.h>
#include "keytrans.h"
#include "profileeditordialog.h"
#include "configdialog.h"
#include "default.h"
@@ -132,24 +133,25 @@ static char * filesave_xpm[] = {
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++ ) {
KeyTrans* s = KeyTrans::find(i );
assert( s );
}
m_factory = new MetaFactory();
Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
m_manager = new ProfileManager( m_factory );
m_manager->load();
+ m_scriptsData.setAutoDelete(TRUE);
initUI();
populateProfiles();
populateScripts();
}
void MainWindow::initUI() {
setToolBarsMovable( FALSE );
/* tool bar for the menu */
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
@@ -349,26 +351,29 @@ void MainWindow::populateProfiles() {
m_sessionsPop->insertItem( (*it).name() );
}
}
void MainWindow::populateScripts() {
m_scriptsPop->clear();
m_scriptsData.clear();
DocLnkSet files(QPEApplication::documentDir(), "text/plain");
QListIterator<DocLnk> dit(files.children());
for (; dit.current(); ++dit) {
if (*dit && (*dit)->name().length()>0) {
- m_scriptsData.append((*dit));
- m_scriptsPop->insertItem((*dit)->name());
+ QFileInfo info((*dit)->file());
+ if (info.extension(false) == "script") {
+ m_scriptsData.append(new DocLnk(**dit));
+ m_scriptsPop->insertItem((*dit)->name());
+ }
}
}
}
MainWindow::~MainWindow() {
delete m_factory;
manager()->save();
}
MetaFactory* MainWindow::factory() {
return m_factory;
@@ -399,43 +404,46 @@ void MainWindow::slotRecordScript() {
m_recordScript->setEnabled(false);
}
}
void MainWindow::slotSaveScript() {
if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
QMap<QString, QStringList> map;
QStringList text;
text << "text/plain";
map.insert(tr("Script"), text );
QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
if (!filename.isEmpty()) {
+ QFileInfo info(filename);
+ if (info.extension(FALSE) != "script")
+ filename += ".script";
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filename);
- nf.setName(filename);
+ nf.setName(info.fileName());
FileManager fm;
fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
currentSession()->emulationHandler()->clearScript();
m_saveScript->setEnabled(false);
m_recordScript->setEnabled(true);
populateScripts();
}
}
}
void MainWindow::slotRunScript(int id) {
if (currentSession()) {
- DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id));
+ int index = m_scriptsPop->indexOf(id);
+ DocLnk *lnk = m_scriptsData.at(index);
QString filePath = lnk->file();
- printf("path is : %s\n", filePath.latin1());
Script script(filePath);
currentSession()->emulationHandler()->runScript(&script);
}
}
void MainWindow::slotConnect() {
if ( currentSession() ) {
bool ret = currentSession()->layer()->open();
if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
QObject::tr("Failed"),
QObject::tr("Connecting failed for this session."));
else {