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 | 16 |
1 files changed, 12 insertions, 4 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 | |||
@@ -8,6 +8,7 @@ | |||
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> |
@@ -141,6 +142,7 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow( | |||
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(); |
@@ -358,10 +360,13 @@ void MainWindow::populateScripts() { | |||
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()); |
364 | if (info.extension(false) == "script") { | ||
365 | m_scriptsData.append(new DocLnk(**dit)); | ||
362 | m_scriptsPop->insertItem((*dit)->name()); | 366 | m_scriptsPop->insertItem((*dit)->name()); |
363 | } | 367 | } |
364 | } | 368 | } |
369 | } | ||
365 | 370 | ||
366 | } | 371 | } |
367 | 372 | ||
@@ -408,10 +413,13 @@ void MainWindow::slotSaveScript() { | |||
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(); |
@@ -424,9 +432,9 @@ void MainWindow::slotSaveScript() { | |||
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 | } |