summaryrefslogtreecommitdiffstats
path: root/tdeparts/tests
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /tdeparts/tests
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeparts/tests')
-rw-r--r--tdeparts/tests/Makefile.am46
-rw-r--r--tdeparts/tests/README5
-rw-r--r--tdeparts/tests/example.cpp135
-rw-r--r--tdeparts/tests/example.h39
-rw-r--r--tdeparts/tests/ghostview.cpp119
-rw-r--r--tdeparts/tests/ghostview.h22
-rw-r--r--tdeparts/tests/ghostviewtest_shell.rc15
-rw-r--r--tdeparts/tests/normalktm.cpp122
-rw-r--r--tdeparts/tests/normalktm.h38
-rw-r--r--tdeparts/tests/notepad.cpp101
-rw-r--r--tdeparts/tests/notepad.desktop86
-rw-r--r--tdeparts/tests/notepad.h42
-rw-r--r--tdeparts/tests/notepadpart.cpp5
-rw-r--r--tdeparts/tests/notepadpart.rc14
-rw-r--r--tdeparts/tests/parts.cpp90
-rw-r--r--tdeparts/tests/parts.h43
-rw-r--r--tdeparts/tests/plugin_foobar.rc12
-rw-r--r--tdeparts/tests/plugin_spellcheck.cpp39
-rw-r--r--tdeparts/tests/plugin_spellcheck.h18
-rw-r--r--tdeparts/tests/plugin_spellcheck.rc15
-rw-r--r--tdeparts/tests/tdepartstest_part1.rc18
-rw-r--r--tdeparts/tests/tdepartstest_shell.rc28
22 files changed, 1052 insertions, 0 deletions
diff --git a/tdeparts/tests/Makefile.am b/tdeparts/tests/Makefile.am
new file mode 100644
index 000000000..df0a2a5be
--- /dev/null
+++ b/tdeparts/tests/Makefile.am
@@ -0,0 +1,46 @@
+
+INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/libltdl -I$(top_srcdir)/kfile -I$(top_srcdir)/kio $(all_includes)
+AM_LDFLAGS = $(all_libraries)
+LDADD = $(LIB_KPARTS)
+
+check_PROGRAMS = tdepartstest normalktmtest ghostviewtest
+
+tdepartstest_SOURCES = example.cpp parts.cpp
+tdepartstest_LDADD = libnotepad.la $(LIB_KPARTS)
+normalktmtest_SOURCES = normalktm.cpp parts.cpp
+normalktmtest_LDADD = libnotepad.la $(LIB_KPARTS)
+ghostviewtest_SOURCES = ghostview.cpp
+ghostviewtest_LDADD = $(LIB_KPARTS)
+
+# These are not really libraries, but modules dynamically opened.
+# So they should be installed in kde_module_dir, which is usually $prefix/lib/trinity
+kde_module_LTLIBRARIES = libspellcheckplugin.la libnotepadpart.la
+
+libspellcheckplugin_la_SOURCES = plugin_spellcheck.cpp
+libspellcheckplugin_la_LIBADD = $(LIB_KPARTS)
+libspellcheckplugin_la_LDFLAGS = -module $(KDE_PLUGIN)
+
+libnotepadpart_la_SOURCES = notepadpart.cpp
+libnotepadpart_la_LIBADD = libnotepad.la $(LIB_KPARTS)
+libnotepadpart_la_LDFLAGS = -module $(KDE_PLUGIN)
+
+noinst_LTLIBRARIES = libnotepad.la
+libnotepad_la_SOURCES = notepad.cpp
+
+rcdir = $(kde_datadir)/tdepartstest
+rc_DATA = tdepartstest_shell.rc
+
+testpartdir = $(kde_datadir)/tdepartstestpart
+testpart_DATA = tdepartstest_part1.rc
+
+notepaddir = $(kde_datadir)/notepadpart
+notepad_DATA = notepadpart.rc
+
+ghostviewtestdir = $(kde_datadir)/ghostviewtest
+ghostviewtest_DATA = ghostviewtest_shell.rc
+
+pluginsdir = $(kde_datadir)/notepadpart/kpartplugins
+plugins_DATA = plugin_foobar.rc plugin_spellcheck.rc
+
+METASOURCES = AUTO
+
diff --git a/tdeparts/tests/README b/tdeparts/tests/README
new file mode 100644
index 000000000..a0bee7ca6
--- /dev/null
+++ b/tdeparts/tests/README
@@ -0,0 +1,5 @@
+In order to test embedding the notepad part in konqueror, you need
+to "make install", to install the libs, and to copy notepad.desktop
+into $TDEDIR/share/services/, and remove kwrite.desktop from
+$TDEDIR/share/applnk/... (at least the ServiceTypes line of it)
+
diff --git a/tdeparts/tests/example.cpp b/tdeparts/tests/example.cpp
new file mode 100644
index 000000000..e8495ffe9
--- /dev/null
+++ b/tdeparts/tests/example.cpp
@@ -0,0 +1,135 @@
+
+#include "example.h"
+#include "parts.h"
+#include "notepad.h"
+
+#include <tqsplitter.h>
+#include <tqcheckbox.h>
+#include <tqdir.h>
+
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <kaction.h>
+#include <klocale.h>
+
+Shell::Shell()
+{
+ setXMLFile( "tdepartstest_shell.rc" );
+
+ m_manager = new KParts::PartManager( this );
+
+ // When the manager says the active part changes, the builder updates (recreates) the GUI
+ connect( m_manager, TQT_SIGNAL( activePartChanged( KParts::Part * ) ),
+ this, TQT_SLOT( createGUI( KParts::Part * ) ) );
+
+ // We can do this "switch active part" because we have a splitter with
+ // two items in it.
+ // I wonder what tdevelop uses/will use to embed kedit, BTW.
+ m_splitter = new TQSplitter( this );
+
+ m_part1 = new Part1(this, m_splitter);
+ m_part2 = new Part2(this, m_splitter);
+
+ KActionCollection *coll = actionCollection();
+
+ (void)new KAction( "&View local file", 0, this, TQT_SLOT( slotFileOpen() ), coll, "open_local_file" );
+ (void)new KAction( "&View remote file", 0, this, TQT_SLOT( slotFileOpenRemote() ), coll, "open_remote_file" );
+
+ m_paEditFile = new KAction( "&Edit file", 0, this, TQT_SLOT( slotFileEdit() ), coll, "edit_file" );
+ m_paCloseEditor = new KAction( "&Close file editor", 0, this, TQT_SLOT( slotFileCloseEditor() ), coll, "close_editor" );
+ m_paCloseEditor->setEnabled(false);
+ KAction * paQuit = new KAction( "&Quit", 0, this, TQT_SLOT( close() ), coll, "shell_quit" );
+ paQuit->setIconSet(TQIconSet(BarIcon("exit")));
+
+ (void)new KAction( "Yet another menu item", 0, coll, "shell_yami" );
+ (void)new KAction( "Yet another submenu item", 0, coll, "shell_yasmi" );
+
+ setCentralWidget( m_splitter );
+ m_splitter->setMinimumSize( 400, 300 );
+
+ m_splitter->show();
+
+ m_manager->addPart( m_part1, true ); // sets part 1 as the active part
+ m_manager->addPart( m_part2, false );
+ m_editorpart = 0;
+}
+
+Shell::~Shell()
+{
+ disconnect( m_manager, 0, this, 0 );
+}
+
+void Shell::slotFileOpen()
+{
+ if ( ! m_part1->openURL( locate("data", TDEGlobal::instance()->instanceName()+"/tdepartstest_shell.rc" ) ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+void Shell::slotFileOpenRemote()
+{
+ KURL u ( "http://www.kde.org/index.html" );
+ if ( ! m_part1->openURL( u ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+void Shell::embedEditor()
+{
+ if ( m_manager->activePart() == m_part2 )
+ createGUI( 0L );
+
+ // replace part2 with the editor part
+ delete m_part2;
+ m_part2 = 0L;
+ m_editorpart = new NotepadPart( m_splitter, "editor",
+ this, "NotepadPart" );
+ m_editorpart->setReadWrite(); // read-write mode
+ m_manager->addPart( m_editorpart );
+ m_paEditFile->setEnabled(false);
+ m_paCloseEditor->setEnabled(true);
+}
+
+void Shell::slotFileCloseEditor()
+{
+ // It is very important to close the url of a read-write part
+ // before destroying it. This allows to save the document (if modified)
+ // and also to cancel.
+ if ( ! m_editorpart->closeURL() )
+ return;
+
+ // Is this necessary ? (David)
+ if ( m_manager->activePart() == m_editorpart )
+ createGUI( 0L );
+
+ delete m_editorpart;
+ m_editorpart = 0L;
+ m_part2 = new Part2(this, m_splitter);
+ m_manager->addPart( m_part2 );
+ m_paEditFile->setEnabled(true);
+ m_paCloseEditor->setEnabled(false);
+}
+
+void Shell::slotFileEdit()
+{
+ if ( !m_editorpart )
+ embedEditor();
+ // TODO use KFileDialog to allow testing remote files
+ if ( ! m_editorpart->openURL( TQDir::current().absPath()+"/tdepartstest_shell.rc" ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+int main( int argc, char **argv )
+{
+ TDEApplication app( argc, argv, "tdepartstest" );
+
+ Shell *shell = new Shell;
+
+ shell->show();
+
+ app.exec();
+
+ return 0;
+}
+
+#include "example.moc"
diff --git a/tdeparts/tests/example.h b/tdeparts/tests/example.h
new file mode 100644
index 000000000..b4bdead61
--- /dev/null
+++ b/tdeparts/tests/example.h
@@ -0,0 +1,39 @@
+
+#ifndef __example_h__
+#define __example_h__
+
+#include <tdeparts/partmanager.h>
+#include <tdeparts/mainwindow.h>
+
+class KAction;
+class TQWidget;
+
+class Shell : public KParts::MainWindow
+{
+ Q_OBJECT
+public:
+ Shell();
+ virtual ~Shell();
+
+protected slots:
+ void slotFileOpen();
+ void slotFileOpenRemote();
+ void slotFileEdit();
+ void slotFileCloseEditor();
+
+protected:
+ void embedEditor();
+
+private:
+
+ KAction * m_paEditFile;
+ KAction * m_paCloseEditor;
+
+ KParts::ReadOnlyPart *m_part1;
+ KParts::Part *m_part2;
+ KParts::ReadWritePart *m_editorpart;
+ KParts::PartManager *m_manager;
+ TQWidget *m_splitter;
+};
+
+#endif
diff --git a/tdeparts/tests/ghostview.cpp b/tdeparts/tests/ghostview.cpp
new file mode 100644
index 000000000..5d1bbe5b3
--- /dev/null
+++ b/tdeparts/tests/ghostview.cpp
@@ -0,0 +1,119 @@
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kcmdlineargs.h>
+#include <klibloader.h>
+
+#include <tqwidget.h>
+#include <tqdir.h>
+#include <tqfile.h>
+
+#include <ktrader.h>
+
+#include "ghostview.h"
+
+Shell::Shell()
+{
+ setXMLFile( "ghostviewtest_shell.rc" );
+
+ KAction * paOpen = new KAction( "&Open file" , "fileopen", 0, this,
+ TQT_SLOT( slotFileOpen() ), actionCollection(), "file_open" );
+
+ KAction * paQuit = new KAction( "&Quit" , "exit", 0, this, TQT_SLOT( close() ), actionCollection(), "file_quit" );
+
+ // Try to find a postscript component first
+ KTrader::OfferList offers = KTrader::self()->query("application/postscript", "('KParts/ReadOnlyPart' in ServiceTypes) or ('Browser/View' in ServiceTypes)");
+
+ KLibFactory *factory = 0;
+ m_gvpart = 0;
+ KTrader::OfferList::Iterator it(offers.begin());
+ for( ; it != offers.end(); ++it)
+ {
+ KService::Ptr ptr = (*it);
+
+ factory = KLibLoader::self()->factory( TQFile::encodeName(ptr->library()) );
+ if (factory)
+ {
+ m_gvpart = static_cast<KParts::ReadOnlyPart *>(factory->create(this, ptr->name().latin1(), "KParts::ReadOnlyPart"));
+ setCentralWidget( m_gvpart->widget() );
+ // Integrate its GUI
+ createGUI( m_gvpart );
+
+ break;
+ }
+ }
+
+ // if we couldn't find a component with the trader, try the
+ // kghostview library directly. if this ever happens, then something
+ // is seriously screwed up, though -- the kghostview component
+ // should be picked up by the trader
+ if (!m_gvpart)
+ {
+ factory = KLibLoader::self()->factory( "libkghostview" );
+ if (factory)
+ {
+ // Create the part
+ m_gvpart = (KParts::ReadOnlyPart *)factory->create( this, "kgvpart",
+ "KParts::ReadOnlyPart" );
+ // Set the main widget
+ setCentralWidget( m_gvpart->widget() );
+ // Integrate its GUI
+ createGUI( m_gvpart );
+ }
+ else
+ {
+ KMessageBox::error(this, "No libkghostview found !");
+ }
+ }
+ // Set a reasonable size
+ resize( 600, 350 );
+}
+
+Shell::~Shell()
+{
+ delete m_gvpart;
+}
+
+void Shell::openURL( const KURL & url )
+{
+ m_gvpart->openURL( url );
+}
+
+void Shell::slotFileOpen()
+{
+ KURL url = KFileDialog::getOpenURL( TQString::null, "*.ps|Postscript files (*.ps)", 0L, "file dialog" );
+
+ if( !url.isEmpty() )
+ openURL( url );
+}
+
+static KCmdLineOptions options[] =
+{
+ { "+file(s)", "Files to load", 0 },
+ KCmdLineLastOption
+};
+static const char version[] = "v0.0.1 2000 (c) David Faure";
+static const char description[] = "This is a test shell for the kghostview part.";
+
+int main( int argc, char **argv )
+{
+ TDECmdLineArgs::init(argc, argv, "ghostviewtest", description, version);
+ TDECmdLineArgs::addCmdLineOptions( options ); // Add my own options.
+ TDEApplication app;
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ Shell *shell = new Shell;
+ if ( args->count() == 1 )
+ {
+ // Allow full paths, but also simple filenames from current dir
+ KURL url( TQDir::currentDirPath()+"/", args->arg(0) );
+ shell->openURL( url );
+ }
+ shell->show();
+ return app.exec();
+}
+
+#include "ghostview.moc"
diff --git a/tdeparts/tests/ghostview.h b/tdeparts/tests/ghostview.h
new file mode 100644
index 000000000..2974ded5e
--- /dev/null
+++ b/tdeparts/tests/ghostview.h
@@ -0,0 +1,22 @@
+#ifndef __example_h__
+#define __example_h__
+
+#include <tdeparts/mainwindow.h>
+
+class Shell : public KParts::MainWindow
+{
+ Q_OBJECT
+public:
+ Shell();
+ virtual ~Shell();
+
+ void openURL( const KURL & url );
+
+protected slots:
+ void slotFileOpen();
+
+private:
+ KParts::ReadOnlyPart *m_gvpart;
+};
+
+#endif
diff --git a/tdeparts/tests/ghostviewtest_shell.rc b/tdeparts/tests/ghostviewtest_shell.rc
new file mode 100644
index 000000000..0bae67c82
--- /dev/null
+++ b/tdeparts/tests/ghostviewtest_shell.rc
@@ -0,0 +1,15 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="KGVShell">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Action name="file_open"/>
+ <Action name="file_quit"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="KGV-ToolBar">
+ <Action name="file_open"/>
+ <Action name="file_quit"/>
+</ToolBar>
+<StatusBar/>
+</kpartgui>
+
diff --git a/tdeparts/tests/normalktm.cpp b/tdeparts/tests/normalktm.cpp
new file mode 100644
index 000000000..277f3ccde
--- /dev/null
+++ b/tdeparts/tests/normalktm.cpp
@@ -0,0 +1,122 @@
+
+#include "normalktm.h"
+#include "parts.h"
+#include "notepad.h"
+
+#include <tqsplitter.h>
+#include <tqcheckbox.h>
+#include <tqdir.h>
+
+#include <kiconloader.h>
+#include <kstandarddirs.h>
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <kaction.h>
+#include <klocale.h>
+
+#include <kmenubar.h>
+
+Shell::Shell()
+{
+ // We can do this "switch active part" because we have a splitter with
+ // two items in it.
+ // I wonder what tdevelop uses/will use to embed kedit, BTW.
+ m_splitter = new TQSplitter( this );
+
+ m_part1 = new Part1(this, m_splitter);
+ m_part2 = new Part2(this, m_splitter);
+
+ TQPopupMenu * pFile = new TQPopupMenu( this );
+ menuBar()->insertItem( "File", pFile );
+ TQObject * coll = this;
+ KAction * paLocal = new KAction( "&View local file", 0, this, TQT_SLOT( slotFileOpen() ), coll, "open_local_file" );
+ // No XML : we need to plug our actions ourselves
+ paLocal->plug( pFile );
+
+ KAction * paRemote = new KAction( "&View remote file", 0, this, TQT_SLOT( slotFileOpenRemote() ), coll, "open_remote_file" );
+ paRemote->plug( pFile );
+
+ m_paEditFile = new KAction( "&Edit file", 0, this, TQT_SLOT( slotFileEdit() ), coll, "edit_file" );
+ m_paEditFile->plug( pFile );
+
+ m_paCloseEditor = new KAction( "&Close file editor", 0, this, TQT_SLOT( slotFileCloseEditor() ), coll, "close_editor" );
+ m_paCloseEditor->setEnabled(false);
+ m_paCloseEditor->plug( pFile );
+
+ KAction * paQuit = new KAction( "&Quit", 0, this, TQT_SLOT( close() ), coll, "shell_quit" );
+ paQuit->setIconSet(TQIconSet(BarIcon("exit")));
+ paQuit->plug( pFile );
+
+ setCentralWidget( m_splitter );
+ m_splitter->setMinimumSize( 400, 300 );
+
+ m_splitter->show();
+
+ m_editorpart = 0;
+}
+
+Shell::~Shell()
+{
+}
+
+void Shell::slotFileOpen()
+{
+ if ( ! m_part1->openURL( locate("data", TDEGlobal::instance()->instanceName()+"/tdepartstest_shell.rc" ) ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+void Shell::slotFileOpenRemote()
+{
+ KURL u ( "http://www.kde.org/index.html" );
+ if ( ! m_part1->openURL( u ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+void Shell::embedEditor()
+{
+ // replace part2 with the editor part
+ delete m_part2;
+ m_part2 = 0L;
+ m_editorpart = new NotepadPart( m_splitter, "editor",
+ this, "NotepadPart" );
+ m_editorpart->setReadWrite(); // read-write mode
+ ////// m_manager->addPart( m_editorpart );
+ m_editorpart->widget()->show(); //// we need to do this in a normal KTM....
+ m_paEditFile->setEnabled(false);
+ m_paCloseEditor->setEnabled(true);
+}
+
+void Shell::slotFileCloseEditor()
+{
+ delete m_editorpart;
+ m_editorpart = 0L;
+ m_part2 = new Part2(this, m_splitter);
+ ////// m_manager->addPart( m_part2 );
+ m_part2->widget()->show(); //// we need to do this in a normal KTM....
+ m_paEditFile->setEnabled(true);
+ m_paCloseEditor->setEnabled(false);
+}
+
+void Shell::slotFileEdit()
+{
+ if ( !m_editorpart )
+ embedEditor();
+ // TODO use KFileDialog to allow testing remote files
+ if ( ! m_editorpart->openURL( TQDir::current().absPath()+"/tdepartstest_shell.rc" ) )
+ KMessageBox::error(this,"Couldn't open file !");
+}
+
+int main( int argc, char **argv )
+{
+ TDEApplication app( argc, argv, "tdepartstest" ); // we cheat and call ourselves tdepartstest for Shell::slotFileOpen()
+
+ Shell *shell = new Shell;
+
+ shell->show();
+
+ app.exec();
+
+ return 0;
+}
+
+#include "normalktm.moc"
diff --git a/tdeparts/tests/normalktm.h b/tdeparts/tests/normalktm.h
new file mode 100644
index 000000000..26a93a52a
--- /dev/null
+++ b/tdeparts/tests/normalktm.h
@@ -0,0 +1,38 @@
+
+#ifndef __normalktm_h__
+#define __normalktm_h__
+
+#include <tdeparts/part.h>
+#include <kmainwindow.h>
+
+class KAction;
+class TQWidget;
+
+class Shell : public KMainWindow
+{
+ Q_OBJECT
+public:
+ Shell();
+ virtual ~Shell();
+
+protected slots:
+ void slotFileOpen();
+ void slotFileOpenRemote();
+ void slotFileEdit();
+ void slotFileCloseEditor();
+
+protected:
+ void embedEditor();
+
+private:
+
+ KAction * m_paEditFile;
+ KAction * m_paCloseEditor;
+
+ KParts::ReadOnlyPart *m_part1;
+ KParts::Part *m_part2;
+ KParts::ReadWritePart *m_editorpart;
+ TQWidget *m_splitter;
+};
+
+#endif
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 <tdeparts/partmanager.h>
+#include <tdeparts/mainwindow.h>
+
+#include <tqsplitter.h>
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqmultilineedit.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kstatusbar.h>
+#include <kstandarddirs.h>
+
+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<KParts::XMLGUIServant *> plugins = KParts::Plugin::pluginServants( this );
+ TQValueList<KParts::XMLGUIServant *>::ConstIterator it = plugins.begin();
+ TQValueList<KParts::XMLGUIServant *>::ConstIterator end = plugins.end();
+ for (; it != end; ++it )
+ factory()->removeServant( *it );
+*/
+}
+
+#include "notepad.moc"
diff --git a/tdeparts/tests/notepad.desktop b/tdeparts/tests/notepad.desktop
new file mode 100644
index 000000000..a529d69a1
--- /dev/null
+++ b/tdeparts/tests/notepad.desktop
@@ -0,0 +1,86 @@
+[Desktop Entry]
+Name=Notepad (example)
+Name[af]=Notablok (voorbeeld)
+Name[ar]=مفكرة (مثال)
+Name[az]=Qeyd dəftəri (misal)
+Name[be]=Нататнік (узор)
+Name[bn]=নোটপ্যাড (উদাহরণ)
+Name[br]=Skrabvloc'h (skouer)
+Name[bs]=Notepad (primjer)
+Name[ca]=Bloc de notes (exemple)
+Name[cs]=Poznámkový blok (příklad)
+Name[csb]=Notownik (przëmiôr)
+Name[cy]=Pad ysgrifennu (enghraifft)
+Name[da]=Notepad (eksempel)
+Name[de]=Notizblock-Beispiel
+Name[el]=Σημειωματάριο (παράδειγμα)
+Name[eo]=Notlibro (ekzemplo)
+Name[es]=Bloc de notas (ejemplo)
+Name[et]=Notepad (näidis)
+Name[eu]=Notepad (adibidea)
+Name[fa]=دفترچه یادداشت)مثال(
+Name[fi]=Muistio (esimerkki)
+Name[fr]=Bloc-notes (exemple)
+Name[fy]=Skriuwboekje (foarbyld)
+Name[ga]=Notepad (sampla)
+Name[gl]=Caderno de Notas (exemplo)
+Name[he]=פנקס רשימות (דוגמה)
+Name[hi]=नोटपैड (उदाहरण)
+Name[hr]=Notepad (primjer)
+Name[hu]=Jegyzettömb (példa)
+Name[id]=Notepad (contoh)
+Name[is]=Notepad (sýnishorn)
+Name[it]=Blocco note (esempio)
+Name[ja]=ノートパッド (例)
+Name[ka]=ბლიკნოტი (მაგალითი)
+Name[kk]=Блокнот (мысал)
+Name[km]=Notepad (ឧទាហរណ៍)
+Name[ko]=쪽지장 (보기)
+Name[lb]=Notizblock (Beispill)
+Name[lt]=Notepad (pavyzdys)
+Name[lv]=Notepads (piemērs)
+Name[mk]=Тетратка (пример)
+Name[mn]=Тэмдэглэлийн блок (Жишээ)
+Name[ms]=Notepad (contoh)
+Name[mt]=Notepad (eżempju)
+Name[nb]=Notisblokk (eksempel)
+Name[nds]=Notizzeddel (Bispeel)
+Name[ne]=नोटप्याड (उदाहरण)
+Name[nl]=Kladblok (voorbeeld)
+Name[nn]=Notisblokk (døme)
+Name[nso]=Notepad (mohlala)
+Name[oc]=Bloc de notes (exemple)
+Name[pa]=ਨੋਟਪੈਡ (ਉਦਾਹਰਨ)
+Name[pl]=Notatnik (przykład)
+Name[pt]=Bloco de Notas (exemplo)
+Name[pt_BR]=Bloco de notas (exemplo)
+Name[ro]=Notepad (exemplu)
+Name[ru]=Блокнот (пример)
+Name[rw]=Notepad (urugero)
+Name[se]=Čállingirjjáš (ovdamearka)
+Name[sk]=Poznámkový blok (Príklad)
+Name[sl]=Beležnica (zgled)
+Name[sq]=Notepad (shembull)
+Name[sr]=Бележница (пример)
+Name[sr@Latn]=Beležnica (primer)
+Name[sv]=Notepad (exempel)
+Name[ta]=நோட்பாட் (உதாரணம்)
+Name[te]=నోట్ పేడ్ (ఉదాహరణ)
+Name[tg]=Дафтари ёддошт (мисол)
+Name[th]=โน้ตแพด (ตัวอย่าง)
+Name[tr]=Not defteri (örnek)
+Name[tt]=Däftär (ürnäk)
+Name[uk]=Записна книжка (приклад)
+Name[uz]=Yon daftarcha (misol)
+Name[uz@cyrillic]=Ён дафтарча (мисол)
+Name[ven]=Hau nwalela notsi (Tsumbo)
+Name[vi]=Tập giấy (thí dụ)
+Name[xh]=Iphetshan lokubhala (umzekelo)
+Name[zh_CN]=记事本(例子)
+Name[zh_HK]=記事本(範例)
+Name[zh_TW]=記事本(範例)
+Name[zu]=Incwadi yokubhala (umfanekiso)
+MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
+ServiceTypes=KParts/ReadOnlyPart
+X-TDE-Library=libnotepadpart
+Type=Service
diff --git a/tdeparts/tests/notepad.h b/tdeparts/tests/notepad.h
new file mode 100644
index 000000000..bd502599b
--- /dev/null
+++ b/tdeparts/tests/notepad.h
@@ -0,0 +1,42 @@
+
+#ifndef __notepad_h__
+#define __notepad_h__
+
+#include <tdeparts/genericfactory.h>
+#include <tdeparts/part.h>
+
+class TDEAboutData;
+class TQMultiLineEdit;
+
+/**
+ * Who said writing a part should be complex ? :-)
+ * Here is a very simple kedit-like part
+ * @internal
+ */
+class NotepadPart : public KParts::ReadWritePart
+{
+ Q_OBJECT
+public:
+ NotepadPart( TQWidget*, const char* widgetName,
+ TQObject* parent, const char* name,
+ const TQStringList& args = TQStringList() );
+ virtual ~NotepadPart();
+
+ virtual void setReadWrite( bool rw );
+
+ static TDEAboutData* createAboutData();
+
+protected:
+ virtual bool openFile();
+ virtual bool saveFile();
+
+protected slots:
+ void slotSearchReplace();
+
+protected:
+ TQMultiLineEdit * m_edit;
+};
+
+typedef KParts::GenericFactory<NotepadPart> NotepadFactory;
+
+#endif
diff --git a/tdeparts/tests/notepadpart.cpp b/tdeparts/tests/notepadpart.cpp
new file mode 100644
index 000000000..072503fd1
--- /dev/null
+++ b/tdeparts/tests/notepadpart.cpp
@@ -0,0 +1,5 @@
+#include "notepad.h"
+
+// The entry point for the part.
+K_EXPORT_COMPONENT_FACTORY( libnotepadpart, NotepadFactory )
+
diff --git a/tdeparts/tests/notepadpart.rc b/tdeparts/tests/notepadpart.rc
new file mode 100644
index 000000000..ba30eb322
--- /dev/null
+++ b/tdeparts/tests/notepadpart.rc
@@ -0,0 +1,14 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="NotepadPart" version="2">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Menu name="NotepadSubMenu"><text>Notepad Stuff</text>
+ <Action name="searchreplace"/>
+ </Menu>
+ </Menu>
+ <Menu name="edit"><Text>&amp;Edit</Text>
+ <Action name="searchreplace"/>
+ </Menu>
+</MenuBar>
+<StatusBar/>
+</kpartgui>
diff --git a/tdeparts/tests/parts.cpp b/tdeparts/tests/parts.cpp
new file mode 100644
index 000000000..2fc63c225
--- /dev/null
+++ b/tdeparts/tests/parts.cpp
@@ -0,0 +1,90 @@
+
+#include <tdeparts/event.h>
+
+#include "parts.h"
+
+#include <tqcheckbox.h>
+#include <tqfile.h>
+#include <tqdir.h>
+#include <tqtextstream.h>
+#include <tqmultilineedit.h>
+#include <tqlineedit.h>
+#include <tqvbox.h>
+
+#include <kiconloader.h>
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <kaction.h>
+#include <klocale.h>
+
+Part1::Part1( TQObject *parent, TQWidget * parentWidget )
+ : KParts::ReadOnlyPart( parent, "Part1" )
+{
+ m_instance = new TDEInstance( "tdepartstestpart" );
+ setInstance( m_instance );
+ m_edit = new TQMultiLineEdit( parentWidget );
+ setWidget( m_edit );
+ setXMLFile( "tdepartstest_part1.rc" );
+
+ /*KAction * paBlah = */ new KAction( "Blah", "filemail", 0, actionCollection(), "p1_blah" );
+}
+
+Part1::~Part1()
+{
+ delete m_instance;
+}
+
+bool Part1::openFile()
+{
+ kdDebug() << "Part1: opening " << TQFile::encodeName(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();
+ } else
+ return false;
+ m_edit->setText(s);
+
+ emit setStatusBarText( m_url.prettyURL() );
+
+ return true;
+}
+
+Part2::Part2( TQObject *parent, TQWidget * parentWidget )
+ : KParts::Part( parent, "Part2" )
+{
+ m_instance = new TDEInstance( "part2" );
+ setInstance( m_instance );
+ TQWidget * w = new TQWidget( parentWidget, "Part2Widget" );
+ setWidget( w );
+
+ TQCheckBox * cb = new TQCheckBox( "something", w );
+
+ TQLineEdit * l = new TQLineEdit( "something", widget() );
+ l->move(0,50);
+ // Since the main widget is a dummy one, we HAVE to set
+ // strong focus for it, otherwise we get the
+ // the famous activating-file-menu-switches-part bug.
+ w->setFocusPolicy( TQWidget::ClickFocus );
+
+ // setXMLFile( ... ); // no actions currently
+}
+
+Part2::~Part2()
+{
+ delete m_instance;
+}
+
+void Part2::guiActivateEvent( KParts::GUIActivateEvent * event )
+{
+ if (event->activated())
+ emit setWindowCaption("[part2 activated]");
+}
+
+#include "parts.moc"
diff --git a/tdeparts/tests/parts.h b/tdeparts/tests/parts.h
new file mode 100644
index 000000000..37af4911e
--- /dev/null
+++ b/tdeparts/tests/parts.h
@@ -0,0 +1,43 @@
+
+#ifndef __parts_h__
+#define __parts_h__
+
+#include <tdeparts/part.h>
+
+class TQMultiLineEdit;
+namespace KParts {
+class GUIActivateEvent;
+};
+
+class Part1 : public KParts::ReadOnlyPart
+{
+ Q_OBJECT
+public:
+ Part1( TQObject *parent, TQWidget * parentWidget );
+ virtual ~Part1();
+
+protected:
+ virtual bool openFile();
+
+protected:
+ TQMultiLineEdit * m_edit;
+ TDEInstance *m_instance;
+};
+
+class Part2 : public KParts::Part
+{
+ Q_OBJECT
+public:
+ Part2( TQObject *parent, TQWidget * parentWidget );
+ virtual ~Part2();
+
+protected:
+ // This is not mandatory - only if you care about setting the
+ // part caption when the part is used in a multi-part environment
+ // (i.e. in a part manager)
+ // There is a default impl for ReadOnlyPart...
+ virtual void guiActivateEvent( KParts::GUIActivateEvent * );
+ TDEInstance *m_instance;
+};
+
+#endif
diff --git a/tdeparts/tests/plugin_foobar.rc b/tdeparts/tests/plugin_foobar.rc
new file mode 100644
index 000000000..e614e505f
--- /dev/null
+++ b/tdeparts/tests/plugin_foobar.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartplugin>
+<kpartplugin library="libfoobar">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Action name="searchreplace"/>
+ </Menu>
+ <Menu name="woohoo"><Text>fun</Text>
+ <Action name="searchreplace"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="gah"/>
+</kpartplugin>
diff --git a/tdeparts/tests/plugin_spellcheck.cpp b/tdeparts/tests/plugin_spellcheck.cpp
new file mode 100644
index 000000000..5521bf22f
--- /dev/null
+++ b/tdeparts/tests/plugin_spellcheck.cpp
@@ -0,0 +1,39 @@
+#include "notepad.h" // this plugin applies to a notepad part
+#include <tqmultilineedit.h>
+#include "plugin_spellcheck.h"
+#include <kaction.h>
+#include <kgenericfactory.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+PluginSpellCheck::PluginSpellCheck( TQObject* parent, const char* name,
+ const TQStringList& )
+ : Plugin( parent, name )
+{
+ (void) new KAction( "&Select current line (plugin)", 0, this, TQT_SLOT(slotSpellCheck()),
+ actionCollection(), "spellcheck" );
+}
+
+PluginSpellCheck::~PluginSpellCheck()
+{
+}
+
+void PluginSpellCheck::slotSpellCheck()
+{
+ kdDebug() << "Plugin parent : " << parent()->name() << " (" << parent()->className() << ")" << endl;
+ // The parent is assumed to be a NotepadPart
+ if ( !parent()->inherits("NotepadPart") )
+ KMessageBox::error(0L,"You just called the spell-check action on a wrong part (not NotepadPart)");
+ else
+ {
+ NotepadPart * part = (NotepadPart *) parent();
+ TQMultiLineEdit * widget = (TQMultiLineEdit *) part->widget();
+ widget->selectAll(); //selects current line !
+ }
+}
+
+K_EXPORT_COMPONENT_FACTORY( libspellcheckplugin,
+ KGenericFactory<PluginSpellCheck> );
+
+#include <plugin_spellcheck.moc>
diff --git a/tdeparts/tests/plugin_spellcheck.h b/tdeparts/tests/plugin_spellcheck.h
new file mode 100644
index 000000000..d27966c0c
--- /dev/null
+++ b/tdeparts/tests/plugin_spellcheck.h
@@ -0,0 +1,18 @@
+#ifndef __plugin_spellcheck_h
+#define __plugin_spellcheck_h
+
+#include <tdeparts/plugin.h>
+
+class PluginSpellCheck : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ PluginSpellCheck( TQObject* parent = 0, const char* name = 0,
+ const TQStringList& = TQStringList() );
+ virtual ~PluginSpellCheck();
+
+public slots:
+ void slotSpellCheck();
+};
+
+#endif
diff --git a/tdeparts/tests/plugin_spellcheck.rc b/tdeparts/tests/plugin_spellcheck.rc
new file mode 100644
index 000000000..1980186cf
--- /dev/null
+++ b/tdeparts/tests/plugin_spellcheck.rc
@@ -0,0 +1,15 @@
+<!DOCTYPE kpartplugin>
+<kpartplugin library="libspellcheckplugin">
+<MenuBar>
+ <Menu name="edit"><Text>&amp;Edit</Text>
+ <Action name="spellcheck"/>
+ </Menu>
+ <Menu name="SomePluginMenu"><text>Some Cool Plugin Menu</text>
+ <Action name="spellcheck"/>
+ <Action name="searchreplace"/>
+ <Menu name="WhatASubMenu"><text>Yep</text>
+ <Action name="searchreplace"/>
+ </Menu>
+ </Menu>
+</MenuBar>
+</kpartplugin>
diff --git a/tdeparts/tests/tdepartstest_part1.rc b/tdeparts/tests/tdepartstest_part1.rc
new file mode 100644
index 000000000..9f4a75687
--- /dev/null
+++ b/tdeparts/tests/tdepartstest_part1.rc
@@ -0,0 +1,18 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="Part">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Action name="p1_blah"/>
+ </Menu>
+ <Menu name="Part1Menu"><text>Part1's Menu</text>
+ <Action name="p1_blah"/>
+ <Menu name="Part1Sub"><text>Stupid Submenu</text>
+ <Action name="p1_blah"/>
+ </Menu>
+ </Menu>
+</MenuBar>
+<ToolBar name="Part1-ToolBar">
+ <Action name="p1_blah"/>
+</ToolBar>
+<StatusBar/>
+</kpartgui>
diff --git a/tdeparts/tests/tdepartstest_shell.rc b/tdeparts/tests/tdepartstest_shell.rc
new file mode 100644
index 000000000..52790f9b6
--- /dev/null
+++ b/tdeparts/tests/tdepartstest_shell.rc
@@ -0,0 +1,28 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="Shell">
+<MenuBar>
+ <Menu name="file"><Text>&amp;File</Text>
+ <Action name="open_local_file"/>
+ <Action name="open_remote_file"/>
+ <Separator/>
+ <Action name="edit_file"/>
+ <Action name="close_editor"/>
+ <Merge name="NotepadPart"/>
+ <Separator/>
+ <Merge/>
+ <Separator/>
+ <Action name="shell_quit"/>
+ </Menu>
+ <Merge/>
+ <Menu name="blah"><Text>BlahFoo</Text>
+ <Action name="shell_yami"/>
+ <Menu name="nonsense"><Text>Dummdidumm</Text>
+ <Action name="shell_yasmi"/>
+ </Menu>
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar">
+ <Action name="shell_quit"/>
+</ToolBar>
+<StatusBar/>
+</kpartgui>