summaryrefslogtreecommitdiffstats
path: root/kate/plugins/autobookmarker
diff options
context:
space:
mode:
Diffstat (limited to 'kate/plugins/autobookmarker')
-rw-r--r--kate/plugins/autobookmarker/Makefile.am17
-rw-r--r--kate/plugins/autobookmarker/autobookmarker.cpp521
-rw-r--r--kate/plugins/autobookmarker/autobookmarker.h137
-rw-r--r--kate/plugins/autobookmarker/ktexteditor_autobookmarker.desktop135
-rw-r--r--kate/plugins/autobookmarker/ktexteditor_autobookmarkerrc18
5 files changed, 828 insertions, 0 deletions
diff --git a/kate/plugins/autobookmarker/Makefile.am b/kate/plugins/autobookmarker/Makefile.am
new file mode 100644
index 000000000..748dbb2e5
--- /dev/null
+++ b/kate/plugins/autobookmarker/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = -I$(top_srcdir)/interfaces $(all_includes)
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = ktexteditor_autobookmarker.la
+
+ktexteditor_autobookmarker_la_SOURCES = autobookmarker.cpp
+ktexteditor_autobookmarker_la_LIBADD = $(top_builddir)/interfaces/ktexteditor/libktexteditor.la
+ktexteditor_autobookmarker_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+kde_services_DATA = ktexteditor_autobookmarker.desktop
+
+confdir=$(kde_confdir)
+conf_DATA = ktexteditor_autobookmarkerrc
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/ktexteditor_autobookmarker.pot
diff --git a/kate/plugins/autobookmarker/autobookmarker.cpp b/kate/plugins/autobookmarker/autobookmarker.cpp
new file mode 100644
index 000000000..af3acbc32
--- /dev/null
+++ b/kate/plugins/autobookmarker/autobookmarker.cpp
@@ -0,0 +1,521 @@
+/*
+ This library is free software you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ file: autobookmarker.cpp
+
+ KTextEditor plugin to add bookmarks to documents.
+ Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003
+*/
+
+//BEGIN includes
+#include "autobookmarker.h"
+
+#include <ktexteditor/markinterfaceextension.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/documentinfo.h>
+#include <ktexteditor/document.h>
+
+#include <kaction.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kgenericfactory.h>
+#include <kiconloader.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kmimetype.h>
+#include <kmimetypechooser.h>
+#include <kprocess.h>
+#include <krun.h>
+#include <kstaticdeleter.h>
+#include <kurl.h>
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qpopupmenu.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qwhatsthis.h>
+#include <qregexp.h>
+
+//#include <kdebug.h>
+//END includes
+
+//BEGIN AutoBookmarker
+K_EXPORT_COMPONENT_FACTORY( ktexteditor_autobookmarker, KGenericFactory<AutoBookmarker>( "ktexteditor_autobookmarker" ) )
+
+AutoBookmarker::AutoBookmarker( QObject *parent,
+ const char* name,
+ const QStringList& /*args*/ )
+ : KTextEditor::Plugin ( (KTextEditor::Document*) parent, name ),
+ KTextEditor::ConfigInterfaceExtension()
+{
+ if ( parent )
+ connect( parent, SIGNAL( completed() ), this, SLOT( slotCompleted() ) );
+}
+
+void AutoBookmarker::addView(KTextEditor::View */*view*/)
+{
+}
+
+void AutoBookmarker::removeView(KTextEditor::View */*view*/)
+{
+}
+
+KTextEditor::ConfigPage * AutoBookmarker::configPage( uint /*number*/, QWidget *parent, const char *name )
+{
+ return new AutoBookmarkerConfigPage( parent, name );
+}
+
+QString AutoBookmarker::configPageName( uint /*p*/ ) const
+{
+// switch (p)
+// {
+// case 0:
+ return i18n("AutoBookmarks");
+// default:
+// return "";
+// }
+}
+
+QString AutoBookmarker::configPageFullName( uint /*p*/ ) const
+{
+// switch (p)
+// {
+// case 0:
+ return i18n("Configure AutoBookmarks");
+// default:
+// return "";
+// }
+}
+
+QPixmap AutoBookmarker::configPagePixmap( uint /*p*/, int size ) const
+{
+ return UserIcon("kte_bookmark", size);
+}
+
+void AutoBookmarker::slotCompleted()
+{
+ // get the document info
+ KTextEditor::DocumentInfoInterface *di =
+ static_cast<KTextEditor::DocumentInfoInterface*>(document()->
+ qt_cast("KTextEditor::DocumentInfoInterface"));
+ QString mt;
+ if ( di ) // we can still try match the URL otherwise
+ mt = di->mimeType();
+
+ QString fileName;
+ if ( document()->url().isValid() )
+ fileName = document()->url().fileName();
+
+ ABEntityList *l = ABGlobal::self()->entities();
+ // for each item, if either mask matches
+ // * apply if onLoad is true
+ ABEntityListIterator it( *l );
+ int n( 0 );
+ bool found;
+ AutoBookmarkEnt *e;
+ while ( ( e = it.current() ) != 0 )
+ {
+ found = ( !e->mimemask.count() && !e->filemask.count() ); // no preferences
+ if ( ! found )
+ found = ( ! mt.isEmpty() && e->mimemask.contains( mt ) );
+ if ( ! found )
+ for( QStringList::Iterator it1 = e->filemask.begin(); it1 != e->filemask.end(); ++it1 )
+ {
+ QRegExp re(*it1, true, true);
+ if ( ( found = ( ( re.search( fileName ) > -1 ) && ( re.matchedLength() == (int)fileName.length() ) ) ) )
+ break;
+ }
+
+ if ( found )
+ applyEntity( e );
+
+ n++;
+ ++it;
+ }
+
+}
+
+void AutoBookmarker::applyEntity( AutoBookmarkEnt *e )
+{
+ KTextEditor::Document *doc = document();
+ KTextEditor::EditInterface *ei = KTextEditor::editInterface( doc );
+ KTextEditor::MarkInterface *mi = KTextEditor::markInterface( doc );
+
+ if ( ! ( ei && mi ) ) return;
+
+ QRegExp re( e->pattern, e->flags & AutoBookmarkEnt::CaseSensitive );
+ re.setMinimal( e->flags & AutoBookmarkEnt::MinimalMatching );
+
+ for ( uint l( 0 ); l < ei->numLines(); l++ )
+ if ( re.search( ei->textLine( l ) ) > -1 )
+ mi->setMark( l, KTextEditor::MarkInterface::Bookmark );
+}
+
+//END
+
+//BEGIN ABGlobal
+ABGlobal *ABGlobal::s_self = 0;
+
+ABGlobal::ABGlobal()
+{
+ m_ents = new ABEntityList;
+ readConfig();
+}
+
+ABGlobal::~ABGlobal()
+{
+ delete m_ents;
+}
+
+static KStaticDeleter<ABGlobal> sdSelf;
+
+ABGlobal *ABGlobal::self()
+{
+ if ( ! s_self )
+ sdSelf.setObject(s_self, new ABGlobal());
+
+ return s_self;
+}
+
+void ABGlobal::readConfig()
+{
+ if ( ! m_ents )
+ m_ents = new ABEntityList;
+ else
+ m_ents->clear();
+ KConfig *config = new KConfig("ktexteditor_autobookmarkerrc");
+
+ uint n( 0 );
+ while ( config->hasGroup( QString("autobookmark%1").arg( n ) ) )
+ {
+ config->setGroup( QString("autobookmark%1").arg( n ) );
+ QStringList filemask = config->readListEntry( "filemask", ';' );
+ QStringList mimemask = config->readListEntry( "mimemask", ';' );
+ int flags = config->readNumEntry( "flags", 1 );
+ AutoBookmarkEnt *e = new AutoBookmarkEnt(
+ config->readEntry( "pattern", "" ),
+ filemask,
+ mimemask,
+ flags
+ );
+
+ m_ents->append( e );
+
+ ++n;
+ }
+
+ delete config;
+}
+
+void ABGlobal::writeConfig()
+{
+ KConfig *config = new KConfig("ktexteditor_autobookmarkerrc");
+
+ // clean the config object
+ QStringList l = config->groupList();
+ for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
+ config->deleteGroup( *it );
+
+ // fill in the current list
+ for ( uint i = 0; i < m_ents->count(); i++ )
+ {
+ AutoBookmarkEnt *e = m_ents->at( i );
+ config->setGroup( QString("autobookmark%1").arg( i ) );
+ config->writeEntry( "pattern", e->pattern );
+ config->writeEntry( "filemask", e->filemask, ';' );
+ config->writeEntry( "mimemask", e->mimemask, ';' );
+ config->writeEntry( "flags", e->flags );
+ }
+
+ config->sync(); // explicit -- this is supposedly handled by the d'tor
+ delete config;
+}
+//END ABGlobal
+
+//BEGIN AutoBookmarkEntItem
+// A QListviewItem which can hold a AutoBookmarkEnt pointer
+class AutoBookmarkEntItem : public QListViewItem
+{
+ public:
+ AutoBookmarkEntItem( KListView *lv, AutoBookmarkEnt *e )
+ : QListViewItem( lv ),
+ ent( e )
+ {
+ redo();
+ };
+ ~AutoBookmarkEntItem(){};
+ void redo()
+ {
+ setText( 0, ent->pattern );
+ setText( 1, ent->mimemask.join("; ") );
+ setText( 2, ent->filemask.join("; ") );
+ }
+ AutoBookmarkEnt *ent;
+};
+//END
+
+//BEGIN AutoBookmarkerEntEditor
+// Dialog for editing a single autobookmark entity
+// * edit the pattern
+// * set the file/mime type masks
+AutoBookmarkerEntEditor::AutoBookmarkerEntEditor( QWidget *parent, AutoBookmarkEnt *e )
+ : KDialogBase( parent, "autobookmark_ent_editor",
+ true, i18n("Edit Entry"),
+ KDialogBase::Ok|KDialogBase::Cancel ),
+ e( e )
+{
+ QFrame *w = makeMainWidget();
+ QGridLayout * lo = new QGridLayout( w, 5, 3 );
+ lo->setSpacing( KDialogBase::spacingHint() );
+
+ QLabel *l = new QLabel( i18n("&Pattern:"), w );
+ lePattern = new QLineEdit( e->pattern, w );
+ l->setBuddy( lePattern );
+ lo->addWidget( l, 0, 0 );
+ lo->addMultiCellWidget( lePattern, 0, 0, 1, 2 );
+ QWhatsThis::add( lePattern, i18n(
+ "<p>A regular expression. Matching lines will be bookmarked.</p>" ) );
+
+ connect( lePattern, SIGNAL(textChanged ( const QString & ) ),this, SLOT( slotPatternChanged( const QString& ) ) );
+
+ cbCS = new QCheckBox( i18n("Case &sensitive"), w );
+ lo->addMultiCellWidget( cbCS, 1, 1, 0, 2 );
+ cbCS->setChecked( e->flags & AutoBookmarkEnt::CaseSensitive );
+ QWhatsThis::add( cbCS, i18n(
+ "<p>If enabled, the pattern matching will be case sensitive, otherwise "
+ "not.</p>") );
+
+ cbMM = new QCheckBox( i18n("&Minimal matching"), w );
+ lo->addMultiCellWidget( cbMM, 2, 2, 0 ,2 );
+ cbMM->setChecked( e->flags & AutoBookmarkEnt::MinimalMatching );
+ QWhatsThis::add( cbMM, i18n(
+ "<p>If enabled, the pattern matching will use minimal matching; if you "
+ "do not know what that is, please read the appendix on regular expressions "
+ "in the kate manual.</p>") );
+
+ l = new QLabel( i18n("&File mask:"), w );
+ leFileMask = new QLineEdit( e->filemask.join( "; " ), w );
+ l->setBuddy( leFileMask );
+ lo->addWidget( l, 3, 0 );
+ lo->addMultiCellWidget( leFileMask, 3, 3, 1, 2 );
+ QWhatsThis::add( leFileMask, i18n(
+ "<p>A list of filename masks, separated by semicolons. This can be used "
+ "to limit the usage of this entity to files with matching names.</p>"
+ "<p>Use the wizard button to the right of the mimetype entry below to "
+ "easily fill out both lists.</p>" ) );
+
+ l = new QLabel( i18n("MIME &types:"), w );
+ leMimeTypes = new QLineEdit( e->mimemask.join( "; " ), w );
+ l->setBuddy( leMimeTypes );
+ lo->addWidget( l, 4, 0 );
+ lo->addWidget( leMimeTypes, 4, 1 );
+ QWhatsThis::add( leMimeTypes, i18n(
+ "<p>A list of mime types, separated by semicolon. This can be used to "
+ "limit the usage of this entity to files with matching mime types.</p>"
+ "<p>Use the wizard button on the right to get a list of existing file "
+ "types to choose from, using it will fill in the file masks as well.</p>" ) );
+
+ QToolButton *btnMTW = new QToolButton(w);
+ lo->addWidget( btnMTW, 4, 2 );
+ btnMTW->setIconSet(QIconSet(SmallIcon("wizard")));
+ connect(btnMTW, SIGNAL(clicked()), this, SLOT(showMTDlg()));
+ QWhatsThis::add( btnMTW, i18n(
+ "<p>Click this button to display a checkable list of mimetypes available "
+ "on your system. When used, the file masks entry above will be filled in "
+ "with the corresponding masks.</p>") );
+ slotPatternChanged( lePattern->text() );
+}
+
+void AutoBookmarkerEntEditor::slotPatternChanged( const QString&_pattern )
+{
+ enableButtonOK( !_pattern.isEmpty() );
+}
+
+void AutoBookmarkerEntEditor::apply()
+{
+ if ( lePattern->text().isEmpty() ) return;
+
+ e->pattern = lePattern->text();
+ e->filemask = QStringList::split( QRegExp("\\s*;\\s*"), leFileMask->text() );
+ e->mimemask = QStringList::split( QRegExp("\\s*;\\s*"), leMimeTypes->text() );
+ e->flags = 0;
+ if ( cbCS->isOn() ) e->flags |= AutoBookmarkEnt::CaseSensitive;
+ if ( cbMM->isOn() ) e->flags |= AutoBookmarkEnt::MinimalMatching;
+}
+
+void AutoBookmarkerEntEditor::showMTDlg()
+{
+ QString text = i18n("Select the MimeTypes for this pattern.\nPlease note that this will automatically edit the associated file extensions as well.");
+ QStringList list = QStringList::split( QRegExp("\\s*;\\s*"), leMimeTypes->text() );
+ KMimeTypeChooserDialog d( i18n("Select Mime Types"), text, list, "text", this );
+ if ( d.exec() == KDialogBase::Accepted ) {
+ // do some checking, warn user if mime types or patterns are removed.
+ // if the lists are empty, and the fields not, warn.
+ leFileMask->setText(d.chooser()->patterns().join("; "));
+ leMimeTypes->setText(d.chooser()->mimeTypes().join("; "));
+ }
+}
+//END
+
+//BEGIN AutoBookmarkerConfigPage
+// TODO allow custom mark types with icons
+AutoBookmarkerConfigPage::AutoBookmarkerConfigPage( QWidget *parent, const char *name )
+ : KTextEditor::ConfigPage( parent, name )
+{
+ QVBoxLayout *lo = new QVBoxLayout( this );
+ lo->setSpacing( KDialogBase::spacingHint() );
+
+ QLabel *l = new QLabel( i18n("&Patterns"), this );
+ lo->addWidget( l );
+ lvPatterns = new KListView( this );
+ lvPatterns->addColumn( i18n("Pattern") );
+ lvPatterns->addColumn( i18n("Mime Types") );
+ lvPatterns->addColumn( i18n("File Masks") );
+ lo->addWidget( lvPatterns );
+ l->setBuddy( lvPatterns );
+ QWhatsThis::add( lvPatterns, i18n(
+ "<p>This list shows your configured autobookmark entities. When a document "
+ "is opened, each entity is used in the following way: "
+ "<ol>"
+ "<li>The entity is dismissed, if a mime and/or filename mask is defined, "
+ "and neither matches the document.</li>"
+ "<li>Otherwise each line of the document is tried against the pattern, "
+ "and a bookmark is set on matching lines.</li></ul>"
+ "<p>Use the buttons below to manage your collection of entities.</p>") );
+
+ QHBoxLayout *lo1 = new QHBoxLayout ( lo );
+ lo1->setSpacing( KDialogBase::spacingHint() );
+
+ btnNew = new QPushButton( i18n("&New..."), this );
+ lo1->addWidget( btnNew );
+ QWhatsThis::add( btnNew, i18n(
+ "Press this button to create a new autobookmark entity.") );
+
+ btnDel = new QPushButton( i18n("&Delete"), this );
+ lo1->addWidget( btnDel );
+ QWhatsThis::add( btnDel, i18n(
+ "Press this button to delete the currently selected entity.") );
+
+ btnEdit = new QPushButton( i18n("&Edit..."), this );
+ lo1->addWidget( btnEdit );
+ QWhatsThis::add( btnEdit, i18n(
+ "Press this button to edit the currently selected entity.") );
+
+ lo1->addStretch( 1 );
+
+ connect( btnNew, SIGNAL(clicked()), this, SLOT(slotNew()) );
+ connect( btnDel, SIGNAL(clicked()), this, SLOT(slotDel()) );
+ connect( btnEdit, SIGNAL(clicked()), this, SLOT(slotEdit()) );
+ connect( lvPatterns, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(slotEdit()) );
+
+ m_ents = new ABEntityList();
+ m_ents->setAutoDelete( true );
+ reset();
+}
+
+// replace the global list with the new one
+void AutoBookmarkerConfigPage::apply()
+{
+ ABGlobal::self()->entities()->clear();
+
+ ABEntityListIterator it ( *m_ents );
+ AutoBookmarkEnt *e;
+
+ while ( (e = it.current()) != 0 )
+ {
+ ABGlobal::self()->entities()->append( e );
+ ++it;
+ }
+
+ ABGlobal::self()->writeConfig();
+
+ // TODO -- how do i refresh all the view menus
+}
+
+// renew our copy of the global list
+void AutoBookmarkerConfigPage::reset()
+{
+ m_ents->clear(); // unused - no reset button currently
+
+ ABEntityListIterator it ( *ABGlobal::self()->entities() );
+ AutoBookmarkEnt *e;
+ while ( (e = it.current()) != 0 )
+ {
+ AutoBookmarkEnt *me = new AutoBookmarkEnt( *e );
+ m_ents->append( me );
+ new AutoBookmarkEntItem( lvPatterns, me );
+ ++it;
+ }
+}
+
+// TODO (so far not used) we have no defaults (except deleting all items??)
+void AutoBookmarkerConfigPage::defaults()
+{
+ // if KMessageBox::warningYesNo()
+ // clear all
+}
+
+// open the edit dialog with a new entity,
+// and add it if the dialog is accepted
+void AutoBookmarkerConfigPage::slotNew()
+{
+ AutoBookmarkEnt *e = new AutoBookmarkEnt();
+ AutoBookmarkerEntEditor dlg( this, e );
+ if ( dlg.exec() )
+ {
+ dlg.apply();
+ new AutoBookmarkEntItem( lvPatterns, e );
+ m_ents->append( e );
+ }
+}
+
+// delete the selected item and remove it from the list view and internal list
+void AutoBookmarkerConfigPage::slotDel()
+{
+ AutoBookmarkEntItem *i = (AutoBookmarkEntItem*)lvPatterns->currentItem();
+ int idx = m_ents->findRef( i->ent );
+ m_ents->remove( idx );
+ delete i;
+}
+
+// open the edit dialog with the selected item
+void AutoBookmarkerConfigPage::slotEdit()
+{
+ AutoBookmarkEnt *e = ((AutoBookmarkEntItem*)lvPatterns->currentItem())->ent;
+ AutoBookmarkerEntEditor dlg( this, e );
+ if ( dlg.exec() )
+ {
+ dlg.apply();
+ ((AutoBookmarkEntItem*)lvPatterns->currentItem())->redo();
+ }
+}
+//END AutoBookmarkerConfigPage
+
+//BEGIN AutoBookmarkEnt
+AutoBookmarkEnt::AutoBookmarkEnt( const QString &p, const QStringList &f, const QStringList &m, int fl )
+ : pattern( p ),
+ filemask( f ),
+ mimemask( m ),
+ flags( fl )
+{;
+}
+//END
+//
+#include "autobookmarker.moc"
diff --git a/kate/plugins/autobookmarker/autobookmarker.h b/kate/plugins/autobookmarker/autobookmarker.h
new file mode 100644
index 000000000..188c8a360
--- /dev/null
+++ b/kate/plugins/autobookmarker/autobookmarker.h
@@ -0,0 +1,137 @@
+/*
+ This library is free software you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ file: autobookmarker.h
+
+ KTextEditor plugin to add bookmarks to documents.
+ Copyright Anders Lund <anders.lund@lund.tdcadsl.dk>, 2003
+*/
+
+#ifndef _AUTOBOOKMARKER_H_
+#define _AUTOBOOKMARKER_H_
+
+#include <ktexteditor/plugin.h>
+#include <ktexteditor/configinterfaceextension.h>
+
+#include <kdialogbase.h>
+
+#include <qptrlist.h>
+#include <qvbox.h>
+
+class AutoBookmarkEnt
+{
+ public:
+ enum REFlags { CaseSensitive=1, MinimalMatching=2 };
+ AutoBookmarkEnt(const QString &p=QString::null,
+ const QStringList &f=QStringList(),
+ const QStringList &m=QStringList(),
+ int flags=1 );
+ ~AutoBookmarkEnt(){};
+ QString pattern;
+ QStringList filemask;
+ QStringList mimemask;
+ int flags;
+};
+
+class AutoBookmarker
+ : public KTextEditor::Plugin, public KTextEditor::PluginViewInterface,
+ public KTextEditor::ConfigInterfaceExtension
+{
+ Q_OBJECT
+ public:
+ AutoBookmarker( QObject *parent = 0,
+ const char* name = 0,
+ const QStringList &args = QStringList() );
+ virtual ~AutoBookmarker() {};
+
+ void addView (KTextEditor::View *view);
+ void removeView (KTextEditor::View *view);
+
+ // ConfigInterfaceExtention
+ uint configPages() const { return 1; };
+ KTextEditor::ConfigPage * configPage( uint number, QWidget *parent, const char *name );
+ QString configPageName( uint ) const;
+ QString configPageFullName( uint ) const;
+ QPixmap configPagePixmap( uint, int ) const;
+ bool abDone;
+
+ private slots:
+ void slotCompleted();
+ void applyEntity( AutoBookmarkEnt *e );
+};
+
+typedef QPtrList<AutoBookmarkEnt> ABEntityList;
+typedef QPtrListIterator<AutoBookmarkEnt> ABEntityListIterator;
+
+/* singleton to keep the data */
+class ABGlobal
+{
+ public:
+ ABGlobal();
+ ~ABGlobal();
+
+ static ABGlobal* self();
+
+ ABEntityList* entities() { return m_ents; };
+ void readConfig();
+ void writeConfig();
+
+ private:
+ ABEntityList *m_ents;
+ static ABGlobal *s_self;
+};
+
+class AutoBookmarkerConfigPage : public KTextEditor::ConfigPage
+{
+ Q_OBJECT
+ public:
+ AutoBookmarkerConfigPage( QWidget *parent, const char *name );
+ virtual ~AutoBookmarkerConfigPage() {};
+
+ virtual void apply();
+ virtual void reset();
+ virtual void defaults();
+
+ private slots:
+ void slotNew();
+ void slotDel();
+ void slotEdit();
+
+ private:
+ class KListView *lvPatterns;
+ class QPushButton *btnNew, *btnDel, *btnEdit;
+ ABEntityList *m_ents;
+};
+
+class AutoBookmarkerEntEditor : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ AutoBookmarkerEntEditor( QWidget *parent, AutoBookmarkEnt *e );
+ ~AutoBookmarkerEntEditor(){};
+
+ void apply();
+
+ private slots:
+ void showMTDlg();
+ void slotPatternChanged( const QString& );
+ private:
+ class QLineEdit *lePattern, *leMimeTypes, *leFileMask;
+ class QCheckBox *cbCS, *cbMM;
+ AutoBookmarkEnt *e;
+};
+
+#endif //_AUTOBOOKMARKER_H_
diff --git a/kate/plugins/autobookmarker/ktexteditor_autobookmarker.desktop b/kate/plugins/autobookmarker/ktexteditor_autobookmarker.desktop
new file mode 100644
index 000000000..a71dbc6be
--- /dev/null
+++ b/kate/plugins/autobookmarker/ktexteditor_autobookmarker.desktop
@@ -0,0 +1,135 @@
+[Desktop Entry]
+Name=KTextEditor Autobookmarker
+Name[af]=KTextEditor OutoBoekmerker
+Name[be]=Аўтаматычны закладкі
+Name[bn]=কে-টেক্সট-এডিটর অটো-মুকমার্কার
+Name[br]=Sinedoù emgefreek evit KTextEditor
+Name[bs]=KTextEditor automatske zabilješke
+Name[ca]=Punts automàtics per al KTextEditor
+Name[cs]=Modul automatických odkazů
+Name[csb]=Aùtomatné wstôwianié załóżków dlô KTextEditor
+Name[de]=KTextEditor: Autom. Lesezeichenmarkierung
+Name[el]=Πρόσθετο αυτόματων σελιδοδεικτών του KTextEditor
+Name[eo]=KTextEditor Aŭtomata legosignigilo
+Name[es]=Automarcadores de KTextEditor
+Name[et]=KTextEditori järjehoidjate märkija
+Name[eu]=KTextEditor-en laster-markatzaile automatikoa
+Name[fa]=چوب الف خودکار KTextEditor
+Name[fi]=KTextEditorin automaattinen kirjanmerkkien tekijä
+Name[fr]=Signets automatiques KTextEditor
+Name[fy]=Automatyske blêdwizer foar de KTekstbewurker
+Name[ga]=Leabharmharcálaí Uathoibríoch KTextEditor
+Name[gl]=Auto-marcador de KTextEditor
+Name[he]= תוסף סימניות אוטומטיות של KTextEditor
+Name[hi]=के-टेक्स्ट-एडिटर ऑटोबुकमार्कर
+Name[hr]=KTextEditor automatske oznake
+Name[hu]=KTextEditor automatikus könyvjelzők
+Name[id]=Penandabuku Otomatis KTextEditor
+Name[is]=KTextEditor sjálfvirkur bókamerkjari
+Name[it]=Segnalibri automatici di KTextEditor
+Name[ja]=KTextEditor 自動ブックマーク
+Name[ka]=KTextEditor-ის ავტოსანიშნე
+Name[kk]=KTextEditor автобетбелгігіші
+Name[km]=វត្ថុ​ចំណាំ​ស្វ័យ​ប្រវត្តិ KTextEditor
+Name[lb]=Automateschen Lieszeechesetzer fir den KTextEditor
+Name[lt]=KTextEditor automatinis žymelių įterpėjas
+Name[lv]=KTextEditor automātiskais grāmatzīmju licējs
+Name[mk]=KTextEditor Автообележувач
+Name[ms]=Penanda buku auto KTextEditor
+Name[nb]=Automatisk bokmerke for KTextEditor
+Name[nds]=KTextEditor -Leestekensetter
+Name[nl]=KTextEditor Autobladwijzers
+Name[nn]=Automatisk bokmerke for KTextEditor
+Name[pa]=ਕੇਪਾਠਸੰਪਾਦਕ ਸਵੈਬੁੱਕਮਾਰਕਰ
+Name[pl]=Automatyczne wstawianie zakładek dla KTextEditor
+Name[pt]=Auto-favoritos do KTextEditor
+Name[pt_BR]=Marca favoritos automático para Editor de textos
+Name[ro]=Semne de carte automate pentru KTextEditor
+Name[ru]=Автозакладки KTextEditor
+Name[rw]=Mushyirahokimenyetsoyikoresha ya KMuhinduziMwandiko
+Name[se]=KTextEditor:a automáhtalaš girjemerkejeaddji
+Name[sk]=Automatické záložky pre KTextEditor
+Name[sl]=Samodejni zaznamki za KTextEditor
+Name[sr]=KTextEditor-ов аутомаркер
+Name[sr@Latn]=KTextEditor-ov automarker
+Name[sv]=Automatiska bokmärken för Ktexteditor
+Name[ta]=கேஉரைதொகுப்பாளர் தானியக்க புத்தக உருவாக்கி
+Name[te]=కెటెక్స్ట్ ఎడిటర్ ఆటొబుక్ మార్కర్
+Name[tg]=Хатчӯбмонии худкори KTextEditor
+Name[th]=ตั้งที่คั่นหน้าอัตโนมัติ ของ KTextEditor
+Name[tr]=KTextEditor Otomatik Sıkkullanılanlar Ekleyici
+Name[tt]=KTextEditor'nıñ Aqıllı Bitbilge
+Name[uk]=Втулок автоматичних закладок KTextEditor
+Name[vi]=Bộ Tự động Đánh dấu KTextEditor
+Name[zh_CN]=KTextEditor 自动书签器
+Comment=Set bookmarks on lines matching a pattern when documents are loaded
+Comment[af]=Stel boekmerke op lyne wat met 'n patroon ooreenstem wanneer dokumente gelaai word.
+Comment[be]=Стварае закладкі для радкоў, якія адпавядаюць шаблону
+Comment[bg]=Установяване на отметки на редовете, които отговарят на зададен шаблон по време на зареждане на файла
+Comment[bn]=ডকুমেন্ট লোড করাকালীন প্রদত্ত নকশার সাথে মেলে এমন সমস্ত লাইন বুকমার্ক করে
+Comment[bs]=Podešava zabilješke na linijama koje odgovaraju uzorku pri učitavanju dokumenta
+Comment[ca]=Estableix punts a les línies coincidents amb un patró quan es carreguen documents
+Comment[cs]=Nastavení záložek do řádek vyhovujících vzoru po nahrání dokumentu
+Comment[csb]=Wstôwiô, òb czas wczëtëwaniô, załóżczi w pasownëch liniach do dónegò mùstra
+Comment[da]=Sæt bogmærker på linjer der matcher et mønster når dokumenter er indlæst
+Comment[de]=Lesezeichen nach bestimmten Mustern auf Zeilen setzen, sobald ein Dokument geladen wird
+Comment[el]=Ορίζει σελιδοδείκτες σε γραμμές που ταιριάζουν σε ένα μοτίβο όταν τα έγγραφα φορτώνονται
+Comment[eo]=Igas legosignojn en linioj, kiuj konvenas ŝablonon, kiam dokumentoj estas ŝarĝataj
+Comment[es]=Pone marcadores en las líneas que coinciden con un patrón definido al cargar documentos.
+Comment[et]=Määrab dokumendi avamisel vastavalt mustrile ridadele järjehoidjad
+Comment[eu]=Eredu batekin bat datozen lerroen laster-markak ezartzen ditu dokumentuak kargatzean
+Comment[fa]=وقتی که مستندات بار می‌شود، چوب الفها را روی خطوط مطابق با الگو تنظیم کنید
+Comment[fi]=Määrittele kirjanmerkkejä riveille, jotka vastaavat kuviota, kun asiakirjoja avataan
+Comment[fr]=Positionne des signets sur les lignes qui correspondent à un motif quand les documents sont chargés
+Comment[fy]=Blêdwizer ynstelle om by it laden fan dokuminten oerienkomstige patroanen
+Comment[ga]=Cruthaigh leabharmharcanna ar línte a mheaitseálann patrún nuair a luchtaítear cáipéisí
+Comment[gl]=Pon marcadores en liñas que se axusten a un patrón durante a carga de documentos
+Comment[he]=קובע סימניות בשורות המתאים לתבנית מסוימת בעת טעינת מסמך
+Comment[hi]=जब दस्तावेज़ लोड हों तो किसी पैटर्न से मेल खाती पंक्तियो में पुस्तचिह्न सेट करें
+Comment[hr]=Pri učitavanju dokumenta postavlja oznake na redovima koji odgovaraju određenom uzorku.
+Comment[hsb]=Staja při začitanju dokumenta znamjenja na linki, kiž wěstemu mustrej wotpowěduja,
+Comment[hu]=Fájl betöltésekor könyvjelzők automatikus létrehozása minta alapján
+Comment[id]=Set bookmark in baris yang cocok dengan sebuah pola jika dokumen dimuatkan
+Comment[is]=Setur bókamerki á línur sem passa ákveðnu mynstri, þegar skjöl eru lesin
+Comment[it]=Imposta dei segnalibri sulle righe corrispondenti a uno schema quando si caricano dei documenti
+Comment[ja]=文書が読み込まれたときに、パターンにマッチした行にブックマークを設定します
+Comment[ka]=დოკუმენტის ჩატვირთვისას სანიშნეების ნიმუშის მიხედვით მითითება
+Comment[kk]=Құжатта үлгі бойынша бетбелгілерді кояды
+Comment[km]=កំណត់​ការចំណាំ​ត្រង់​បន្ទាត់​ដែល​ដូច​នឹង​ឃ្លា ពេល​ឯកសារ​ត្រូវ​បាន​ផ្ទុក
+Comment[lb]=Setzt Lieszeechen op d'Zeilen, déi ee bestëmmtent Muster enthalen, wann d'Dokument geluede gëtt
+Comment[lt]=Įterpia žymeles eilutėse, kurios atitinka tam tikrą derinį, dokumento įkėlimo metu
+Comment[lv]=Ielādējot dokumentu, liek grāmatzīmes rindām, kuras atbilst norādītajam paraugam
+Comment[mk]=Постава обележувачи на линиите кои се поклопуваат со шема кога документите се вчитуваат
+Comment[ms]=Tetapkan penanda buku pada baris yang padan dengan paten apabila dokumen dimuatkan
+Comment[nb]=Bestem bokmerke på linjer som passer til et mønster når dokument blir åpnet
+Comment[nds]=Sett al bi't Laden Leestekens för Regen, op de en Muster passt
+Comment[ne]=कागजात लोड हुँदा बाँन्की मिल्दो पुस्तकचिनोहरू लाइनमा सेट गर्नुहोस्
+Comment[nl]=Plaatsen van bladwijzers op regels die voldoen aan een bepaald patroon zodra het document geopend wordt
+Comment[nn]=Set bokmerke på linjer som passar til eit mønster når dokument vert opna
+Comment[pa]=ਜਦੋਂ ਵੀ ਦਸਤਾਵੇਜ਼ ਨੂੰ ਲੋਡ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੋਵੇ ਤਾਂ ਬੁੱਕਮਾਰਕ ਨੂੰ ਸਤਰ-ਮੇਲ ਤਰਤੀਬ ਨਿਰਧਾਰਿਤ ਕਰੋ
+Comment[pl]=W czasie wczytywanie dokumentu ustawia zakładki w liniach pasujących do podanego wzorca
+Comment[pt]=Coloca favoritos em linhas que condizem com um padrão quando os documentos são carregados.
+Comment[pt_BR]=Configura os favoritos em linhas que combinam com um padrão, quando os documentos forem carregados
+Comment[ro]=La încărcarea documentului setează semne de carte la liniile care se potrivesc cu un model de text
+Comment[ru]=Установка закладок в текстовом документе по шаблону
+Comment[rw]=Gushyiraho ibimenyetso ku mirongo mu guhuza ishusho igihe inyandiko zitangizwa
+Comment[se]=Bidjá girjemearkkaid linnjáide mat heivehit dihto minsttáriid go dokumeanttat rahpejuvvot.
+Comment[sk]=Nastavuje záložky pri načítaní dokumentu na riadky zodpovedajúce vzorke
+Comment[sl]=Nastavi zaznamke v vrsticah, ki se ujemajo vzorcu, ko so dokumenti naloženi
+Comment[sr]=Поставља маркере на линијама које се уклапају у узорак када се учитавају документи
+Comment[sr@Latn]=Postavlja markere na linijama koje se uklapaju u uzorak kada se učitavaju dokumenti
+Comment[sv]=Lägg till bokmärken på rader som motsvarar ett mönster när dokument laddas
+Comment[ta]= ஆவணங்கள் பதிவாகும் போது அமைப்பு புத்தகக்குறிப்பு கோடுகள் பொருத்தும் மாதிரி
+Comment[te]=పత్రాలు ఎక్కించిన తరువాత బాణీకి సరిపొయిన వరుసల మీద బుక్ మార్కులను ఏర్పరుచును
+Comment[tg]=Хатчӯбмонӣ дар старҳои мувофиқи қолиб ҳангоми боркунии ҳуҷҷати матнӣ
+Comment[th]=ตั้งที่คั่นหน้าที่การจับคู่บรรทัดและรูปแบบ เมื่อมีการโหลดเอกสาร
+Comment[tt]=İstälek açqan çaqta sözgeçkä kileşkän yullarına bitbilgelär quya
+Comment[uk]=Встановлює закладки на рядках, що відповідають взірцю, під час завантаження документів
+Comment[vi]=Đặt đánh dấu trên các dòng khớp một mẫu nào đó khi tải tài liệu.
+Comment[zh_CN]=文档装入时根据匹配模式自动设置书签
+Comment[zh_TW]=文件載入時以字串比對演算法來設定書籤。
+X-KDE-Library=ktexteditor_autobookmarker
+ServiceTypes=KTextEditor/Plugin
+Type=Service
+InitialPreference=8
+MimeType=text/plain
diff --git a/kate/plugins/autobookmarker/ktexteditor_autobookmarkerrc b/kate/plugins/autobookmarker/ktexteditor_autobookmarkerrc
new file mode 100644
index 000000000..3ed8fe8c5
--- /dev/null
+++ b/kate/plugins/autobookmarker/ktexteditor_autobookmarkerrc
@@ -0,0 +1,18 @@
+[autobookmark0]
+filemask=*.pl;*.pm
+flags=1
+mimemask=text/x-perl
+pattern=sub \\w+
+
+[autobookmark1]
+filemask=*.hh;*.h
+flags=1
+mimemask=text/x-c++hdr
+pattern=^class\\s+[^;]+$
+
+[autobookmark2]
+filemask=*.js;*.html;*.HTML;*.htm;*.HTM;*.xhtml;*.asp
+flags=1
+mimemask=application/x-javascript;text/html
+pattern=\\s*function\\s+\\w+
+