KDevelop API Documentation

SnippetWidget Class Reference

This is the widget which gets added to the right TreeToolView. More...

#include <snippet_widget.h>

Inheritance diagram for SnippetWidget:

Inheritance graph
[legend]
Collaboration diagram for SnippetWidget:

Collaboration graph
[legend]
List of all members.

Public Slots

void slotRemove ()
void slotEdit ()
void slotAdd ()

Public Member Functions

 SnippetWidget (SnippetPart *part)
 ~SnippetWidget ()
QPtrList< SnippetItem > * getList ()
void writeConfig ()
void initConfig ()
SnippetConfiggetSnippetConfig ()

Protected Slots

void showPopupMenu (QListViewItem *item, const QPoint &p, int)
void slotListDblClicked (QListViewItem *item, const QPoint &pos, int c)
void slotDropped (QDropEvent *e, QListViewItem *after)

Protected Member Functions

void maybeTip (const QPoint &)
bool acceptDrag (QDropEvent *event) const

Protected Attributes

SnippetPartm_part
SnippetDlgm_dialog

Private Member Functions

void insertIntoActiveView (QString text)
QString parseText (QString text, QString del="$")
bool showMultiVarDialog (QMap< QString, QString > *map, QMap< QString, QString > *mapSave, int &iWidth, int &iBasicHeight, int &iOneHeight)
QString showSingleVarDialog (QString var, QMap< QString, QString > *mapSave, QRect &dlgSize)

Private Attributes

QPtrList< SnippetItem_list
QMap< QString, QString_mapSaved
KConfig_cfg
SnippetConfig _SnippetConfig

Detailed Description

This is the widget which gets added to the right TreeToolView.

It inherits KListView and QToolTip which is needed for showing the tooltips which contains the text of the snippet

Author:
Robert Gruber

Definition at line 40 of file snippet_widget.h.


Constructor & Destructor Documentation

SnippetWidget::SnippetWidget SnippetPart part  ) 
 

Definition at line 49 of file snippet_widget.cpp.

References _cfg, _list, KListView::addColumn(), KListView::dropped(), initConfig(), m_dialog, KListView::setAcceptDrops(), KListView::setDragEnabled(), KListView::setDropVisualizer(), KListView::setFullWidth(), KListView::setSorting(), showPopupMenu(), slotDropped(), and slotListDblClicked().

SnippetWidget::~SnippetWidget  ) 
 

Definition at line 80 of file snippet_widget.cpp.

References _list, and writeConfig().


Member Function Documentation

bool SnippetWidget::acceptDrag QDropEvent event  )  const [protected, virtual]
 

Reimplementation from KListView. Check here if the data the user is about to drop fits our restrictions. We only accept dropps of plaintext, because from the dropped text we will create a snippet.

Reimplemented from KListView.

Definition at line 659 of file snippet_widget.cpp.

References kdDebug().

QPtrList<SnippetItem>* SnippetWidget::getList  )  [inline]
 

Definition at line 48 of file snippet_widget.h.

SnippetConfig* SnippetWidget::getSnippetConfig  )  [inline]
 

Definition at line 51 of file snippet_widget.h.

Referenced by SnippetSettings::SnippetSettings().

void SnippetWidget::initConfig  ) 
 

Initial read the cofig file

Definition at line 251 of file snippet_widget.cpp.

References _cfg, _list, _mapSaved, _SnippetConfig, KConfigBase::readBoolEntry(), KConfigBase::readEntry(), KConfigBase::readNumEntry(), KConfigBase::readRectEntry(), SnippetConfig::setDelimiter(), KConfigBase::setGroup(), SnippetConfig::setInputMethod(), SnippetConfig::setMultiRect(), SnippetConfig::setSingleRect(), and SnippetConfig::setToolTips().

Referenced by SnippetWidget().

void SnippetWidget::insertIntoActiveView QString  text  )  [private]
 

Inserts the parameter text into the activ view

Definition at line 173 of file snippet_widget.cpp.

References KParts::PartManager::activePart(), KParts::PartManager::activeWidget(), KTextEditor::ViewCursorInterface::cursorPositionReal(), KTextEditor::EditInterface::insertText(), m_part, KDevPlugin::partController(), and text().

Referenced by slotListDblClicked().

void SnippetWidget::maybeTip const QPoint p  )  [protected]
 

Shows the Snippet-Text as ToolTip

Definition at line 310 of file snippet_widget.cpp.

References _SnippetConfig, SnippetItem::getText(), and SnippetConfig::useToolTips().

QString SnippetWidget::parseText QString  text,
QString  del = "$"
[private]
 

This function is used to parse the given QString for variables. If found the user will be prompted for a replacement value. It returns the string text with all replacements made

Definition at line 356 of file snippet_widget.cpp.

References _mapSaved, _SnippetConfig, SnippetConfig::getInputMethod(), SnippetConfig::getMultiRect(), SnippetConfig::getSingleRect(), SnippetConfig::setMultiRect(), SnippetConfig::setSingleRect(), showMultiVarDialog(), showSingleVarDialog(), and text().

Referenced by slotListDblClicked().

bool SnippetWidget::showMultiVarDialog QMap< QString, QString > *  map,
QMap< QString, QString > *  mapSave,
int &  iWidth,
int &  iBasicHeight,
int &  iOneHeight
[private]
 

This function constructs a dialog which contains a label and a linedit for every variable that is stored in the given map except the double-delimiter entry It return true if everything was ok and false if the user hit cancel

Definition at line 429 of file snippet_widget.cpp.

References _SnippetConfig, SnippetConfig::getDelimiter(), KTextEdit, and KPushButton::setText().

Referenced by parseText().

void SnippetWidget::showPopupMenu QListViewItem item,
const QPoint p,
int 
[protected, slot]
 

Shows the Popup-Menu depending item is a valid pointer

Definition at line 328 of file snippet_widget.cpp.

References SnippetItem::getName(), KPopupMenu::insertTitle(), slotAdd(), slotEdit(), and slotRemove().

Referenced by SnippetWidget().

QString SnippetWidget::showSingleVarDialog QString  var,
QMap< QString, QString > *  mapSave,
QRect dlgSize
[private]
 

This function constructs a dialog which contains a label and a linedit for the given variable It return either the entered value or an empty string if the user hit cancel

Definition at line 566 of file snippet_widget.cpp.

References KTextEdit, and KPushButton::setText().

Referenced by parseText().

void SnippetWidget::slotAdd  )  [slot]
 

Opens the didalog to add a snippet

Definition at line 92 of file snippet_widget.cpp.

References _list, KLineEdit::clear(), kdDebug(), m_dialog, SnippetDlg::snippetName, and SnippetDlg::snippetText.

Referenced by showPopupMenu().

void SnippetWidget::slotDropped QDropEvent e,
QListViewItem after
[protected, slot]
 

This slot is connected to the dropped signal. If it is emitted, we need to construct a new snippet entry with the data given

Definition at line 676 of file snippet_widget.cpp.

References _list, KLineEdit::clear(), kdDebug(), m_dialog, SnippetDlg::snippetName, and SnippetDlg::snippetText.

Referenced by SnippetWidget().

void SnippetWidget::slotEdit  )  [slot]
 

Opens the dialog of editing the selected snippet

Definition at line 126 of file snippet_widget.cpp.

References SnippetDlg::btnAdd, SnippetItem::getName(), SnippetItem::getText(), m_dialog, SnippetItem::setName(), SnippetItem::setText(), KPushButton::setText(), KLineEdit::setText(), SnippetDlg::snippetName, and SnippetDlg::snippetText.

Referenced by showPopupMenu().

void SnippetWidget::slotListDblClicked QListViewItem item,
const QPoint pos,
int  c
[protected, slot]
 

On a DoubleClick the clicked snippet gets inserted at the current cursor position of the active view

Definition at line 158 of file snippet_widget.cpp.

References _SnippetConfig, SnippetConfig::getDelimiter(), SnippetItem::getText(), insertIntoActiveView(), and parseText().

Referenced by SnippetWidget().

void SnippetWidget::slotRemove  )  [slot]
 

Removes the selected snippet

Definition at line 108 of file snippet_widget.cpp.

References _list.

Referenced by showPopupMenu().

void SnippetWidget::writeConfig  ) 
 

Write the cofig file

Definition at line 199 of file snippet_widget.cpp.

References _cfg, _list, _mapSaved, _SnippetConfig, KConfigBase::deleteGroup(), SnippetConfig::getDelimiter(), SnippetConfig::getInputMethod(), SnippetConfig::getMultiRect(), SnippetItem::getName(), SnippetConfig::getSingleRect(), SnippetItem::getText(), KConfigBase::setGroup(), KConfigBase::sync(), SnippetConfig::useToolTips(), and KConfigBase::writeEntry().

Referenced by ~SnippetWidget().


Member Data Documentation

KConfig* SnippetWidget::_cfg [private]
 

Definition at line 69 of file snippet_widget.h.

Referenced by initConfig(), SnippetWidget(), and writeConfig().

QPtrList<SnippetItem> SnippetWidget::_list [private]
 

Definition at line 67 of file snippet_widget.h.

Referenced by initConfig(), slotAdd(), slotDropped(), slotRemove(), SnippetWidget(), writeConfig(), and ~SnippetWidget().

QMap<QString, QString> SnippetWidget::_mapSaved [private]
 

Definition at line 68 of file snippet_widget.h.

Referenced by initConfig(), parseText(), and writeConfig().

SnippetConfig SnippetWidget::_SnippetConfig [private]
 

Definition at line 70 of file snippet_widget.h.

Referenced by initConfig(), maybeTip(), parseText(), showMultiVarDialog(), slotListDblClicked(), and writeConfig().

SnippetDlg* SnippetWidget::m_dialog [protected]
 

Definition at line 56 of file snippet_widget.h.

Referenced by slotAdd(), slotDropped(), slotEdit(), and SnippetWidget().

SnippetPart* SnippetWidget::m_part [protected]
 

Definition at line 55 of file snippet_widget.h.

Referenced by insertIntoActiveView().


The documentation for this class was generated from the following files:
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:47:51 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003