You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.4 KiB
102 lines
2.4 KiB
15 years ago
|
|
||
|
#include "notepad.h"
|
||
12 years ago
|
#include <tdeparts/partmanager.h>
|
||
|
#include <tdeparts/mainwindow.h>
|
||
15 years ago
|
|
||
14 years ago
|
#include <tqsplitter.h>
|
||
|
#include <tqfile.h>
|
||
13 years ago
|
#include <tqtextstream.h>
|
||
14 years ago
|
#include <tqmultilineedit.h>
|
||
15 years ago
|
|
||
|
#include <kaboutdata.h>
|
||
|
#include <kapplication.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kaction.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kstatusbar.h>
|
||
|
#include <kstandarddirs.h>
|
||
|
|
||
13 years ago
|
NotepadPart::NotepadPart( TQWidget* parentWidget, const char*,
|
||
14 years ago
|
TQObject* parent, const char* name,
|
||
|
const TQStringList& )
|
||
15 years ago
|
: KParts::ReadWritePart( parent, name )
|
||
|
{
|
||
|
setInstance( NotepadFactory::instance() );
|
||
|
|
||
13 years ago
|
m_edit = new TQMultiLineEdit( parentWidget, "NotepadPart's multiline edit" );
|
||
15 years ago
|
setWidget( m_edit );
|
||
|
|
||
14 years ago
|
(void)new KAction( "Search and replace", 0, this, TQT_SLOT( slotSearchReplace() ), actionCollection(), "searchreplace" );
|
||
15 years ago
|
setXMLFile( "notepadpart.rc" );
|
||
|
setReadWrite( true );
|
||
|
}
|
||
|
|
||
|
NotepadPart::~NotepadPart()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void NotepadPart::setReadWrite( bool rw )
|
||
|
{
|
||
|
m_edit->setReadOnly( !rw );
|
||
|
if (rw)
|
||
14 years ago
|
connect( m_edit, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( setModified() ) );
|
||
15 years ago
|
else
|
||
14 years ago
|
disconnect( m_edit, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( setModified() ) );
|
||
15 years ago
|
|
||
|
ReadWritePart::setReadWrite( rw );
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEAboutData* NotepadPart::createAboutData()
|
||
15 years ago
|
{
|
||
12 years ago
|
return new TDEAboutData( "notepadpart", I18N_NOOP( "Notepad" ), "2.0" );
|
||
15 years ago
|
}
|
||
|
|
||
|
bool NotepadPart::openFile()
|
||
|
{
|
||
|
kdDebug() << "NotepadPart: opening " << m_file << endl;
|
||
|
// Hehe this is from a tutorial I did some time ago :)
|
||
14 years ago
|
TQFile f(m_file);
|
||
|
TQString s;
|
||
15 years ago
|
if ( f.open(IO_ReadOnly) ) {
|
||
14 years ago
|
TQTextStream t( &f );
|
||
15 years ago
|
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;
|
||
14 years ago
|
TQFile f(m_file);
|
||
|
TQString s;
|
||
15 years ago
|
if ( f.open(IO_WriteOnly) ) {
|
||
14 years ago
|
TQTextStream t( &f );
|
||
15 years ago
|
t << m_edit->text();
|
||
|
f.close();
|
||
|
return true;
|
||
|
} else
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void NotepadPart::slotSearchReplace()
|
||
|
{
|
||
|
// What's this ? (David)
|
||
|
/*
|
||
14 years ago
|
TQValueList<KParts::XMLGUIServant *> plugins = KParts::Plugin::pluginServants( this );
|
||
|
TQValueList<KParts::XMLGUIServant *>::ConstIterator it = plugins.begin();
|
||
|
TQValueList<KParts::XMLGUIServant *>::ConstIterator end = plugins.end();
|
||
15 years ago
|
for (; it != end; ++it )
|
||
|
factory()->removeServant( *it );
|
||
|
*/
|
||
|
}
|
||
|
|
||
|
#include "notepad.moc"
|