summaryrefslogtreecommitdiffstats
path: root/kate/tabbarextension
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch)
tree2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /kate/tabbarextension
downloadtdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz
tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/tabbarextension')
-rw-r--r--kate/tabbarextension/Makefile.am17
-rw-r--r--kate/tabbarextension/katetabbarextension.desktop109
-rw-r--r--kate/tabbarextension/plugin_katetabbarextension.cpp530
-rw-r--r--kate/tabbarextension/plugin_katetabbarextension.h322
-rw-r--r--kate/tabbarextension/ui.rc7
5 files changed, 985 insertions, 0 deletions
diff --git a/kate/tabbarextension/Makefile.am b/kate/tabbarextension/Makefile.am
new file mode 100644
index 0000000..eea5072
--- /dev/null
+++ b/kate/tabbarextension/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = libkatetabbarextensionplugin.la
+
+libkatetabbarextensionplugin_la_SOURCES = plugin_katetabbarextension.cpp
+libkatetabbarextensionplugin_la_LIBADD = -lkateinterfaces
+libkatetabbarextensionplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+pluginsdir = $(kde_datadir)/kate/plugins/katetabbarextension
+plugins_DATA = ui.rc
+
+kde_services_DATA = katetabbarextension.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/katetabbarextension.pot
diff --git a/kate/tabbarextension/katetabbarextension.desktop b/kate/tabbarextension/katetabbarextension.desktop
new file mode 100644
index 0000000..0a54045
--- /dev/null
+++ b/kate/tabbarextension/katetabbarextension.desktop
@@ -0,0 +1,109 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=Kate/Plugin
+X-KDE-Library=libkatetabbarextensionplugin
+X-Kate-Version=2.5
+Name=Kate Tab Bar Extension
+Name[bs]=Kate tab bar ekstenzija
+Name[ca]=Extensió de barra de pestanyes per Kate
+Name[cs]=Rozšiření se záložkovou lištou
+Name[da]=Kate Fanebladslinjeudvidelse
+Name[de]=Unterfensterleiste für Kate
+Name[el]=Επέκταση γραμμής καρτελών του Kate
+Name[eo]=Tablistela kromaĵo por Kodredaktilo
+Name[es]=Extensión de la barra de pestañas de Kate
+Name[et]=Kate kaardirea laiend
+Name[eu]=Kateren fitxa-barra hedapena
+Name[fa]=توسعۀ میله تب Kate
+Name[fi]=Kate tabulointipalkkilaajennus
+Name[fr]=Extension de la barre d'onglets pour Kate
+Name[fy]=Kate Tabbalke-ekstinsje
+Name[ga]=Eisínteacht Barra Cluaisíní Kate
+Name[gl]=Extensión de Barra de Páxina para Kate
+Name[hi]=के-एटीई टैब पट्टी एक्सटेंशन
+Name[hr]=Kate proširenje za trake kartica
+Name[hu]=Kate fülsáv
+Name[is]=Kate flipaviðbót
+Name[it]=Estensione di Kate per la barra delle linguette
+Name[ja]=Kate タブバーエクステンション
+Name[ka]=Kate ჩანართთა ზოლის გაფართოება
+Name[kk]=Kate койындылар панелі
+Name[km]=ផ្នែក​បន្ថែម​របារ​ថេប​របស់ Kate
+Name[lt]=Kate kortelių juostos plėtinys
+Name[mk]=Лента со ливчиња за Кате
+Name[ms]=Sambungan Bar Tab Kate
+Name[nb]=Kate Tablinje-utvidelse
+Name[nds]=Kate-Ünnerfinsterbalken
+Name[ne]=केट ट्याब पट्टी विस्तार
+Name[nl]=Kate Tabbalk-extensie
+Name[nn]=Kate fanelinjetillegg
+Name[pa]=ਕੇਟ ਟੈਬ ਪੱਟੀ ਵਿਹਾਰ
+Name[pl]=Rozszerzenie paska kart dla Kate
+Name[pt]=Extensão de Barra de Página do Kate
+Name[pt_BR]=Extensão da Barra de Abas do Kate
+Name[ru]=Панель вкладок
+Name[sk]=Rozšírenie pre pruh kariet v Kate
+Name[sl]=Razširitev Vrstica z zavihki za Kate
+Name[sr]=Трака језичака, проширење за Kate
+Name[sr@Latn]=Traka jezičaka, proširenje za Kate
+Name[sv]=Kate flikradsutökning
+Name[ta]=கேட் தத்தல் பட்டி விரிவாக்கம்
+Name[tg]=Воридотҳо барои Kate
+Name[tr]=Kate Sekme Çubuğu Uzantısı
+Name[uk]=Розширення смужки вкладок Kate
+Name[vi]=Phần mở rộng thanh thẻ Kate
+Name[zh_CN]=Kate 标签栏扩展
+Name[zh_TW]=Kate Tab 列延伸
+Comment=Adds a tab bar to Kate's main window
+Comment[bg]=Добавяне на лента за отворените прозорци в главния прозорец на редактора
+Comment[bs]=Dodaje traku sa karticama na Kate glavni prozor
+Comment[ca]=Afegeix una barra de pestanyes a la finestra principal de Kate
+Comment[cs]=Přidá lištu se záložkami do okna Kate
+Comment[da]=Tilføjer en fanebladslinje til Kate's hovedvindue
+Comment[de]=Eine Unterfensterleiste mit allen geöffneten Dokumenten in Kate
+Comment[el]=Προσθέτει μία γραμμή στηλοθέτη στο κύριο παράθυρο του Kate
+Comment[eo]=Aldonas tablistelon al Kodredaktila ĉeffenestro
+Comment[es]=Añada una barra de pestañas a la ventana principal de Kate
+Comment[et]=Lisab Kate peaaknasse kaardirea
+Comment[eu]=Kateren leiho nagusiari fitxa-barra gehitzen dio
+Comment[fa]=میله تب را به پنجرۀ اصلی Kate اضافه می‌کند.
+Comment[fi]=Lisää tabulointipalkin Katen pääikkunaan
+Comment[fr]=Ajoute une barre d'onglet dans la fenêtre principale de Kate
+Comment[fy]=Heakket in taakbalke ta oan it haadfinster fan Kate
+Comment[ga]=Cuir barra cluaisíní le príomhfhuinneog Kate
+Comment[gl]=Engade unha barra de páxinas á fiestra principal de Kate
+Comment[hi]=केएटीई के मुख्य विंडो में एक टैब पट्टी जोड़ता है
+Comment[hr]=Dodaje traku kartica u glavni prozor aplikacije Kate
+Comment[hu]=Hozzáad egy lapozósávot a Kate főablakához
+Comment[is]=Bætir við flipaslá í aðalglugga Kate
+Comment[it]=Aggiunge una barra delle linguette alla finestra principale di Kate
+Comment[ja]=Kate のメインウインドウにタブバーを追加します
+Comment[ka]=Kateის მთავარ ფანჯარას ამატებს ჩანართთა ზოლს
+Comment[kk]=Kate негізгі терезесіне қойындылар панелін қосады
+Comment[km]=បន្ថែម​របារ​ថេប​ទៅ​បង្អួច​មេ​របស់ Kate
+Comment[lt]=Įdeda kortelių juostą į Kate langą
+Comment[mk]=Додава лента со ливчиња на главниот прозорец на Кате
+Comment[ms]=Tambah bar tab kepada tetingkap utama
+Comment[nb]=Legger til en tabulatorlinje i Kates hovedvindu
+Comment[nds]=Föögt dat Hööftfinster vun Kate en Ünnerfinsterbalken to
+Comment[ne]=केटको मुख्य सञ्झ्यालमा ट्याब पट्टी थप्दछ
+Comment[nl]=Voegt een tabbalk toe aan het hoofdvenster van Kate
+Comment[nn]=Legg til ei fanelinje i hovudvindauget til Kate
+Comment[pa]=ਕੇਟ ਦੇ ਮੁੱਖ ਝਰੋਖੇ ਵਿੱਚ ਇੱਕ ਟੈਬ ਜੋੜੋ
+Comment[pl]=Dodaje pasek kart do głównego okna Kate
+Comment[pt]=Adiciona uma barra de páginas à janela principal do Kate
+Comment[pt_BR]=Adiciona uma barra de abas na janela principal do Kate
+Comment[ru]=Добавляет панель вкладок с именами файлов в окно Kate
+Comment[sk]=Pridá pruh kariet do hlavného okna Kate
+Comment[sl]=Doda vrstico z zavihki v glavno okno Kate
+Comment[sr]=Додаје траку са језичцима у главни прозор Kate
+Comment[sr@Latn]=Dodaje traku sa jezičcima u glavni prozor Kate
+Comment[sv]=Lägger till en flikrad i Kates huvudfönster
+Comment[ta]=கேட்ஸ்ன் முக்கிய சாளரத்தில் ஒரு தத்தல் பட்டியைச் சேர்க்கிறது
+Comment[tg]=Панели воридотҳоро ба тирезаи Kate илова мекунад
+Comment[tr]=Kate'in ana penceresine bir sekme çubuğu ekler
+Comment[uk]=Додає смужку вкладок до головного вікна Kate
+Comment[vi]=Thêm một thanh thẻ vào cửa sổ chính của Kate
+Comment[zh_CN]=在 Kate 的主窗口添加一个标签栏
+Comment[zh_TW]=新增 tab 列到 Kate 主視窗
+author=Dominik Haumann, dhdev@gmx.de
diff --git a/kate/tabbarextension/plugin_katetabbarextension.cpp b/kate/tabbarextension/plugin_katetabbarextension.cpp
new file mode 100644
index 0000000..7004ff8
--- /dev/null
+++ b/kate/tabbarextension/plugin_katetabbarextension.cpp
@@ -0,0 +1,530 @@
+/***************************************************************************
+ plugin_katetabbarextension.cpp
+ -------------------
+ begin : 2004-04-20
+ copyright : (C) 2004 by Dominik Haumann
+ email : dhdev@gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+
+// BEGIN INCLUDES
+#include "plugin_katetabbarextension.h"
+
+#include <kaction.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kglobalsettings.h>
+
+#include <kdebug.h>
+#include <ktoolbar.h>
+#include <kconfig.h>
+#include <kiconloader.h>
+#include <kfiledialog.h>
+
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+// END
+
+class PluginView : public KXMLGUIClient
+{
+ friend class KatePluginTabBarExtension;
+
+ public:
+ Kate::MainWindow *win;
+ KateTabBarExtension* tabbar;
+};
+
+extern "C"
+{
+ void* init_libkatetabbarextensionplugin()
+ {
+ KGlobal::locale()->insertCatalogue("katetabbarextension");
+ return new KatePluginFactory;
+ }
+}
+
+KatePluginFactory::KatePluginFactory()
+{
+ s_instance = new KInstance( "kate" );
+}
+
+KatePluginFactory::~KatePluginFactory()
+{
+ delete s_instance;
+}
+
+QObject* KatePluginFactory::createObject(
+ QObject* parent, const char* name, const char*, const QStringList & )
+{
+ return new KatePluginTabBarExtension( parent, name );
+}
+
+KInstance* KatePluginFactory::s_instance = 0L;
+
+// BEGIN KatePluginTabBarExtension
+KatePluginTabBarExtension::KatePluginTabBarExtension(
+ QObject* parent, const char* name )
+ : Kate::Plugin ( (Kate::Application*)parent, name ),
+ pConfig(new KConfig("katetabbarextensionpluginrc"))
+{
+ pConfig->setGroup("global");
+}
+
+KatePluginTabBarExtension::~KatePluginTabBarExtension()
+{
+ while (m_views.count() > 0)
+ {
+ removeView(m_views.at(0)->win);
+ }
+
+ delete pConfig;
+}
+
+void KatePluginTabBarExtension::addView(Kate::MainWindow *win)
+{
+ PluginView *view = new PluginView ();
+
+ bool bHoriz = pConfig->readBoolEntry("horizontal orientation", true);
+ bool sort = pConfig->readBoolEntry("sort", true);
+
+ view->tabbar = new KateTabBarExtension( application()->documentManager(),
+ win, bHoriz, sort, 0, "tabs_hbox");
+
+ new KWidgetAction(view->tabbar, "tab_bar_widget",
+ KShortcut::null(), 0, 0, view->actionCollection(), "tabbar_widget");
+
+ view->setInstance (new KInstance("kate"));
+ view->setXMLFile("plugins/katetabbarextension/ui.rc");
+ win->guiFactory()->addClient (view);
+ view->win = win;
+
+ m_views.append (view);
+
+ KToolBar* toolbar = dynamic_cast<KToolBar*>
+ (win->guiFactory()->container("tabbarExtensionToolBar", view));
+ if (toolbar) {
+ connect(toolbar, SIGNAL( orientationChanged(Orientation) ),
+ view->tabbar, SLOT( slotMoved(Orientation) ));
+ }
+}
+
+void KatePluginTabBarExtension::removeView(Kate::MainWindow *win)
+{
+ for (uint z=0; z < m_views.count(); z++) {
+ if (m_views.at(z)->win == win)
+ {
+ PluginView *view = m_views.at(z);
+
+ // the last tabbar, save options
+ if (m_views.count() == 1)
+ {
+ pConfig->writeEntry("horizontal orientation",
+ view->tabbar->orientation()==Qt::Horizontal?true:false);
+ pConfig->writeEntry("sort", view->tabbar->sortByName());
+ pConfig->sync();
+ }
+
+ m_views.remove (view);
+ win->guiFactory()->removeClient (view);
+ delete view->tabbar;
+ delete view;
+ }
+ }
+}
+
+Kate::PluginConfigPage* KatePluginTabBarExtension::configPage(
+ uint, QWidget *w, const char* /*name*/)
+{
+ KateTabBarExtensionConfigPage* p = new KateTabBarExtensionConfigPage(this, w);
+ initConfigPage( p );
+ connect( p, SIGNAL(configPageApplyRequest(KateTabBarExtensionConfigPage*)),
+ SLOT(applyConfig(KateTabBarExtensionConfigPage*)) );
+ return (Kate::PluginConfigPage*)p;
+}
+
+void KatePluginTabBarExtension::initConfigPage( KateTabBarExtensionConfigPage* p )
+{
+ p->pSortAlpha->setChecked(m_views.at(0)->tabbar->sortByName());
+}
+
+void KatePluginTabBarExtension::applyConfig( KateTabBarExtensionConfigPage* p )
+{
+ m_views.at(0)->tabbar->setSortByName(p->pSortAlpha->isChecked());
+ // sync m_config in destructor
+}
+// END KatePluginTabBarExtension
+
+// BEGIN KateTabBarButton
+KateTabBarButton::KateTabBarButton(Kate::ViewManager* pViewManager,
+ Kate::Document *pDoc, QWidget * parent, const char * name)
+ : QPushButton(parent, name),
+ modified(false),
+ myDocID(pDoc->documentNumber()),
+ doc(pDoc),
+ viewManager(pViewManager)
+{
+ setFlat(true);
+ setToggleButton(true);
+ setFocusPolicy(QWidget::NoFocus);
+
+ setText(pDoc->docName());
+
+ connect(this, SIGNAL(toggled(bool)), SLOT(setOn(bool)));
+}
+
+KateTabBarButton::~KateTabBarButton() {}
+
+uint KateTabBarButton::documentNumber()
+{
+ return myDocID;
+}
+
+void KateTabBarButton::setDirty(bool d)
+{
+ if (d) {
+ setIconSet(SmallIconSet("cancel"));
+ } else {
+ if (modified) setIconSet(SmallIconSet("modified"));
+ else setIconSet(QIconSet());
+ }
+}
+
+void KateTabBarButton::setText( const QString& newText)
+{
+ QToolTip::remove(this);
+
+ if (newText.length() > 20) {
+ // squeeze to length 17+3=20
+ QPushButton::setText(newText.left(9) + "..." + newText.right(8));
+ QToolTip::add(this, newText);
+ } else {
+ QPushButton::setText(newText);
+ }
+}
+
+QString KateTabBarButton::fullName() const
+{
+ if (doc) {
+ return doc->docName();
+ } else {
+ return QString("");
+ }
+}
+
+void KateTabBarButton::triggerModified()
+{
+ modified = !modified;
+ if (modified) {
+ QColor c(255, 0, 0);
+ setPaletteForegroundColor( c );
+ setIconSet(SmallIconSet("modified"));
+ } else {
+ QColor c(KGlobalSettings::textColor());
+ setPaletteForegroundColor( c );
+ setIconSet(QIconSet());
+ }
+}
+
+void KateTabBarButton::setOn(bool on)
+{
+ disconnect( SIGNAL(toggled(bool)));
+// kdDebug() << "setOn: " << (int)on << endl;
+ if ((!on) && viewManager->activeView()->document()->documentNumber()
+ == documentNumber()) {
+// kdDebug() << "setOn aborted " << endl;
+ QPushButton::setOn(true);
+ } else {
+ QPushButton::setOn(on);
+
+ if (on) emit myToggled(this);
+ }
+ connect(this, SIGNAL(toggled(bool)), SLOT(setOn(bool)));
+}
+// END KateTabBarButton
+
+// BEGIN KateTabBarExtension
+KateTabBarExtension::KateTabBarExtension( Kate::DocumentManager *pDocManager,
+ Kate::MainWindow *win, bool bHorizOrientation, bool bSort,
+ QWidget* parent, const char* name, WFlags f )
+ : QWidget(parent, name, f),
+ pCurrentTab(0), m_win(win), m_docManager(pDocManager), m_sort(false)
+{
+ if (bHorizOrientation) {
+ top = new QBoxLayout(this, QBoxLayout::LeftToRight);
+ m_orientation = Qt::Horizontal;
+ } else {
+ top = new QBoxLayout(this, QBoxLayout::TopToBottom);
+ m_orientation = Qt::Vertical;
+ }
+
+ // add all already existing documents to the tabbar
+ for (uint i = 0; i < pDocManager->documents(); i++)
+ {
+ slotDocumentCreated (pDocManager->document(i));
+ }
+
+ connect(m_win->viewManager(), SIGNAL(viewChanged()), SLOT(slotViewChanged()));
+ connect(pDocManager,
+ SIGNAL(documentCreated(Kate::Document *)),
+ SLOT(slotDocumentCreated(Kate::Document *)));
+ connect(pDocManager,
+ SIGNAL(documentDeleted(uint)),
+ SLOT(slotDocumentDeleted(uint)));
+
+ setSortByName(bSort);
+}
+
+KateTabBarExtension::~KateTabBarExtension() {}
+
+void KateTabBarExtension::slotMoved(Orientation o)
+{
+ // the tabbar moved (top, right, bottom, left or fluently)
+ switch (o) {
+ case Qt::Vertical:
+ top->setDirection(QBoxLayout::TopToBottom);
+ break;
+
+ case Qt::Horizontal:
+ top->setDirection(QBoxLayout::LeftToRight);
+ break;
+ }
+
+ m_orientation = o;
+}
+
+Qt::Orientation KateTabBarExtension::orientation() const
+{
+ return m_orientation;
+}
+
+bool KateTabBarExtension::sortByName() const
+{
+ return m_sort;
+}
+
+void KateTabBarExtension::setSortByName(bool sbn)
+{
+ if (m_sort != sbn) {
+ m_sort = sbn;
+ if (m_sort)
+ updateSort();
+ }
+}
+
+void KateTabBarExtension::updateSort()
+{
+// kdDebug() << "updateSort called" << endl;
+
+ if (sortByName()) {
+ // remove all tabs from the tabbar
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ top->remove(tab);
+ }
+
+ // now sort
+ m_tabs.sort();
+
+ // and finally add tabs again. FIXME: Is there a better way? :(
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ top->addWidget(tab);
+ }
+ }
+}
+
+void KateTabBarExtension::slotDocumentCreated (Kate::Document *doc)
+{
+// kdDebug() << "slotDocumentCreated" << endl;
+ if (!doc) return;
+
+ KateTabBarButton* tab = new KateTabBarButton(m_win->viewManager(), doc, this);
+ connect(tab, SIGNAL(myToggled(KateTabBarButton*)),
+ SLOT(slotActivateView(KateTabBarButton*)));
+ connect(doc, SIGNAL(nameChanged(Kate::Document *)),
+ SLOT(slotNameChanged(Kate::Document *)));
+ connect(doc, SIGNAL(modStateChanged(Kate::Document *)),
+ SLOT(slotModChanged(Kate::Document *)));
+ connect(doc,
+ SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),
+ SLOT(slotModifiedOnDisc(Kate::Document *, bool, unsigned char)));
+ if(doc->isModified()) tab->triggerModified();
+ tab->show();
+ top->addWidget(tab);
+ m_tabs.append(tab);
+
+ updateSort();
+}
+
+void KateTabBarExtension::slotDocumentDeleted (uint documentNumber)
+{
+// kdDebug() << "slotDocumentDeleted " << endl;
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->documentNumber() == documentNumber) {
+ tab->disconnect();
+ top->remove(tab);
+ m_tabs.removeRef(tab);
+ delete tab;
+ tab = 0;
+ break;
+ }
+ }
+}
+
+void KateTabBarExtension::slotActivateView(KateTabBarButton* newTab)
+{
+// kdDebug() << "slotActiavateView" << endl;
+ pCurrentTab = newTab;
+ if (pCurrentTab) {
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->isOn() && tab != pCurrentTab)
+ tab->setOn(false);
+ }
+ uint id = pCurrentTab->documentNumber();
+ m_win->viewManager()->activateView( id );
+ }
+}
+
+void KateTabBarExtension::slotModChanged (Kate::Document *doc)
+{
+// kdDebug() << "slotModChanged" << endl;
+
+ if (!doc) return;
+
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->documentNumber() == doc->documentNumber()) {
+ // found
+ tab->triggerModified();
+ break;
+ }
+ }
+}
+
+void KateTabBarExtension::slotModifiedOnDisc (
+ Kate::Document *doc, bool b, unsigned char /*reason*/)
+{
+// kdDebug() << "slotModifiedOnDisc: " << (int)b << endl;
+
+ // find corresponding tab
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->documentNumber() == doc->documentNumber()) {
+ tab->setDirty(b);
+ }
+ }
+}
+
+void KateTabBarExtension::slotNameChanged (Kate::Document *doc)
+{
+ if (!doc) return;
+// kdDebug() << "slotNameChanged " << doc->docName() << endl;
+
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->documentNumber() == doc->documentNumber()) {
+ tab->setText(doc->docName());
+ break;
+ }
+ }
+
+ updateSort();
+}
+
+void KateTabBarExtension::slotViewChanged ()
+{
+// kdDebug() << "slotVieChanged()" << endl;
+ Kate::View *view = m_win->viewManager()->activeView();
+ if (!view) return;
+
+ KateTabBarButton* tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->documentNumber()
+ == ((Kate::Document *)view->getDoc())->documentNumber()) {
+ pCurrentTab = tab;
+ for (tab = m_tabs.first(); tab; tab = m_tabs.next() ) {
+ if (tab->isOn()) tab->setOn(false);
+ }
+ if (!pCurrentTab->isOn()) pCurrentTab->setOn(true);
+
+ break;
+ }
+ }
+}
+// END KateTabBarExtension
+
+// BEGIN KateTabBarExtensionConfigPage
+KateTabBarExtensionConfigPage::KateTabBarExtensionConfigPage(
+ QObject* /*parent*/ /*= 0L*/, QWidget *parentWidget /*= 0L*/)
+ : Kate::PluginConfigPage( parentWidget )
+{
+ QVBoxLayout* top = new QVBoxLayout(this, 0,
+ KDialogBase::spacingHint());
+
+ QGroupBox* gb = new QGroupBox( i18n("Sorting Behavior"),
+ this, "tab_bar_extension_config_page_layout" );
+ gb->setColumnLayout(1, Qt::Vertical);
+ gb->setInsideSpacing(KDialogBase::spacingHint());
+ pSortAlpha = new QCheckBox(i18n("Sort files alphabetically"), gb);
+
+ top->add(gb);
+ top->addStretch(1);
+// throw signal changed
+ connect(pSortAlpha, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+}
+
+KateTabBarExtensionConfigPage::~KateTabBarExtensionConfigPage() {}
+
+void KateTabBarExtensionConfigPage::apply()
+{
+ emit configPageApplyRequest( this );
+}
+// END KateTabBarExtensionConfigPage
+
+
+// BEGIN MyPtrList implementaion
+int MyPtrList::compareItems ( QPtrCollection::Item item1_,
+ QPtrCollection::Item item2_ )
+{
+ KateTabBarButton* item1 = reinterpret_cast<KateTabBarButton*>(item1_);
+ KateTabBarButton* item2 = reinterpret_cast<KateTabBarButton*>(item2_);
+
+ if (item1->fullName().lower() < item2->fullName().lower()) {
+// kdDebug() << item1->fullName().lower() << " < "
+// << item2->fullName().lower() << endl;
+ return -1;
+ } else {
+ if (item1->fullName().lower() > item2->fullName().lower()) {
+// kdDebug() << item1->fullName().lower() << " > "
+// << item2->fullName().lower() << endl;
+ return 1;
+ } else {
+// kdDebug() << item1->fullName().lower() << " == "
+// << item2->fullName().lower() << endl;
+ return 0;
+ }
+ }
+}
+// END MyPtrList implementaion
+
+#include "plugin_katetabbarextension.moc"
diff --git a/kate/tabbarextension/plugin_katetabbarextension.h b/kate/tabbarextension/plugin_katetabbarextension.h
new file mode 100644
index 0000000..6b53444
--- /dev/null
+++ b/kate/tabbarextension/plugin_katetabbarextension.h
@@ -0,0 +1,322 @@
+/***************************************************************************
+ plugin_katetabbarextension.h
+ -------------------
+ begin : 2004-04-20
+ copyright : (C) 2004 by Dominik Haumann
+ email : dhdev@gmx.de
+ ***************************************************************************/
+
+/***************************************************************************
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#ifndef _PLUGIN_TABBAREXTENSION_H_
+#define _PLUGIN_TABBAREXTENSION_H_
+
+#include <kate/application.h>
+#include <kate/documentmanager.h>
+#include <kate/document.h>
+#include <kate/mainwindow.h>
+#include <kate/plugin.h>
+#include <kate/view.h>
+#include <kate/viewmanager.h>
+#include <kate/pluginconfiginterface.h>
+#include <kate/pluginconfiginterfaceextension.h>
+
+#include <klibloader.h>
+#include <klocale.h>
+#include <ktoolbar.h>
+
+#include <qwidget.h>
+#include <qpushbutton.h>
+#include <qptrlist.h>
+
+class QBoxLayout;
+class QCheckBox;
+class KateTabBarButton;
+
+/**
+ * Same as QPtrList. Only difference is: overwrite comapreItems() for sorting reason.
+ */
+class MyPtrList : public QPtrList <KateTabBarButton>
+{
+ public:
+ MyPtrList() { QPtrList<KateTabBarButton>::QPtrList(); }
+
+ virtual int compareItems ( QPtrCollection::Item item1_, QPtrCollection::Item item2_ );
+};
+
+class KatePluginFactory : public KLibFactory
+{
+ Q_OBJECT
+
+ public:
+ KatePluginFactory();
+ virtual ~KatePluginFactory();
+
+ virtual QObject* createObject( QObject* parent = 0, const char* pname = 0,
+ const char* name = "QObject", const QStringList &args = QStringList() );
+
+ private:
+ static KInstance* s_instance;
+};
+
+/**
+ * This class implements a single tab. Every tab represents a document and shows
+ * the current flag (modified: true or false).
+ */
+class KateTabBarButton: public QPushButton
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * constructor
+ * @param pViewManager pointer to kate's the view manager
+ * @param pDoc pointer to the document, that the tab button represents
+ * @param parent parent widget
+ * @param name name of the tab button
+ */
+ KateTabBarButton(Kate::ViewManager* pViewManager, Kate::Document *pDoc,
+ QWidget* parent = 0, const char * name = 0);
+
+ /**
+ * standard destructor (emtpy)
+ */
+ ~KateTabBarButton();
+
+ /**
+ * @return the unique document ID
+ */
+ uint documentNumber();
+
+ /**
+ * get the document's full name (eg. main.cpp), used for comparison
+ * @return the document's name
+ */
+ QString fullName() const;
+
+ /**
+ * negate the modified flag and change the button color
+ * (usually red or black)
+ */
+ void triggerModified();
+
+ /**
+ * dirty flag indicates whether the file was modified on disk
+ * @param d if true, a small warning icon appears
+ */
+ void setDirty(bool d);
+
+ /**
+ * set text for this tab
+ * @param newText new text
+ */
+ virtual void setText( const QString& newText);
+
+ signals:
+ /**
+ * signal that is only emitted when the toggle button toggles to state 'on'
+ * @param tab pointer to the button that emitted the signal
+ */
+ void myToggled(KateTabBarButton* tab);
+
+ public slots:
+ /**
+ * control the ToggleButton
+ * @param on if true, the button is toggled on
+ */
+ virtual void setOn(bool on);
+
+ private:
+ bool modified; ///< if true, doc is modified
+ uint myDocID; ///< unique document ID
+ Kate::Document *doc; ///< pointer to the doc
+ Kate::ViewManager *viewManager; ///< pointer to the view manager
+};
+
+/**
+ * This class handels all tabs and implements a full-featured "tabbar".
+ */
+class KateTabBarExtension : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * constructor
+ * @param pDocManager pointer to kate's document manager
+ * @param win pinter to the main window
+ * @param bHorizOrientation true, if orientation is Qt::Horizontal
+ * @param bSort true, if orientation is Qt::Horizontal
+ * @param parent parent widget
+ * @param name name of widget
+ * @param f widget flags
+ */
+ KateTabBarExtension( Kate::DocumentManager *pDocManager,
+ Kate::MainWindow *win, bool bHorizOrientation, bool bSort,
+ QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
+
+ /** standard destructor */
+ ~KateTabBarExtension();
+
+ /**
+ * @return the tabbar's orientation
+ */
+ Qt::Orientation orientation() const;
+
+ /**
+ * @return true, when sorting is alphabetically
+ */
+ bool sortByName() const;
+
+ /**
+ * set sorting type
+ * @param sbn if true, sort by filename.lower()
+ */
+ void setSortByName(bool sbn);
+
+ /**
+ * sort all tabs
+ */
+ void updateSort();
+
+ public slots:
+ /**
+ * called when a new document is created/loaded
+ * @param doc the new document
+ */
+ void slotDocumentCreated (Kate::Document *doc);
+
+ /**
+ * called when an existing document is being deleted
+ * @param documentNumber ID of the document
+ */
+ void slotDocumentDeleted (uint documentNumber);
+
+ /**
+ * called whenever the view changes
+ * @param v pointer to the button that represents the active view
+ */
+ void slotActivateView(KateTabBarButton* v);
+
+ /**
+ * called when the document's modified flag changes
+ * @param doc the document
+ */
+ void slotModChanged (Kate::Document *doc);
+
+ /**
+ * called when the document changed on disk [NOT SUPPORTED AT THE MOMENT]
+ * @param doc the document
+ * @param b modified flag
+ * @param reason the reason why the file changed
+ */
+ void slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason);
+
+ /**
+ * called when the document's name changed
+ * @param doc the document
+ */
+ void slotNameChanged (Kate::Document *doc);
+
+ /**
+ * called when the active view changes
+ */
+ void slotViewChanged ();
+
+ /**
+ * called whenever the toolbar's orientation changes
+ * @param o new orientation [Qt::Horizontal or Qt::Vertical]
+ */
+ void slotMoved(Orientation o);
+
+ private:
+ KateTabBarButton* pCurrentTab; ///< pointer to the current tab
+ QBoxLayout* top; ///< layout that contains all tabs
+ Kate::MainWindow* m_win; ///< pointer to the main window
+ Kate::DocumentManager* m_docManager; ///< pointer to the document manager
+// QPtrList <KateTabBarButton> m_tabs; ///< list containing all tabs
+ MyPtrList m_tabs; ///< list containing all tabs
+ Qt::Orientation m_orientation; ///< save tabbar's orientation
+ bool m_sort; ///< how to sort
+};
+
+/**
+ * The tabbar's config page
+ */
+class KateTabBarExtensionConfigPage : public Kate::PluginConfigPage
+{
+ Q_OBJECT
+
+ friend class KatePluginTabBarExtension;
+
+ public:
+ KateTabBarExtensionConfigPage (QObject* parent = 0L, QWidget *parentWidget = 0L);
+ ~KateTabBarExtensionConfigPage ();
+
+ /**
+ * Reimplemented from Kate::PluginConfigPage
+ * just emits configPageApplyRequest( this ).
+ */
+ virtual void apply();
+
+ virtual void reset () { ; }
+ virtual void defaults () { ; }
+
+ signals:
+ /**
+ * Ask the plugin to set initial values
+ */
+ void configPageApplyRequest( KateTabBarExtensionConfigPage* );
+
+ /**
+ * Ask the plugin to apply changes
+ */
+ void configPageInitRequest( KateTabBarExtensionConfigPage* );
+
+ private:
+ QCheckBox* pSortAlpha;
+};
+
+class KatePluginTabBarExtension : public Kate::Plugin, Kate::PluginViewInterface, Kate::PluginConfigInterfaceExtension
+{
+ Q_OBJECT
+
+ public:
+ KatePluginTabBarExtension( QObject* parent = 0, const char* name = 0 );
+ virtual ~KatePluginTabBarExtension();
+
+ void addView (Kate::MainWindow *win);
+ void removeView (Kate::MainWindow *win);
+
+ uint configPages () const { return 1; }
+ Kate::PluginConfigPage *configPage (uint , QWidget *w, const char *name=0);
+ QString configPageName(uint) const { return i18n("Tab Bar Extension"); }
+ QString configPageFullName(uint) const { return i18n("Configure Tab Bar Extension"); }
+ QPixmap configPagePixmap (uint number = 0, int size = KIcon::SizeSmall) const { return 0L; }
+
+ public slots:
+ void applyConfig( KateTabBarExtensionConfigPage* );
+
+ private:
+ void initConfigPage( KateTabBarExtensionConfigPage* );
+
+ private:
+ QPtrList<class PluginView> m_views;
+ KConfig* pConfig;
+};
+
+#endif // _PLUGIN_TABBAREXTENSION_H_
diff --git a/kate/tabbarextension/ui.rc b/kate/tabbarextension/ui.rc
new file mode 100644
index 0000000..1c88db2
--- /dev/null
+++ b/kate/tabbarextension/ui.rc
@@ -0,0 +1,7 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="tabbarextension" library="libkatetabbarextensionplugin" version="1">
+<ToolBar name="tabbarExtensionToolBar">
+ <text>Tab Bar Extension</text>
+ <Action name="tabbar_widget"/>
+</ToolBar>
+</kpartplugin>