22#include "kexieditor.h"
24#include <keximainwindow.h>
34#ifdef KTEXTEDIT_BASED_SQL_EDITOR
35# include <ktextedit.h>
37# include <tdetexteditor/document.h>
38# include <tdetexteditor/view.h>
39# include <tdetexteditor/editorchooser.h>
40# include <tdetexteditor/editinterface.h>
41# include <tdetexteditor/viewcursorinterface.h>
42# include <tdetexteditor/popupmenuinterface.h>
43# include <tdetexteditor/undointerface.h>
44# include <tdetexteditor/configinterface.h>
45# include <tdetexteditor/highlightinginterface.h>
53 KexiEditorSharedActionConnector( KexiActionProxy* proxy, TQObject* obj )
56#ifdef KTEXTEDIT_BASED_SQL_EDITOR
57 plugSharedAction( "edit_cut", TQ_SLOT(cut()));
58 plugSharedAction( "edit_copy", TQ_SLOT(copy()));
59 plugSharedAction( "edit_paste", TQ_SLOT(paste()));
60 plugSharedAction( "edit_clear", TQ_SLOT(clear()));
61 plugSharedAction( "edit_undo", TQ_SLOT(undo()));
62 plugSharedAction( "edit_redo", TQ_SLOT(redo()));
63 plugSharedAction( "edit_select_all", TQ_SLOT(selectAll()));
65 TQValueList<TQCString> actions;
66 actions << "edit_cut" << "edit_copy" << "edit_paste" << "edit_clear"
67 << "edit_undo" << "edit_redo" << "edit_select_all";
68 plugSharedActionsToExternalGUI(actions, dynamic_cast<KXMLGUIClient* >(obj));
74class KexiEditorPrivate {
76#ifdef KTEXTEDIT_BASED_SQL_EDITOR
79 KTextEditor::Document *doc;
80 KTextEditor::View *view;
86 , d(new KexiEditorPrivate())
88 TQVBoxLayout *layout = new TQVBoxLayout( this);
89#ifdef KTEXTEDIT_BASED_SQL_EDITOR
90 d->view = new KTextEdit( "", TQString(), this, "kexi_editor" );
94 f.setStyleStrategy(TQFont::PreferAntialias);
95 f.setPointSize(d->view->font().pointSize());
96 d->view->setFont( f );
97 d->view->setCheckSpellingEnabled( false);
99 TQFrame *fr = new TQFrame( this);
100 fr->setFrameStyle(TQFrame::Sunken|TQFrame::WinPanel);
101 layout->addWidget(fr);
102 layout = new TQVBoxLayout(fr);
103 layout->setMargin( 2 );
105 d->doc = KTextEditor::EditorChooser::createDocument(fr);
108 d->view = d->doc->createView(fr, 0L);
110 KTextEditor::PopupMenuInterface *popupInt = dynamic_cast<KTextEditor::PopupMenuInterface* >( d->view );
112 TQPopupMenu *pop = (TQPopupMenu*) mainWin->factory()->container( "edit", mainWin);
115 popupInt->installPopup(pop);
121 KexiEditorSharedActionConnector c( this, d->view);
122 d->view->installEventFilter( this);
124 layout->addWidget(d->view);
125 setViewWidget(d->view, true);
141#ifdef KTEXTEDIT_BASED_SQL_EDITOR
150#ifdef KTEXTEDIT_BASED_SQL_EDITOR
151 return d->view->text();
155 KTextEditor::EditInterface *eIface = KTextEditor::editInterface(d->doc);
156 return eIface->text();
162#ifdef KTEXTEDIT_BASED_SQL_EDITOR
163 const bool was_dirty = m_parentView ? m_parentView-> dirty() : dirty();
164 d->view->setText( text);
169 const bool was_dirty = dirty();
170 KTextEditor::EditInterface *eIface = KTextEditor::editInterface(d->doc);
171 eIface->setText( text);
172 KTextEditor::UndoInterface *undoIface = KTextEditor::undoInterface(d->doc);
173 undoIface->clearUndo();
174 undoIface->clearRedo();
181#ifdef KTEXTEDIT_BASED_SQL_EDITOR
183 KTextEditor::HighlightingInterface *hl = KTextEditor::highlightingInterface( d->doc );
184 for(uint i = 0; i < hl->hlModeCount(); i++) {
186 if (hl->hlModeName(i).contains(highlightmodename, false)) {
197#ifdef KTEXTEDIT_BASED_SQL_EDITOR
200 KTextEditor::ConfigInterface *config = KTextEditor::configInterface( d->doc );
202 config->configDialog();
208#ifdef KTEXTEDIT_BASED_SQL_EDITOR
209 const int numRows = d->view->paragraphs();
210 int row = 0, col = 0;
211 for ( int ch = 0; row < numRows; row++) {
212 const int rowLen = d->view->paragraphLength(row)+1;
213 if ((ch + rowLen) > character) {
219 d->view->setCursorPosition(row, col);
223 KTextEditor::EditInterface *ei = KTextEditor::editInterface(d->doc);
224 const int numRows = ei->numLines();
225 int row = 0, col = 0;
226 for ( int ch = 0; row < numRows; row++) {
227 const int rowLen = ei->lineLength(row)+1;
228 if ((ch + rowLen) > character) {
234 KTextEditor::ViewCursorInterface *ci = KTextEditor::viewCursorInterface(d->view);
235 ci->setCursorPositionReal(row, col);
241#ifdef KTEXTEDIT_BASED_SQL_EDITOR
242 d->view->setCursorPosition(line, col);
244 KTextEditor::ViewCursorInterface *ci = KTextEditor::viewCursorInterface( d->view );
245 ci->setCursorPosition(line, col);
251#ifdef KTEXTEDIT_BASED_SQL_EDITOR
254 KTextEditor::UndoInterface* u = KTextEditor::undoInterface( d->doc );
260#include "kexieditor.moc"
An interface that acts as proxy for shared actions within the application.
virtual ~KexiEditor() Destructor.
void setText(const TQString &text)
virtual void updateActions(bool activated)
static bool isAdvancedEditor()
KexiEditor(KexiMainWindow *mainWin, TQWidget *parent, const char *name=0) Constructor.
void clearUndoRedo() Clear all remembered undo/redo-actions.
void setCursorPosition(int line, int col) Set the cursor position to line and col .
void setHighlightMode(const TQString &highlightmodename) Set the highlight-mode to highlightmodename .
void slotConfigureEditor()
void jump(int character) Find row and column for this character and jump to the position.
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
Abstract helper class used to connect shared actions from outside of shared-action-aware object.
Base class for single view embeddable of in KexiDialogBase.
virtual bool dirty() const
KexiMainWindow * mainWin() const
virtual void updateActions(bool activated)
|