From dfe289850f068f19ba4a83ab4e7e22a7e09c13c9 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sat, 26 Jan 2013 13:17:21 -0600 Subject: Rename a number of libraries and executables to avoid conflicts with KDE4 --- tdeparts/tests/notepad.cpp | 101 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tdeparts/tests/notepad.cpp (limited to 'tdeparts/tests/notepad.cpp') diff --git a/tdeparts/tests/notepad.cpp b/tdeparts/tests/notepad.cpp new file mode 100644 index 000000000..6494288cd --- /dev/null +++ b/tdeparts/tests/notepad.cpp @@ -0,0 +1,101 @@ + +#include "notepad.h" +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +NotepadPart::NotepadPart( TQWidget* parentWidget, const char*, + TQObject* parent, const char* name, + const TQStringList& ) + : KParts::ReadWritePart( parent, name ) +{ + setInstance( NotepadFactory::instance() ); + + m_edit = new TQMultiLineEdit( parentWidget, "NotepadPart's multiline edit" ); + setWidget( m_edit ); + + (void)new KAction( "Search and replace", 0, this, TQT_SLOT( slotSearchReplace() ), actionCollection(), "searchreplace" ); + setXMLFile( "notepadpart.rc" ); + setReadWrite( true ); +} + +NotepadPart::~NotepadPart() +{ +} + +void NotepadPart::setReadWrite( bool rw ) +{ + m_edit->setReadOnly( !rw ); + if (rw) + connect( m_edit, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( setModified() ) ); + else + disconnect( m_edit, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( setModified() ) ); + + ReadWritePart::setReadWrite( rw ); +} + +TDEAboutData* NotepadPart::createAboutData() +{ + return new TDEAboutData( "notepadpart", I18N_NOOP( "Notepad" ), "2.0" ); +} + +bool NotepadPart::openFile() +{ + kdDebug() << "NotepadPart: opening " << m_file << endl; + // Hehe this is from a tutorial I did some time ago :) + TQFile f(m_file); + TQString s; + if ( f.open(IO_ReadOnly) ) { + TQTextStream t( &f ); + while ( !t.eof() ) { + s += t.readLine() + "\n"; + } + f.close(); + } + m_edit->setText(s); + + emit setStatusBarText( m_url.prettyURL() ); + + return true; +} + +bool NotepadPart::saveFile() +{ + if ( !isReadWrite() ) + return false; + TQFile f(m_file); + TQString s; + if ( f.open(IO_WriteOnly) ) { + TQTextStream t( &f ); + t << m_edit->text(); + f.close(); + return true; + } else + return false; +} + +void NotepadPart::slotSearchReplace() +{ + // What's this ? (David) +/* + TQValueList plugins = KParts::Plugin::pluginServants( this ); + TQValueList::ConstIterator it = plugins.begin(); + TQValueList::ConstIterator end = plugins.end(); + for (; it != end; ++it ) + factory()->removeServant( *it ); +*/ +} + +#include "notepad.moc" -- cgit v1.2.3