diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kate/utils | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.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/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kate/utils')
-rw-r--r-- | kate/utils/Makefile.am | 16 | ||||
-rw-r--r-- | kate/utils/README | 29 | ||||
-rw-r--r-- | kate/utils/dockviewbase.cpp | 102 | ||||
-rw-r--r-- | kate/utils/dockviewbase.h | 102 | ||||
-rw-r--r-- | kate/utils/listboxview.cpp | 57 | ||||
-rw-r--r-- | kate/utils/listboxview.h | 44 | ||||
-rw-r--r-- | kate/utils/messageview.cpp | 46 | ||||
-rw-r--r-- | kate/utils/messageview.h | 72 |
8 files changed, 468 insertions, 0 deletions
diff --git a/kate/utils/Makefile.am b/kate/utils/Makefile.am new file mode 100644 index 000000000..eda68c724 --- /dev/null +++ b/kate/utils/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir)/kate/utils $(all_includes) + +EXTRA_DIST = README + +lib_LTLIBRARIES = libkateutils.la + +libkateutils_la_SOURCES = dockviewbase.cpp messageview.cpp listboxview.cpp + +libkateutils_la_LDFLAGS = $(all_libraries) -no-undefined + +libkateutils_la_LIBADD = $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_KIO) + +libkateutils_la_METASOURCES = AUTO + +kateutilsinclude_HEADERS = dockviewbase.h messageview.h listboxview.h +kateutilsincludedir = $(includedir)/kate/utils diff --git a/kate/utils/README b/kate/utils/README new file mode 100644 index 000000000..262b108f0 --- /dev/null +++ b/kate/utils/README @@ -0,0 +1,29 @@ +README for libkateutils + +Contents: +* What it is +* Maintainer + +What it is +========== + +This library is a container for classes that may be usefull for +Kate and for kate plugins. If you have a class that you think would +be usefull for other plugins, ask the maintainer of this library +to put it here. + +If you find a class in a plugin (ore even elsewhere) that you need to +copy in order to use it inside kate or a kate plugin, consider debating with +the author of that class to move it here. + +To fit in, the class must be generic enough that it can be usefull for +many purposes. + +Apart from the convenience (and avoided copies of code) putting classes in this +library will help us maintain a common feel of how kate works. + +Maintainer +========== + +This library was started in july 2002 and is maintained by +Anders Lund <[email protected]> diff --git a/kate/utils/dockviewbase.cpp b/kate/utils/dockviewbase.cpp new file mode 100644 index 000000000..54a4d6d6e --- /dev/null +++ b/kate/utils/dockviewbase.cpp @@ -0,0 +1,102 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#include "dockviewbase.h" +#include "dockviewbase.moc" + +#include <qlabel.h> +#include <qlayout.h> + +//#include <kdebug.h> + +namespace Kate { + +// data storage +class DockViewBasePrivate { + public: + QWidget *header; + QLabel *lTitle; + QLabel *lPrefix; +}; + +} + +Kate::DockViewBase::DockViewBase( QWidget* parent, const char* name ) + : QVBox( parent, name ), + d ( new Kate::DockViewBasePrivate ) +{ + init( QString::null, QString::null ); +} + +Kate::DockViewBase::DockViewBase( const QString &prefix, const QString &title, QWidget* parent, const char* name ) + : QVBox( parent, name ), + d ( new Kate::DockViewBasePrivate ) +{ + init( prefix, title ); +} + +Kate::DockViewBase::~DockViewBase() +{ + delete d; +} + +void Kate::DockViewBase::setTitlePrefix( const QString &prefix ) +{ + d->lPrefix->setText( prefix ); + d->lPrefix->show(); +} + +QString Kate::DockViewBase::titlePrefix() const +{ + return d->lPrefix->text(); +} + +void Kate::DockViewBase::setTitle( const QString &title ) +{ + d->lTitle->setText( title ); + d->lTitle->show(); +} + +QString Kate::DockViewBase::title() const +{ + return d->lTitle->text(); +} + +void Kate::DockViewBase::setTitle( const QString &prefix, const QString &title ) +{ + setTitlePrefix( prefix ); + setTitle( title ); +} + +void Kate::DockViewBase::init( const QString &prefix, const QString &title ) +{ + setSpacing( 4 ); + d->header = new QWidget( this ); + d->header->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed, true ) ); + QHBoxLayout *lo = new QHBoxLayout( d->header ); + lo->setSpacing( 6 ); + lo->insertSpacing( 0, 6 ); + d->lPrefix = new QLabel( title, d->header ); + lo->addWidget( d->lPrefix ); + d->lTitle = new QLabel( title, d->header ); + lo->addWidget( d->lTitle ); + lo->setStretchFactor( d->lTitle, 1 ); + lo->insertSpacing( -1, 6 ); + if ( prefix.isEmpty() ) d->lPrefix->hide(); + if ( title.isEmpty() ) d->lTitle->hide(); +} diff --git a/kate/utils/dockviewbase.h b/kate/utils/dockviewbase.h new file mode 100644 index 000000000..9e3010302 --- /dev/null +++ b/kate/utils/dockviewbase.h @@ -0,0 +1,102 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#ifndef _KATE_DOCKVIEW_BASE_H_ +#define _KATE_DOCKVIEW_BASE_H_ + +#include <qvbox.h> + +/** +* Namespace collecting as much of the internal Kate classes as we +* can manage. +*/ +namespace Kate +{ + +/** + Base class for dockwidget views + This class creates a widget meant to be set as the main widget + for a KDockWidget. + + This class provides a title in two parts, titlePrefix and title. The + size policies are set so that neither will prevent resizing the view to + a width smaller than the texts, the titlePrefix (on the left) will remain + fully visible for as long as possible. + + Use the titlePrefix to describe the nature of the view contents, for + example "Messages". + + Use the title to inform the user what is currently in the view, + for example the name of a related file, a command or similar. + + To add widgets, just create them with this as the parent. + + @author Anders Lund <[email protected]> +*/ + + +class DockViewBase : public QVBox { + Q_OBJECT + public: + /** + Create a KateDockViewBase. + */ + DockViewBase( QWidget *parent=0, const char *name=0 ); + + /** + Create a KateDockViewBase with the title prefix @p prefix + and the title @p title. + */ + DockViewBase( const QString &prefix, const QString &title, QWidget *parent=0, const char *name=0 ); + + ~DockViewBase(); + + /** + Set the title prefix to @p prefix. + */ + void setTitlePrefix( const QString &prefix ); + + /** + @return The title prefix. + */ + QString titlePrefix() const; + + /** + Set the title to @p title + */ + void setTitle( const QString &title ); + + /** + Convenience method, sets both the prefix and title + */ + void setTitle( const QString &prefix, const QString &title ); + + /** + @return the title of the KateDockViewBase + */ + QString title() const; + + private: + /** Private initialization */ + void init( const QString &, const QString &); + class DockViewBasePrivate *d; +}; + +} + +#endif // _KATE_DOCKVIEW_BASE_H_ diff --git a/kate/utils/listboxview.cpp b/kate/utils/listboxview.cpp new file mode 100644 index 000000000..69e103bad --- /dev/null +++ b/kate/utils/listboxview.cpp @@ -0,0 +1,57 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#include "listboxview.h" +#include "listboxview.moc" + +#include <klistbox.h> + +namespace Kate { + +// private storage +class ListboxViewPrivate { + public: + KListBox *listbox; +}; + +} + +Kate::ListboxView::ListboxView( QWidget *parent, const char *name ) + : Kate::DockViewBase( parent, name), + d( new Kate::ListboxViewPrivate) +{ + d->listbox = new KListBox( this ); +} + +Kate::ListboxView::ListboxView( const QString &titlePrefix, const QString &title, QWidget *parent, const char *name ) + : Kate::DockViewBase( titlePrefix, title, parent, name), + d( new Kate::ListboxViewPrivate) +{ + d->listbox = new KListBox( this ); +} + +Kate::ListboxView::~ListboxView() +{ + delete d; +} + +KListBox *Kate::ListboxView::listbox() +{ + return d->listbox; +} + diff --git a/kate/utils/listboxview.h b/kate/utils/listboxview.h new file mode 100644 index 000000000..233b4798a --- /dev/null +++ b/kate/utils/listboxview.h @@ -0,0 +1,44 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#ifndef _KATE_LISTBOX_VIEW_H_ +#define _KATE_LISTBOX_VIEW_H_ + +#include "dockviewbase.h" + +class KListBox; + +namespace Kate +{ + +class ListboxView : public DockViewBase { + Q_OBJECT + public: + ListboxView( QWidget *parent=0, const char *name=0 ); + ListboxView( const QString &titlePrefix, const QString &title, QWidget *parent=0, const char *name=0 ); + ~ListboxView(); + + KListBox * listbox(); + + private: + class ListboxViewPrivate *d; +}; + +} + +#endif // _KATE_LISTBOX_VIEW_H_ diff --git a/kate/utils/messageview.cpp b/kate/utils/messageview.cpp new file mode 100644 index 000000000..2f0904433 --- /dev/null +++ b/kate/utils/messageview.cpp @@ -0,0 +1,46 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#include "messageview.h" +#include "messageview.moc" + +#include <qtextbrowser.h> + +Kate::MessageView::MessageView( QWidget *parent, const char *name ) + : Kate::DockViewBase( parent, name ) +{ + m_view = new QTextBrowser( this ); + // m_view->setFormat( Qt::richText ); // should be!! + connect( m_view, SIGNAL( linkClicked( const QString & ) ), + SIGNAL( linkClicked( const QString & ) ) ); +} + +Kate::MessageView::~MessageView() +{ +} + +void Kate::MessageView::addMessage( const QString &msg ) +{ + m_view->append( msg ); + m_view->scrollToBottom(); +} + +void Kate::MessageView::clear() +{ + m_view->clear(); +} diff --git a/kate/utils/messageview.h b/kate/utils/messageview.h new file mode 100644 index 000000000..d6d330842 --- /dev/null +++ b/kate/utils/messageview.h @@ -0,0 +1,72 @@ +/* This file is part of the KDE project + Copyright (C) 2002 Anders Lund <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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. +*/ + +#ifndef _KATE_MESSAGE_VIEW_H_ +#define _KATE_MESSAGE_VIEW_H_ + +#include "dockviewbase.h" + +/** + A simple message view for Kate plugins. + + This is a message view for displaying output from processes. + + It uses a QTextEdit in _ mode to display the text. + + You can use HTML links, for example to allow the user to go + to a line in a precessed document. + + Connect to the linkClicked() signal to process the links. + + @section Usage + + To use it in the intended way: + @li Create a KProcess (or derived class) + @li As the output of the process arrives, hand it over + using addText(). The view will add it to the end and + make sure it is scrolled to the end. + + Each time you restart the process, clear() the view. +*/ + +class QTextBrowser; + +namespace Kate +{ + +class MessageView : public DockViewBase { + Q_OBJECT + public: + MessageView( QWidget *parent=0, const char *name=0 ); + ~MessageView(); + + public slots: + void addMessage( const QString &msg ); + void clear(); + + signals: + void linkClicked( const QString & href ); + + private: + QTextBrowser *m_view; +}; + +} + +#endif // _KATE_MESSAGE_VIEW_H_ + |