author | wazlaf <wazlaf> | 2002-10-24 20:40:24 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-24 20:40:24 (UTC) |
commit | 0fc598a0ee9151f82f5a78383645a758d5f6cad9 (patch) (unidiff) | |
tree | d7b6df2344aafe89f914d796d941ef6fd705cff4 | |
parent | b3d13ad799eebbee3a1a73c4fe5b38167070ab87 (diff) | |
download | opie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.zip opie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.tar.gz opie-0fc598a0ee9151f82f5a78383645a758d5f6cad9.tar.bz2 |
only use .script files, set DocLnk names correctly
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 18 |
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 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qfileinfo.h> | ||
11 | 12 | ||
12 | #include <qpe/resource.h> | 13 | #include <qpe/resource.h> |
13 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
14 | #include <qpe/filemanager.h> | 15 | #include <qpe/filemanager.h> |
15 | #include <qpe/mimetype.h> | 16 | #include <qpe/mimetype.h> |
16 | 17 | ||
17 | #include <opie/ofiledialog.h> | 18 | #include <opie/ofiledialog.h> |
18 | 19 | ||
19 | #include "keytrans.h" | 20 | #include "keytrans.h" |
20 | #include "profileeditordialog.h" | 21 | #include "profileeditordialog.h" |
21 | #include "configdialog.h" | 22 | #include "configdialog.h" |
22 | #include "default.h" | 23 | #include "default.h" |
@@ -132,24 +133,25 @@ static char * filesave_xpm[] = { | |||
132 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 133 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
133 | KeyTrans::loadAll(); | 134 | KeyTrans::loadAll(); |
134 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 135 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
135 | KeyTrans* s = KeyTrans::find(i ); | 136 | KeyTrans* s = KeyTrans::find(i ); |
136 | assert( s ); | 137 | assert( s ); |
137 | } | 138 | } |
138 | m_factory = new MetaFactory(); | 139 | m_factory = new MetaFactory(); |
139 | Default def(m_factory); | 140 | Default def(m_factory); |
140 | m_sessions.setAutoDelete( TRUE ); | 141 | m_sessions.setAutoDelete( TRUE ); |
141 | m_curSession = 0; | 142 | m_curSession = 0; |
142 | m_manager = new ProfileManager( m_factory ); | 143 | m_manager = new ProfileManager( m_factory ); |
143 | m_manager->load(); | 144 | m_manager->load(); |
145 | m_scriptsData.setAutoDelete(TRUE); | ||
144 | 146 | ||
145 | initUI(); | 147 | initUI(); |
146 | populateProfiles(); | 148 | populateProfiles(); |
147 | populateScripts(); | 149 | populateScripts(); |
148 | } | 150 | } |
149 | void MainWindow::initUI() { | 151 | void MainWindow::initUI() { |
150 | setToolBarsMovable( FALSE ); | 152 | setToolBarsMovable( FALSE ); |
151 | 153 | ||
152 | /* tool bar for the menu */ | 154 | /* tool bar for the menu */ |
153 | m_tool = new QToolBar( this ); | 155 | m_tool = new QToolBar( this ); |
154 | m_tool->setHorizontalStretchable( TRUE ); | 156 | m_tool->setHorizontalStretchable( TRUE ); |
155 | 157 | ||
@@ -349,26 +351,29 @@ void MainWindow::populateProfiles() { | |||
349 | m_sessionsPop->insertItem( (*it).name() ); | 351 | m_sessionsPop->insertItem( (*it).name() ); |
350 | } | 352 | } |
351 | 353 | ||
352 | } | 354 | } |
353 | 355 | ||
354 | void MainWindow::populateScripts() { | 356 | void MainWindow::populateScripts() { |
355 | m_scriptsPop->clear(); | 357 | m_scriptsPop->clear(); |
356 | m_scriptsData.clear(); | 358 | m_scriptsData.clear(); |
357 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 359 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
358 | QListIterator<DocLnk> dit(files.children()); | 360 | QListIterator<DocLnk> dit(files.children()); |
359 | for (; dit.current(); ++dit) { | 361 | for (; dit.current(); ++dit) { |
360 | if (*dit && (*dit)->name().length()>0) { | 362 | if (*dit && (*dit)->name().length()>0) { |
361 | m_scriptsData.append((*dit)); | 363 | QFileInfo info((*dit)->file()); |
362 | m_scriptsPop->insertItem((*dit)->name()); | 364 | if (info.extension(false) == "script") { |
365 | m_scriptsData.append(new DocLnk(**dit)); | ||
366 | m_scriptsPop->insertItem((*dit)->name()); | ||
367 | } | ||
363 | } | 368 | } |
364 | } | 369 | } |
365 | 370 | ||
366 | } | 371 | } |
367 | 372 | ||
368 | MainWindow::~MainWindow() { | 373 | MainWindow::~MainWindow() { |
369 | delete m_factory; | 374 | delete m_factory; |
370 | manager()->save(); | 375 | manager()->save(); |
371 | } | 376 | } |
372 | 377 | ||
373 | MetaFactory* MainWindow::factory() { | 378 | MetaFactory* MainWindow::factory() { |
374 | return m_factory; | 379 | return m_factory; |
@@ -399,43 +404,46 @@ void MainWindow::slotRecordScript() { | |||
399 | m_recordScript->setEnabled(false); | 404 | m_recordScript->setEnabled(false); |
400 | } | 405 | } |
401 | } | 406 | } |
402 | 407 | ||
403 | void MainWindow::slotSaveScript() { | 408 | void MainWindow::slotSaveScript() { |
404 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 409 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
405 | QMap<QString, QStringList> map; | 410 | QMap<QString, QStringList> map; |
406 | QStringList text; | 411 | QStringList text; |
407 | text << "text/plain"; | 412 | text << "text/plain"; |
408 | map.insert(tr("Script"), text ); | 413 | map.insert(tr("Script"), text ); |
409 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 414 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
410 | if (!filename.isEmpty()) { | 415 | if (!filename.isEmpty()) { |
416 | QFileInfo info(filename); | ||
417 | if (info.extension(FALSE) != "script") | ||
418 | filename += ".script"; | ||
411 | DocLnk nf; | 419 | DocLnk nf; |
412 | nf.setType("text/plain"); | 420 | nf.setType("text/plain"); |
413 | nf.setFile(filename); | 421 | nf.setFile(filename); |
414 | nf.setName(filename); | 422 | nf.setName(info.fileName()); |
415 | FileManager fm; | 423 | FileManager fm; |
416 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 424 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
417 | currentSession()->emulationHandler()->clearScript(); | 425 | currentSession()->emulationHandler()->clearScript(); |
418 | m_saveScript->setEnabled(false); | 426 | m_saveScript->setEnabled(false); |
419 | m_recordScript->setEnabled(true); | 427 | m_recordScript->setEnabled(true); |
420 | populateScripts(); | 428 | populateScripts(); |
421 | } | 429 | } |
422 | } | 430 | } |
423 | } | 431 | } |
424 | 432 | ||
425 | void MainWindow::slotRunScript(int id) { | 433 | void MainWindow::slotRunScript(int id) { |
426 | if (currentSession()) { | 434 | if (currentSession()) { |
427 | DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id)); | 435 | int index = m_scriptsPop->indexOf(id); |
436 | DocLnk *lnk = m_scriptsData.at(index); | ||
428 | QString filePath = lnk->file(); | 437 | QString filePath = lnk->file(); |
429 | printf("path is : %s\n", filePath.latin1()); | ||
430 | Script script(filePath); | 438 | Script script(filePath); |
431 | currentSession()->emulationHandler()->runScript(&script); | 439 | currentSession()->emulationHandler()->runScript(&script); |
432 | } | 440 | } |
433 | } | 441 | } |
434 | 442 | ||
435 | void MainWindow::slotConnect() { | 443 | void MainWindow::slotConnect() { |
436 | if ( currentSession() ) { | 444 | if ( currentSession() ) { |
437 | bool ret = currentSession()->layer()->open(); | 445 | bool ret = currentSession()->layer()->open(); |
438 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 446 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
439 | QObject::tr("Failed"), | 447 | QObject::tr("Failed"), |
440 | QObject::tr("Connecting failed for this session.")); | 448 | QObject::tr("Connecting failed for this session.")); |
441 | else { | 449 | else { |