[prev in list] [next in list] [prev in thread] [next in thread]
List: kwrite-devel
Subject: KTextEditor loadingFinished() signal
From: Hamish Rodda <meddie () yoyo ! its ! monash ! edu ! au>
Date: 2003-02-09 11:46:36
[Download RAW message or body]
Hi,
As mentioned previously I've implemented a simple loadingFinished() signal for
KTextEditor::Document. This (along with the attached gideon patch) solves
the problem when opening a file in Gideon the cursor is not set to the
requested line number because the file isn't completely loaded at that point.
The biggest problem I can think of is other editors that don't emit this
signal.
Comments?
Cheers,
Hamish.
["ktexteditor-20030209.patch" (text/x-diff)]
Index: document.h
===================================================================
RCS file: /home/kde/kdelibs/interfaces/ktexteditor/document.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 document.h
--- document.h 7 Feb 2003 11:16:53 -0000 1.8
+++ document.h 9 Feb 2003 11:36:28 -0000
@@ -60,6 +60,13 @@ class Document : public KTextEditor::Edi
*/
virtual QPtrList<class View> views () const = 0;
+ signals:
+ /**
+ * Indicate when loading the requested file has finished.
+ * @since 3.2
+ */
+ void loadingFinished();
+
private:
class PrivateDocument *d;
static unsigned int globalDocumentNumber;
["katedocument-20030209.patch" (text/x-diff)]
Index: katedocument.cpp
===================================================================
RCS file: /home/kde/kdelibs/kate/part/katedocument.cpp,v
retrieving revision 1.424
diff -u -3 -p -r1.424 katedocument.cpp
--- katedocument.cpp 1 Feb 2003 16:37:31 -0000 1.424
+++ katedocument.cpp 9 Feb 2003 11:37:12 -0000
@@ -4827,6 +4827,7 @@ unsigned int KateDocument::visibleLines
void KateDocument::slotLoadingFinished()
{
tagAll();
+ emit loadingFinished();
}
const QFont& KateDocument::getFont( WhichFont wf )
["gideon-20030209.patch" (text/x-diff)]
Index: editorproxy.h
===================================================================
RCS file: /home/kde/kdevelop/src/editorproxy.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 editorproxy.h
--- editorproxy.h 11 Dec 2002 23:31:31 -0000 1.8
+++ editorproxy.h 9 Feb 2003 11:37:39 -0000
@@ -32,14 +32,16 @@ private slots:
void popupAboutToShow();
+ void documentLoaded();
+
private:
-
+
EditorProxy();
-
+
static EditorProxy *s_instance;
QArray<int> m_popupIds;
-
+ QMap<KParts::Part*, int> m_requestedLineNumbers;
};
Index: editorproxy.cpp
===================================================================
RCS file: /home/kde/kdevelop/src/editorproxy.cpp,v
retrieving revision 1.13
diff -u -3 -p -r1.13 editorproxy.cpp
--- editorproxy.cpp 26 Jan 2003 14:43:28 -0000 1.13
+++ editorproxy.cpp 9 Feb 2003 11:37:39 -0000
@@ -46,11 +46,29 @@ void EditorProxy::setLineNumber(KParts::
if ( lineNum < 0 )
return;
+ EditInterface* edit = dynamic_cast<EditInterface*>(part);
+ if (edit)
+ if (edit->numLines() > lineNum) {
+ ViewCursorInterface *iface = dynamic_cast<ViewCursorInterface*>(part->widget());
+ if (iface)
+ iface->setCursorPosition(lineNum, 0);
+ } else {
+ connect(part, SIGNAL(loadingFinished()), SLOT(documentLoaded()));
+ m_requestedLineNumbers.insert(part, lineNum);
+ }
+}
+
+void EditorProxy::documentLoaded()
+{
+ KParts::Part* part = dynamic_cast<KParts::Part*>(const_cast<QObject*>(sender()));
+ int lineNum = m_requestedLineNumbers[part];
ViewCursorInterface *iface = dynamic_cast<ViewCursorInterface*>(part->widget());
- if (iface)
+ if (iface) {
iface->setCursorPosition(lineNum, 0);
+ kdDebug() << k_funcinfo << endl;
+ }
+ m_requestedLineNumbers.remove(part);
}
-
void EditorProxy::installPopup(KParts::Part *part, QPopupMenu *popup)
{
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic