KDevelop API Documentation

replace_part.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Jens Dagerbo                                    *
00003  *   jens.dagerbo@swipnet.se                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00012 #include <qwhatsthis.h>
00013 
00014 #include <kaction.h>
00015 #include <kiconloader.h>
00016 #include <klocale.h>
00017 //#include <kgenericfactory.h>
00018 #include <kdevgenericfactory.h>
00019 #include <kdebug.h>
00020 #include <kiconloader.h>
00021 
00022 #include <kdevcore.h>
00023 #include <kdevmainwindow.h>
00024 
00025 #include "replace_widget.h"
00026 #include "replace_part.h"
00027 
00028 static const KAboutData data("kdevreplace", I18N_NOOP("Replace"), "1.0");
00029 
00030 //typedef KGenericFactory<ReplacePart> ReplaceFactory;
00031 //K_EXPORT_COMPONENT_FACTORY( libkdevreplace, ReplaceFactory( "kdevreplace" ) )
00032 
00033 typedef KDevGenericFactory<ReplacePart> ReplaceFactory;
00034 K_EXPORT_COMPONENT_FACTORY(libkdevreplace, ReplaceFactory(&data))
00035 
00036 ReplacePart::ReplacePart(QObject *parent, const char *name, const QStringList& )
00037         : KDevPlugin( "Project Wide Replace", "", parent, name ? name : "ReplacePart" )
00038 {
00039     setInstance(ReplaceFactory::instance());
00040     setXMLFile("kdevpart_replace.rc");
00041 
00042     m_widget = new ReplaceWidget(this);
00043     m_widget->setIcon( SmallIcon("filefind") );
00044     m_widget->setCaption(i18n("Replace"));
00045     
00046     QWhatsThis::add
00047         (m_widget, i18n("<b>Replace</b><p>"
00048                         "This window shows a preview of a string replace "
00049                         "operation. Uncheck a line to exclude that replacement. "
00050                         "Uncheck a file to exclude the whole file from the "
00051                         "operation. "
00052                         "Clicking on a line in the list will automatically "
00053                         "open the corresponding source file and set the "
00054                         "cursor to the line with the match." ));
00055 
00056     mainWindow()->embedOutputView( m_widget, i18n("Replace"), i18n("Project wide string replacement") );
00057 
00058     KAction * action = new KAction(i18n("Find-Select-Replace..."), "replace project",
00059                                    CTRL+SHIFT+Key_R, this, SLOT(slotReplace()), actionCollection(), "edit_replace_across");
00060     action->setToolTip( i18n("Project wide string replacement") );
00061     action->setWhatsThis( i18n("<b>Find-Select-Replace</b><p>"
00062                                "Opens the project wide string replacement dialog. There you "
00063                                "can enter a string or a regular expression which is then "
00064                                "searched for within all files in the locations "
00065                                "you specify. Matches will be displayed in the <b>Replace</b> window, you "
00066                                "can replace them with the specified string, exclude them from replace operation or cancel the whole replace.") );
00067 
00068     core()->insertNewAction( action );
00069 }
00070 
00071 
00072 ReplacePart::~ReplacePart()
00073 {
00074     if ( m_widget )
00075         mainWindow()->removeView( m_widget );
00076     delete m_widget;
00077 }
00078 
00079 void ReplacePart::slotReplace()
00080 {
00081     m_widget->showDialog();
00082 }
00083 
00084 
00085 #include "replace_part.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003