author | zecke <zecke> | 2002-11-07 18:31:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-07 18:31:52 (UTC) |
commit | b89e9179db00b777e41bdd0c95885fb76b3f1a88 (patch) (side-by-side diff) | |
tree | 6b0b6e33d5d084849ab8d7b17ba1c03b74d8a0c9 | |
parent | 8baa44cf756fc3767829983941fc64c9547b8cc0 (diff) | |
download | opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.zip opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.tar.gz opie-b89e9179db00b777e41bdd0c95885fb76b3f1a88.tar.bz2 |
Renove Emulationhandler from MetaFactory
common.h clashed with TECommon.h
Implement saving of history!
-rw-r--r-- | noncore/apps/opie-console/TEScreen.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEScreen.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/TEmulation.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/emulation_handler.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 25 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 11 |
10 files changed, 64 insertions, 42 deletions
diff --git a/noncore/apps/opie-console/TEScreen.cpp b/noncore/apps/opie-console/TEScreen.cpp index a3d115d..2675d31 100644 --- a/noncore/apps/opie-console/TEScreen.cpp +++ b/noncore/apps/opie-console/TEScreen.cpp @@ -987,3 +987,3 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) { - if (sel_begin == -1) + if (sel_begin == -1) return QString::null; // Selection got clear while selecting. @@ -1017,3 +1017,3 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) } - + while (hX < eol) @@ -1114,3 +1114,3 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) } - + QString res(qc, d); @@ -1122,2 +1122,13 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks) } +QString TEScreen::getHistory() { + sel_begin = 0; + sel_BR = sel_begin; + sel_TL = sel_begin; + setSelExtentXY(columns-1,lines-1); + QString tmp=getSelText(true); + while (tmp.at(tmp.length()-2).unicode()==10 && tmp.at(tmp.length()-1).unicode()==10) + tmp.truncate(tmp.length()-1); + + return tmp; +} /* above ... end of line processing for selection -- psilva diff --git a/noncore/apps/opie-console/TEScreen.h b/noncore/apps/opie-console/TEScreen.h index 473ce79..a840b44 100644 --- a/noncore/apps/opie-console/TEScreen.h +++ b/noncore/apps/opie-console/TEScreen.h @@ -164,2 +164,4 @@ public: // these are all `Screen' operations + QString getHistory(); + private: // helper diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 7a0c624..3b1b9e1 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp @@ -273,3 +273,5 @@ void TEmulation::clearSelection() { } - +void TEmulation::streamHistory(QTextStream* stream) { + *stream << scr->getHistory(); +} // Refreshing -------------------------------------------------------------- -- diff --git a/noncore/apps/opie-console/TEmulation.h b/noncore/apps/opie-console/TEmulation.h index ec15e7a..d7b3d6d 100644 --- a/noncore/apps/opie-console/TEmulation.h +++ b/noncore/apps/opie-console/TEmulation.h @@ -26,2 +26,4 @@ #include <qtextcodec.h> +#include <qtextstream.h> + #include "keytrans.h" @@ -39,2 +41,3 @@ public: virtual bool history(); + virtual void streamHistory( QTextStream* ); @@ -45,3 +48,3 @@ public slots: // signals incoming from TEWidget virtual void onKeyPress(QKeyEvent*); - + virtual void clearSelection(); @@ -77,2 +80,4 @@ public: + + protected: diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 7924568..235facb 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp @@ -33,2 +33,5 @@ EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const c } +TEmulation* EmulationHandler::emulation() { + return m_teEmu; +} EmulationHandler::~EmulationHandler() { diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h index 7bc6f16..1338525 100644 --- a/noncore/apps/opie-console/emulation_handler.h +++ b/noncore/apps/opie-console/emulation_handler.h @@ -49,2 +49,3 @@ public: QWidget* widget(); + TEmulation *emulation(); void setColor( const QColor& fore, const QColor& back ); diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index d221715..01468ca 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -11,2 +11,3 @@ #include <qfileinfo.h> +#include <qtextstream.h> @@ -19,2 +20,3 @@ +#include "TEmulation.h" #include "keytrans.h" @@ -243,2 +245,8 @@ void MainWindow::initUI() { m_console->insertSeparator(); + + QAction *a = new QAction(); + a->setText( tr("Save history") ); + a->addTo( m_console ); + connect(a, SIGNAL(activated() ), + this, SLOT(slotSaveHistory() ) ); /* @@ -304,3 +312,3 @@ void MainWindow::initUI() { - QAction *a = new QAction(tr("Copy"), + a = new QAction(tr("Copy"), Resource::loadPixmap("copy"), QString::null, @@ -770 +778,26 @@ void MainWindow::slotSaveSession() { } +void MainWindow::slotSaveHistory() { + QMap<QString, QStringList> map; + QStringList text; + text << "text/plain"; + map.insert(tr("History"), text ); + QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); + if (filename.isEmpty() ) return; + + QFileInfo info(filename); + + DocLnk nf; + nf.setType("text/plain"); + nf.setFile(filename); + nf.setName(info.fileName()); + + + QFile file(filename); + file.open(IO_WriteOnly ); + QTextStream str(&file ); + if ( currentSession() ) + currentSession()->emulationHandler()->emulation()->streamHistory(&str); + + file.close(); + nf.writeLink(); +} diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 37219c5..0fac38b 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -72,2 +72,3 @@ private slots: void slotKeyReceived(FKey, ushort, ushort, bool); + void slotSaveHistory(); diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 0b43e17..24928e7 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -45,8 +45,2 @@ void MetaFactory::addReceiveLayer( const QCString& name, } -void MetaFactory::addEmulationLayer( const QCString& name, - const QString& str, - emulationLayer em) { - m_strings.insert(str, name ); - m_emu.insert( str, em ); -} QStringList MetaFactory::ioLayers()const { @@ -91,10 +85,2 @@ QStringList MetaFactory::receiveLayers()const { } -QStringList MetaFactory::emulationLayers()const { - QStringList list; - QMap<QString, emulationLayer>::ConstIterator it; - for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { - list << it.key(); - } - return list; -} @@ -150,13 +136,2 @@ ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget } -EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { - EmulationLayer* lay = 0l; - - QMap<QString, emulationLayer>::Iterator it; - it = m_emu.find( str ); - if ( it != m_emu.end() ) { - lay = (*(it.data() ) )(wid); - } - - return lay; -} FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index f89136c..bcc40db 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -18,3 +18,2 @@ #include "profiledialogwidget.h" -#include "emulation_layer.h" @@ -27,3 +26,2 @@ public: typedef ReceiveLayer* (*receivelayer)(IOLayer*); - typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); @@ -63,8 +61,2 @@ public: - /** - * adds a Factory for Emulation to the Layer.. - */ - void addEmulationLayer ( const QCString& name, - const QString& uiString, - emulationLayer ); @@ -80,3 +72,2 @@ public: QStringList receiveLayers()const; - QStringList emulationLayers()const; @@ -89,3 +80,2 @@ public: ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); - EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); @@ -115,3 +105,2 @@ private: QMap<QString, receivelayer> m_receiveFact; - QMap<QString, emulationLayer> m_emu; }; |