From 722ce1efbac31c61b1d4b13f7e075c9f311e3e73 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Sun, 2 Mar 2014 20:05:33 +0100 Subject: Finish renaming tdevelop components --- lib/widgets/CMakeLists.txt | 10 +- lib/widgets/Makefile.am | 24 +- lib/widgets/kdevhtml_partui.rc | 18 -- lib/widgets/kdevhtmlpart.cpp | 512 ---------------------------------- lib/widgets/kdevhtmlpart.h | 111 -------- lib/widgets/kdevtabwidget.cpp | 66 ----- lib/widgets/propeditor/CMakeLists.txt | 4 +- lib/widgets/propeditor/Makefile.am | 14 +- lib/widgets/tdevhtml_partui.rc | 18 ++ lib/widgets/tdevhtmlpart.cpp | 512 ++++++++++++++++++++++++++++++++++ lib/widgets/tdevhtmlpart.h | 111 ++++++++ lib/widgets/tdevtabwidget.cpp | 66 +++++ 12 files changed, 733 insertions(+), 733 deletions(-) delete mode 100644 lib/widgets/kdevhtml_partui.rc delete mode 100644 lib/widgets/kdevhtmlpart.cpp delete mode 100644 lib/widgets/kdevhtmlpart.h delete mode 100644 lib/widgets/kdevtabwidget.cpp create mode 100644 lib/widgets/tdevhtml_partui.rc create mode 100644 lib/widgets/tdevhtmlpart.cpp create mode 100644 lib/widgets/tdevhtmlpart.h create mode 100644 lib/widgets/tdevtabwidget.cpp (limited to 'lib/widgets') diff --git a/lib/widgets/CMakeLists.txt b/lib/widgets/CMakeLists.txt index 30e0ba3e..86303b6d 100644 --- a/lib/widgets/CMakeLists.txt +++ b/lib/widgets/CMakeLists.txt @@ -28,22 +28,22 @@ link_directories( install( FILES tdelistviewaction.h qcomboview.h flagboxes.h ksavealldialog.h resizablecombo.h kcomboview.h - kdevhtmlpart.h processlinemaker.h processwidget.h + tdevhtmlpart.h processlinemaker.h processwidget.h fancylistviewitem.h DESTINATION ${INCLUDE_INSTALL_DIR}/tdevelop/widgets ) ##### other data ################################ -install( FILES kdevhtml_partui.rc DESTINATION ${DATA_INSTALL_DIR}/tdevelop ) +install( FILES tdevhtml_partui.rc DESTINATION ${DATA_INSTALL_DIR}/tdevelop ) -##### kdevwidgets (shared) ###################### +##### tdevwidgets (shared) ###################### -tde_add_library( kdevwidgets SHARED AUTOMOC +tde_add_library( tdevwidgets SHARED AUTOMOC SOURCES flagboxes.cpp qcomboview.cpp tdelistviewaction.cpp - kcomboview.cpp resizablecombo.cpp kdevhtmlpart.cpp + kcomboview.cpp resizablecombo.cpp tdevhtmlpart.cpp processlinemaker.cpp processwidget.cpp ksavealldialog.cpp fancylistviewitem.cpp VERSION 0.0.0 diff --git a/lib/widgets/Makefile.am b/lib/widgets/Makefile.am index 69be7a11..7181151e 100644 --- a/lib/widgets/Makefile.am +++ b/lib/widgets/Makefile.am @@ -2,29 +2,29 @@ INCLUDES = -I$(top_srcdir)/lib/compat -I$(top_srcdir)/lib/interfaces $(all_inclu METASOURCES = AUTO -lib_LTLIBRARIES = libkdevwidgets.la +lib_LTLIBRARIES = libtdevwidgets.la -kdevwidgetsincludedir = $(includedir)/tdevelop/widgets +tdevwidgetsincludedir = $(includedir)/tdevelop/widgets -libkdevwidgets_la_SOURCES = flagboxes.cpp qcomboview.cpp tdelistviewaction.cpp \ - kcomboview.cpp resizablecombo.cpp kdevhtmlpart.cpp processlinemaker.cpp \ +libtdevwidgets_la_SOURCES = flagboxes.cpp qcomboview.cpp tdelistviewaction.cpp \ + kcomboview.cpp resizablecombo.cpp tdevhtmlpart.cpp processlinemaker.cpp \ processwidget.cpp ksavealldialog.cpp fancylistviewitem.cpp -kdevwidgetsinclude_HEADERS = tdelistviewaction.h qcomboview.h flagboxes.h \ - ksavealldialog.h resizablecombo.h kcomboview.h kdevhtmlpart.h processlinemaker.h \ +tdevwidgetsinclude_HEADERS = tdelistviewaction.h qcomboview.h flagboxes.h \ + ksavealldialog.h resizablecombo.h kcomboview.h tdevhtmlpart.h processlinemaker.h \ processwidget.h fancylistviewitem.h SUBDIRS = propeditor -libkdevwidgets_la_LIBADD = $(top_builddir)/lib/interfaces/libkdevinterfaces.la -libkdevwidgets_la_LDFLAGS = -no-undefined $(all_libraries) +libtdevwidgets_la_LIBADD = $(top_builddir)/lib/interfaces/libtdevinterfaces.la +libtdevwidgets_la_LDFLAGS = -no-undefined $(all_libraries) rcdir = $(kde_datadir)/tdevelop -rc_DATA = kdevhtml_partui.rc +rc_DATA = tdevhtml_partui.rc -DOXYGEN_REFERENCES = dcop interfaces tdecore tdefx tdeui tdehtml tdemdi tdeio kjs tdeparts tdeutils kdevutil kdevinterfaces -DOXYGEN_PROJECTNAME = KDevelop Widgets Library -DOXYGEN_DOCDIRPREFIX = kdev +DOXYGEN_REFERENCES = dcop interfaces tdecore tdefx tdeui tdehtml tdemdi tdeio kjs tdeparts tdeutils tdevutil tdevinterfaces +DOXYGEN_PROJECTNAME = TDevelop Widgets Library +DOXYGEN_DOCDIRPREFIX = tdev include ../../Doxyfile.am diff --git a/lib/widgets/kdevhtml_partui.rc b/lib/widgets/kdevhtml_partui.rc deleted file mode 100644 index 5a55b7bf..00000000 --- a/lib/widgets/kdevhtml_partui.rc +++ /dev/null @@ -1,18 +0,0 @@ - - - - - &File - - - - - - - - - - - - - diff --git a/lib/widgets/kdevhtmlpart.cpp b/lib/widgets/kdevhtmlpart.cpp deleted file mode 100644 index 76697cfa..00000000 --- a/lib/widgets/kdevhtmlpart.cpp +++ /dev/null @@ -1,512 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -#include "kdevhtmlpart.h" - -KDevHTMLPart::KDevHTMLPart() - : TDEHTMLPart(0L, 0L, 0L, "KDevHTMLPart", DefaultGUI ) -{ - setXMLFile(locate("data", "tdevelop/kdevhtml_partui.rc"), true); - - connect(browserExtension(), TQT_SIGNAL(openURLRequestDelayed(const KURL &,const KParts::URLArgs &)), - this, TQT_SLOT(openURLRequest(const KURL &)) ); - - connect(this, TQT_SIGNAL(started(TDEIO::Job *)), this, TQT_SLOT(slotStarted(TDEIO::Job* ))); - connect(this, TQT_SIGNAL(completed()), this, TQT_SLOT(slotCompleted())); - connect(this, TQT_SIGNAL(canceled(const TQString &)), this, TQT_SLOT(slotCancelled(const TQString &))); - - TDEActionCollection * actions = actionCollection();// new TDEActionCollection( this ); - reloadAction = new TDEAction( i18n( "Reload" ), "reload", 0, - this, TQT_SLOT( slotReload() ), actions, "doc_reload" ); - reloadAction->setWhatsThis(i18n("Reload

Reloads the current document.")); - stopAction = new TDEAction( i18n( "Stop" ), "stop", 0, - this, TQT_SLOT( slotStop() ), actions, "doc_stop" ); - stopAction->setWhatsThis(i18n("Stop

Stops the loading of current document.")); - duplicateAction = new TDEAction( i18n( "Duplicate Tab" ), "window_new", 0, - this, TQT_SLOT( slotDuplicate() ), actions, "doc_dup" ); - duplicateAction->setWhatsThis(i18n("Duplicate window

Opens current document in a new window.")); - printAction = KStdAction::print(this, TQT_SLOT(slotPrint()), actions, "print_doc"); - copyAction = KStdAction::copy(this, TQT_SLOT(slotCopy()), actions, "copy_doc_selection"); - - connect( this, TQT_SIGNAL(popupMenu(const TQString &, const TQPoint &)), this, TQT_SLOT(popup(const TQString &, const TQPoint &))); - connect(this, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged())); - -//BEGIN documentation history stuff - - m_backAction = new TDEToolBarPopupAction(i18n("Back"), "back", 0, - this, TQT_SLOT(slotBack()), - actions, "browser_back"); - m_backAction->setEnabled( false ); - m_backAction->setToolTip(i18n("Back")); - m_backAction->setWhatsThis(i18n("Back

Moves backwards one step in the documentation browsing history.")); - - connect(m_backAction->popupMenu(), TQT_SIGNAL(aboutToShow()), - this, TQT_SLOT(slotBackAboutToShow())); - connect(m_backAction->popupMenu(), TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotPopupActivated(int))); - - m_forwardAction = new TDEToolBarPopupAction(i18n("Forward"), "forward", 0, - this, TQT_SLOT(slotForward()), - actions, "browser_forward"); - m_forwardAction->setEnabled( false ); - m_forwardAction->setToolTip(i18n("Forward")); - m_forwardAction->setWhatsThis(i18n("Forward

Moves forward one step in the documentation browsing history.")); - - connect(m_forwardAction->popupMenu(), TQT_SIGNAL(aboutToShow()), - this, TQT_SLOT(slotForwardAboutToShow())); - connect(m_forwardAction->popupMenu(), TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotPopupActivated(int))); - - m_restoring = false; - m_Current = m_history.end(); -//END documentation history stuff - - //settings: - TDEConfig *appConfig = TDEGlobal::config(); - appConfig->setGroup("TDEHTMLPart"); - setStandardFont(appConfig->readEntry("StandardFont", - settings()->stdFontName())); - setFixedFont(appConfig->readEntry("FixedFont", - settings()->fixedFontName())); - setZoomFactor(appConfig->readEntry("Zoom", "100").toInt()); -} - -void KDevHTMLPart::popup( const TQString & url, const TQPoint & p ) -{ -// TDEPopupMenu popup( i18n( "Documentation Viewer" ), this->widget() ); - TDEPopupMenu popup(this->widget()); - - bool needSep = false; - int idNewWindow = -2; - if (!url.isEmpty() && (m_options & CanOpenInNewWindow)) - { - idNewWindow = popup.insertItem(SmallIcon("window_new"),i18n("Open in New Tab")); - popup.TQMenuData::setWhatsThis(idNewWindow, i18n("Open in new window

Opens current link in a new window.")); - needSep = true; - } - if (m_options & CanDuplicate) - { - duplicateAction->plug(&popup); - needSep = true; - } - if (needSep) - popup.insertSeparator(); - - m_backAction->plug( &popup ); - m_forwardAction->plug( &popup ); - reloadAction->plug(&popup); -// stopAction->plug(&popup); - popup.insertSeparator(); - - copyAction->plug( &popup ); - popup.insertSeparator(); - - printAction->plug(&popup); - popup.insertSeparator(); - - TDEAction * incFontAction = this->action("incFontSizes"); - TDEAction * decFontAction = this->action("decFontSizes"); - if ( incFontAction && decFontAction ) - { - incFontAction->plug( &popup ); - decFontAction->plug( &popup ); - popup.insertSeparator(); - } - - TDEAction *ac = action("setEncoding"); - if (ac) - ac->plug(&popup); - - int r = popup.exec(p); - - if (r == idNewWindow) - { - KURL kurl; - if (!KURL(url).path().startsWith("/")) - { - kdDebug() << "processing relative url: " << url << endl; - if (url.startsWith("#")) - { - kurl = KURL(KDevHTMLPart::url()); - kurl.setRef(url.mid(1)); - } - else - kurl = KURL(KDevHTMLPart::url().upURL().url(true)+url); - } - else - kurl = KURL(url); - - if (kurl.isValid()) - slotOpenInNewWindow(kurl); - } -} - -void KDevHTMLPart::setContext(const TQString &context) -{ - m_context = context; -} - - -TQString KDevHTMLPart::context() const -{ - return m_context; -} - - -// Note: this function is a copy of code in tdecore/tdeconfigbase.cpp ;) -static bool isUtf8(const char *buf) { - int i, n; - register unsigned char c; - bool gotone = false; - -#define F 0 /* character never appears in text */ -#define T 1 /* character appears in plain ASCII text */ -#define I 2 /* character appears in ISO-8859 text */ -#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */ - - static const unsigned char text_chars[256] = { - /* BEL BS HT LF FF CR */ - F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */ - /* ESC */ - F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */ - T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */ - /* NEL */ - X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */ - X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */ - I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */ - }; - - /* *ulen = 0; */ - for (i = 0; (c = buf[i]); i++) { - if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */ - /* - * Even if the whole file is valid UTF-8 sequences, - * still reject it if it uses weird control characters. - */ - - if (text_chars[c] != T) - return false; - - } else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */ - return false; - } else { /* 11xxxxxx begins UTF-8 */ - int following; - - if ((c & 0x20) == 0) { /* 110xxxxx */ - following = 1; - } else if ((c & 0x10) == 0) { /* 1110xxxx */ - following = 2; - } else if ((c & 0x08) == 0) { /* 11110xxx */ - following = 3; - } else if ((c & 0x04) == 0) { /* 111110xx */ - following = 4; - } else if ((c & 0x02) == 0) { /* 1111110x */ - following = 5; - } else - return false; - - for (n = 0; n < following; n++) { - i++; - if (!(c = buf[i])) - goto done; - - if ((c & 0x80) == 0 || (c & 0x40)) - return false; - } - gotone = true; - } - } -done: - return gotone; /* don't claim it's UTF-8 if it's all 7-bit */ -} -#undef F -#undef T -#undef I -#undef X - -TQString KDevHTMLPart::resolveEnvVarsInURL(const TQString& url) -{ - // check for environment variables and make necessary translations - TQString path = url; - int nDollarPos = path.find( '$' ); - - // Note: the while loop below is a copy of code in tdecore/tdeconfigbase.cpp ;) - while( nDollarPos != -1 && nDollarPos+1 < static_cast(path.length())) { - // there is at least one $ - if( (path)[nDollarPos+1] == '(' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - while ( (nEndPos <= path.length()) && (path[nEndPos]!=')') ) - nEndPos++; - nEndPos++; - TQString cmd = path.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - - TQString result; - FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); - if (fs) - { - TQTextStream ts(fs, IO_ReadOnly); - result = ts.read().stripWhiteSpace(); - pclose(fs); - } - path.replace( nDollarPos, nEndPos-nDollarPos, result ); - } else if( (path)[nDollarPos+1] != '$' ) { - uint nEndPos = nDollarPos+1; - // the next character is no $ - TQString aVarName; - if (path[nEndPos]=='{') - { - while ( (nEndPos <= path.length()) && (path[nEndPos]!='}') ) - nEndPos++; - nEndPos++; - aVarName = path.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); - } - else - { - while ( nEndPos <= path.length() && (path[nEndPos].isNumber() - || path[nEndPos].isLetter() || path[nEndPos]=='_' ) ) - nEndPos++; - aVarName = path.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); - } - const char* pEnv = 0; - if (!aVarName.isEmpty()) - pEnv = getenv( aVarName.ascii() ); - if( pEnv ) { - // !!! Sergey A. Sukiyazov !!! - // A environment variables may contain values in 8bit - // locale cpecified encoding or in UTF8 encoding. - if (isUtf8( pEnv )) - path.replace( nDollarPos, nEndPos-nDollarPos, TQString::fromUtf8(pEnv) ); - else - path.replace( nDollarPos, nEndPos-nDollarPos, TQString::fromLocal8Bit(pEnv) ); - } else - path.remove( nDollarPos, nEndPos-nDollarPos ); - } else { - // remove one of the dollar signs - path.remove( nDollarPos, 1 ); - nDollarPos++; - } - nDollarPos = path.find( '$', nDollarPos ); - } - - return path; -} - -bool KDevHTMLPart::openURL(const KURL &url) -{ - TQString path = resolveEnvVarsInURL(url.url()); - KURL newUrl(path); - - bool retval = TDEHTMLPart::openURL(newUrl); - if ( retval ) - { - emit fileNameChanged(this); - if ( !m_restoring ) - { - addHistoryEntry(); - } - } - - m_backAction->setEnabled( m_Current != m_history.begin() ); - m_forwardAction->setEnabled( m_Current != m_history.fromLast() ); - - return retval; -} - -void KDevHTMLPart::openURLRequest(const KURL &url) -{ - openURL( url ); -} - -void KDevHTMLPart::slotReload( ) -{ - openURL( url() ); -} - -void KDevHTMLPart::slotStop( ) -{ - closeURL(); -} - -void KDevHTMLPart::slotStarted( TDEIO::Job * ) -{ - stopAction->setEnabled(true); -} - -void KDevHTMLPart::slotCompleted( ) -{ - stopAction->setEnabled(false); -} - -void KDevHTMLPart::slotCancelled( const TQString & /*errMsg*/ ) -{ - stopAction->setEnabled(false); -} - -/*void KDevHTMLPart::slotDuplicate( ) -{ - PartController::getInstance()->showDocument(url(), true); -}*/ - -void KDevHTMLPart::slotPrint( ) -{ - view()->print(); -} - -void KDevHTMLPart::slotBack() -{ - if ( m_Current != m_history.begin() ) - { - --m_Current; - m_restoring = true; - openURL( (*m_Current).url ); - m_restoring = false; - } -} - -void KDevHTMLPart::slotForward() -{ - if ( m_Current != m_history.fromLast() ) - { - ++m_Current; - m_restoring = true; - openURL( (*m_Current).url ); - m_restoring = false; - } -} - -void KDevHTMLPart::slotBackAboutToShow() -{ - TDEPopupMenu *popup = m_backAction->popupMenu(); - popup->clear(); - - if ( m_Current == m_history.begin() ) return; - - TQValueList::Iterator it = m_Current; - --it; - - int i = 0; - while( i < 10 ) - { - if ( it == m_history.begin() ) - { - popup->insertItem( (*it).url.url(), (*it).id ); - return; - } - - popup->insertItem( (*it).url.url(), (*it).id ); - ++i; - --it; - } -} - -void KDevHTMLPart::slotForwardAboutToShow() -{ - TDEPopupMenu *popup = m_forwardAction->popupMenu(); - popup->clear(); - - if ( m_Current == m_history.fromLast() ) return; - - TQValueList::Iterator it = m_Current; - ++it; - - int i = 0; - while( i < 10 ) - { - if ( it == m_history.fromLast() ) - { - popup->insertItem( (*it).url.url(), (*it).id ); - return; - } - - popup->insertItem( (*it).url.url(), (*it).id ); - ++i; - ++it; - } -} - -void KDevHTMLPart::slotPopupActivated( int id ) -{ - kdDebug(9000) << "id: " << id << endl; - - TQValueList::Iterator it = m_history.begin(); - while( it != m_history.end() ) - { - kdDebug(9000) << "(*it).id: " << (*it).id << endl; - if ( (*it).id == id ) - { - m_Current = it; - m_restoring = true; - openURL( (*m_Current).url ); - m_restoring = false; - return; - } - ++it; - } -} - -void KDevHTMLPart::addHistoryEntry() -{ - TQValueList::Iterator it = m_Current; - - // if We're not already the last entry, we truncate the list here before adding an entry - if ( it != m_history.end() && it != m_history.fromLast() ) - { - m_history.erase( ++it, m_history.end() ); - } - - DocumentationHistoryEntry newEntry( url() ); - - // Only save the new entry if it is different from the last - if ( newEntry.url != (*m_Current).url ) - { - m_history.append( newEntry ); - m_Current = m_history.fromLast(); - } -} - -void KDevHTMLPart::slotCopy( ) -{ - TQString text = selectedText(); - text.replace( TQChar( 0xa0 ), ' ' ); - TQClipboard *cb = TQApplication::clipboard(); - disconnect( cb, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotClearSelection() ) ); - cb->setText(text); - connect( cb, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotClearSelection() ) ); -} - -void KDevHTMLPart::slotSelectionChanged( ) -{ - if (selectedText().isEmpty()) - copyAction->setEnabled(false); - else - copyAction->setEnabled(true); -} - -#include "kdevhtmlpart.moc" diff --git a/lib/widgets/kdevhtmlpart.h b/lib/widgets/kdevhtmlpart.h deleted file mode 100644 index 6c8f7dc3..00000000 --- a/lib/widgets/kdevhtmlpart.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef __KDEVHTMLPART_H__ -#define __KDEVHTMLPART_H__ - -#include - -#include - -#include - -/** -@file kdevhtmlpart.h -Customized TDEHTML part for KDevelop. -*/ - -class TDEAction; -class TDEToolBarPopupAction; - -struct DocumentationHistoryEntry { - KURL url; - int id; - - DocumentationHistoryEntry() {} - DocumentationHistoryEntry( const KURL& u ): url( u ) - { - id = abs( TQTime::currentTime().msecsTo( TQTime() ) ); // nasty, but should provide a reasonably unique number - } -}; - -/** -Customized TDEHTML part for KDevelop. -Used as HTML documentation and file viewer. - -Represents customized BrowserViewGUI mode of TDEHTMLPart. Provides also actions for: -- reload; -- stop; -- duplicate; -- print; -- copy text; -- back; -- forward. -. -It has it's own popup menu and font/zoom settings. -*/ -class KDevHTMLPart : public TDEHTMLPart -{ - Q_OBJECT - - -public: - - enum Options { CanDuplicate=1, CanOpenInNewWindow=2 }; - - KDevHTMLPart(); - - void setContext(const TQString &context); - TQString context() const; - virtual bool openURL(const KURL &url); - static TQString resolveEnvVarsInURL(const TQString& url); - - void setOptions(int options) { m_options = options; } - -signals: - void fileNameChanged(KParts::ReadOnlyPart *part); - -protected slots: - - void slotStarted(TDEIO::Job *); - void slotCompleted(); - void slotCancelled(const TQString &errMsg); - - void openURLRequest(const KURL &url); - void popup( const TQString & url, const TQPoint & p ); - - void slotReload(); - void slotStop(); - virtual void slotDuplicate() = 0; - virtual void slotOpenInNewWindow(const KURL &url) = 0; - void slotPrint(); - void slotCopy(); - void slotSelectionChanged(); - - void slotBack(); - void slotForward(); - void slotBackAboutToShow(); - void slotForwardAboutToShow(); - - void slotPopupActivated( int id ); - void addHistoryEntry(); - - -private: - - TQValueList< DocumentationHistoryEntry > m_history; - TQValueList< DocumentationHistoryEntry >::Iterator m_Current; - - TDEToolBarPopupAction* m_backAction; - TDEToolBarPopupAction* m_forwardAction; - - bool m_restoring; - - TQString m_context; - TDEAction *stopAction; - TDEAction *reloadAction; - TDEAction *duplicateAction; - TDEAction *printAction; - TDEAction *copyAction; - - int m_options; -}; - -#endif diff --git a/lib/widgets/kdevtabwidget.cpp b/lib/widgets/kdevtabwidget.cpp deleted file mode 100644 index 33c9f733..00000000 --- a/lib/widgets/kdevtabwidget.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2001-2003 * - * The KDevelop Team * - * * - * 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. * - * * - ***************************************************************************/ - -#include - -#include -#include -#include -#include - -#include "kdevtabwidget.h" - -KDevTabWidget::KDevTabWidget(TQWidget *parent, const char *name) : TQTabWidget(parent,name) -{ - m_pTabBar = new KTabBar(this, "tabbar"); - setTabBar(m_pTabBar); - connect(m_pTabBar, TQT_SIGNAL(closeWindow(const TQWidget*)), this, TQT_SIGNAL(closeWindow(const TQWidget*))); - connect(m_pTabBar, TQT_SIGNAL(closeOthers(TQWidget*)), this, TQT_SIGNAL(closeOthers(TQWidget*))); -} - -KTabBar::KTabBar(TQWidget *parent, const char *name) : TQTabBar(parent,name) -{ - m_pPopupMenu = new TQPopupMenu(this); - - TQPixmap closePixmap = TDEGlobal::instance()->iconLoader()->loadIcon( "tab_remove", TDEIcon::Small, 0, TDEIcon::DefaultState, 0, true ); - if (closePixmap.isNull()) - closePixmap = SmallIcon("fileclose"); - - m_pPopupMenu->insertItem(closePixmap, i18n("&Close"), this, TQT_SLOT(closeWindowSlot())); - m_pPopupMenu->insertItem(i18n("Close &Others"), this, TQT_SLOT(closeOthersSlot())); -} - -void KTabBar::closeWindowSlot() -{ - emit closeWindow(m_pPage); -} - -void KTabBar::closeOthersSlot() -{ - emit closeOthers(m_pPage); -} - -void KTabBar::mousePressEvent(TQMouseEvent *e) -{ - if(e->button() == Qt::RightButton) { - - TQTab *tab = selectTab(e->pos() ); - if( tab == 0L ) return; - - m_pPage = ((KDevTabWidget*)parent())->page(indexOf(tab->identifier() ) ); - if(m_pPage == 0L) return; - - m_pPopupMenu->exec(mapToGlobal(e->pos())); - } - TQTabBar::mousePressEvent(e); -} - -#include "kdevtabwidget.moc" diff --git a/lib/widgets/propeditor/CMakeLists.txt b/lib/widgets/propeditor/CMakeLists.txt index 2620aaa0..1cffb908 100644 --- a/lib/widgets/propeditor/CMakeLists.txt +++ b/lib/widgets/propeditor/CMakeLists.txt @@ -38,9 +38,9 @@ install( FILES DESTINATION ${INCLUDE_INSTALL_DIR}/tdevelop/propeditor ) -##### kdevpropertyeditor (shared) ############### +##### tdevpropertyeditor (shared) ############### -tde_add_library( kdevpropertyeditor SHARED AUTOMOC +tde_add_library( tdevpropertyeditor SHARED AUTOMOC SOURCES childproperty.cpp pcombobox.cpp pdummywidget.cpp ppointedit.cpp propertymachinefactory.cpp diff --git a/lib/widgets/propeditor/Makefile.am b/lib/widgets/propeditor/Makefile.am index e07d5c69..a01eb4d3 100644 --- a/lib/widgets/propeditor/Makefile.am +++ b/lib/widgets/propeditor/Makefile.am @@ -1,18 +1,18 @@ INCLUDES = -I$(top_srcdir)/lib/compat $(all_includes) METASOURCES = AUTO -lib_LTLIBRARIES = libkdevpropertyeditor.la -libkdevpropertyeditor_la_LIBADD = $(LIB_TDEIO) -libkdevpropertyeditor_la_LDFLAGS = -no-undefined $(all_libraries) -libkdevpropertyeditor_la_SOURCES = childproperty.cpp pcombobox.cpp pdummywidget.cpp ppointedit.cpp propertymachinefactory.cpp pstringlistedit.cpp\ +lib_LTLIBRARIES = libtdevpropertyeditor.la +libtdevpropertyeditor_la_LIBADD = $(LIB_TDEIO) +libtdevpropertyeditor_la_LDFLAGS = -no-undefined $(all_libraries) +libtdevpropertyeditor_la_SOURCES = childproperty.cpp pcombobox.cpp pdummywidget.cpp ppointedit.cpp propertymachinefactory.cpp pstringlistedit.cpp\ multiproperty.cpp pcursoredit.cpp pfontbutton.cpp prectedit.cpp propertywidget.cpp psymbolcombo.cpp\ pcheckbox.cpp pdateedit.cpp pfontcombo.cpp property.cpp psizeedit.cpp purledit.cpp\ pcolorbutton.cpp pdatetimeedit.cpp plineedit.cpp propertyeditor.cpp psizepolicyedit.cpp pyesnobutton.cpp\ pcolorcombo.cpp pdoublenuminput.cpp ppixmapedit.cpp propertylist.cpp pspinbox.cpp propertywidgetproxy.cpp plinestyleedit.cpp qeditlistbox.cpp -kdevpropeditorincludedir = $(includedir)/tdevelop/propeditor -kdevpropeditorinclude_HEADERS = childproperty.h pcombobox.h pdummywidget.h ppointedit.h propertymachinefactory.h pcursoredit.h pfontbutton.h prectedit.h propertywidget.h pdateedit.h pfontcombo.h property.h psizeedit.h pdatetimeedit.h plineedit.h propertyeditor.h psizepolicyedit.h pdoublenuminput.h ppixmapedit.h propertylist.h pspinbox.h propertywidgetproxy.h multiproperty.h pyesnobutton.h purledit.h psymbolcombo.h pstringlistedit.h pcolorcombo.h pcolorbutton.h pcheckbox.h plinestyleedit.h +tdevpropeditorincludedir = $(includedir)/tdevelop/propeditor +tdevpropeditorinclude_HEADERS = childproperty.h pcombobox.h pdummywidget.h ppointedit.h propertymachinefactory.h pcursoredit.h pfontbutton.h prectedit.h propertywidget.h pdateedit.h pfontcombo.h property.h psizeedit.h pdatetimeedit.h plineedit.h propertyeditor.h psizepolicyedit.h pdoublenuminput.h ppixmapedit.h propertylist.h pspinbox.h propertywidgetproxy.h multiproperty.h pyesnobutton.h purledit.h psymbolcombo.h pstringlistedit.h pcolorcombo.h pcolorbutton.h pcheckbox.h plinestyleedit.h DOXYGEN_REFERENCES = dcop interfaces tdecore tdefx tdeui tdehtml tdemdi tdeio kjs tdeparts tdeutils -DOXYGEN_PROJECTNAME = KDevelop Property Editing Library +DOXYGEN_PROJECTNAME = TDevelop Property Editing Library include ../../../Doxyfile.am diff --git a/lib/widgets/tdevhtml_partui.rc b/lib/widgets/tdevhtml_partui.rc new file mode 100644 index 00000000..a62fa22f --- /dev/null +++ b/lib/widgets/tdevhtml_partui.rc @@ -0,0 +1,18 @@ + + + + +

&File + + + + + + + + + + + + + diff --git a/lib/widgets/tdevhtmlpart.cpp b/lib/widgets/tdevhtmlpart.cpp new file mode 100644 index 00000000..6ec74651 --- /dev/null +++ b/lib/widgets/tdevhtmlpart.cpp @@ -0,0 +1,512 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#include "tdevhtmlpart.h" + +TDevHTMLPart::TDevHTMLPart() + : TDEHTMLPart(0L, 0L, 0L, "TDevHTMLPart", DefaultGUI ) +{ + setXMLFile(locate("data", "tdevelop/tdevhtml_partui.rc"), true); + + connect(browserExtension(), TQT_SIGNAL(openURLRequestDelayed(const KURL &,const KParts::URLArgs &)), + this, TQT_SLOT(openURLRequest(const KURL &)) ); + + connect(this, TQT_SIGNAL(started(TDEIO::Job *)), this, TQT_SLOT(slotStarted(TDEIO::Job* ))); + connect(this, TQT_SIGNAL(completed()), this, TQT_SLOT(slotCompleted())); + connect(this, TQT_SIGNAL(canceled(const TQString &)), this, TQT_SLOT(slotCancelled(const TQString &))); + + TDEActionCollection * actions = actionCollection();// new TDEActionCollection( this ); + reloadAction = new TDEAction( i18n( "Reload" ), "reload", 0, + this, TQT_SLOT( slotReload() ), actions, "doc_reload" ); + reloadAction->setWhatsThis(i18n("Reload

Reloads the current document.")); + stopAction = new TDEAction( i18n( "Stop" ), "stop", 0, + this, TQT_SLOT( slotStop() ), actions, "doc_stop" ); + stopAction->setWhatsThis(i18n("Stop

Stops the loading of current document.")); + duplicateAction = new TDEAction( i18n( "Duplicate Tab" ), "window_new", 0, + this, TQT_SLOT( slotDuplicate() ), actions, "doc_dup" ); + duplicateAction->setWhatsThis(i18n("Duplicate window

Opens current document in a new window.")); + printAction = KStdAction::print(this, TQT_SLOT(slotPrint()), actions, "print_doc"); + copyAction = KStdAction::copy(this, TQT_SLOT(slotCopy()), actions, "copy_doc_selection"); + + connect( this, TQT_SIGNAL(popupMenu(const TQString &, const TQPoint &)), this, TQT_SLOT(popup(const TQString &, const TQPoint &))); + connect(this, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged())); + +//BEGIN documentation history stuff + + m_backAction = new TDEToolBarPopupAction(i18n("Back"), "back", 0, + this, TQT_SLOT(slotBack()), + actions, "browser_back"); + m_backAction->setEnabled( false ); + m_backAction->setToolTip(i18n("Back")); + m_backAction->setWhatsThis(i18n("Back

Moves backwards one step in the documentation browsing history.")); + + connect(m_backAction->popupMenu(), TQT_SIGNAL(aboutToShow()), + this, TQT_SLOT(slotBackAboutToShow())); + connect(m_backAction->popupMenu(), TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotPopupActivated(int))); + + m_forwardAction = new TDEToolBarPopupAction(i18n("Forward"), "forward", 0, + this, TQT_SLOT(slotForward()), + actions, "browser_forward"); + m_forwardAction->setEnabled( false ); + m_forwardAction->setToolTip(i18n("Forward")); + m_forwardAction->setWhatsThis(i18n("Forward

Moves forward one step in the documentation browsing history.")); + + connect(m_forwardAction->popupMenu(), TQT_SIGNAL(aboutToShow()), + this, TQT_SLOT(slotForwardAboutToShow())); + connect(m_forwardAction->popupMenu(), TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotPopupActivated(int))); + + m_restoring = false; + m_Current = m_history.end(); +//END documentation history stuff + + //settings: + TDEConfig *appConfig = TDEGlobal::config(); + appConfig->setGroup("TDEHTMLPart"); + setStandardFont(appConfig->readEntry("StandardFont", + settings()->stdFontName())); + setFixedFont(appConfig->readEntry("FixedFont", + settings()->fixedFontName())); + setZoomFactor(appConfig->readEntry("Zoom", "100").toInt()); +} + +void TDevHTMLPart::popup( const TQString & url, const TQPoint & p ) +{ +// TDEPopupMenu popup( i18n( "Documentation Viewer" ), this->widget() ); + TDEPopupMenu popup(this->widget()); + + bool needSep = false; + int idNewWindow = -2; + if (!url.isEmpty() && (m_options & CanOpenInNewWindow)) + { + idNewWindow = popup.insertItem(SmallIcon("window_new"),i18n("Open in New Tab")); + popup.TQMenuData::setWhatsThis(idNewWindow, i18n("Open in new window

Opens current link in a new window.")); + needSep = true; + } + if (m_options & CanDuplicate) + { + duplicateAction->plug(&popup); + needSep = true; + } + if (needSep) + popup.insertSeparator(); + + m_backAction->plug( &popup ); + m_forwardAction->plug( &popup ); + reloadAction->plug(&popup); +// stopAction->plug(&popup); + popup.insertSeparator(); + + copyAction->plug( &popup ); + popup.insertSeparator(); + + printAction->plug(&popup); + popup.insertSeparator(); + + TDEAction * incFontAction = this->action("incFontSizes"); + TDEAction * decFontAction = this->action("decFontSizes"); + if ( incFontAction && decFontAction ) + { + incFontAction->plug( &popup ); + decFontAction->plug( &popup ); + popup.insertSeparator(); + } + + TDEAction *ac = action("setEncoding"); + if (ac) + ac->plug(&popup); + + int r = popup.exec(p); + + if (r == idNewWindow) + { + KURL kurl; + if (!KURL(url).path().startsWith("/")) + { + kdDebug() << "processing relative url: " << url << endl; + if (url.startsWith("#")) + { + kurl = KURL(TDevHTMLPart::url()); + kurl.setRef(url.mid(1)); + } + else + kurl = KURL(TDevHTMLPart::url().upURL().url(true)+url); + } + else + kurl = KURL(url); + + if (kurl.isValid()) + slotOpenInNewWindow(kurl); + } +} + +void TDevHTMLPart::setContext(const TQString &context) +{ + m_context = context; +} + + +TQString TDevHTMLPart::context() const +{ + return m_context; +} + + +// Note: this function is a copy of code in tdecore/tdeconfigbase.cpp ;) +static bool isUtf8(const char *buf) { + int i, n; + register unsigned char c; + bool gotone = false; + +#define F 0 /* character never appears in text */ +#define T 1 /* character appears in plain ASCII text */ +#define I 2 /* character appears in ISO-8859 text */ +#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */ + + static const unsigned char text_chars[256] = { + /* BEL BS HT LF FF CR */ + F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */ + /* ESC */ + F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */ + T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */ + /* NEL */ + X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */ + X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */ + I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */ + }; + + /* *ulen = 0; */ + for (i = 0; (c = buf[i]); i++) { + if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */ + /* + * Even if the whole file is valid UTF-8 sequences, + * still reject it if it uses weird control characters. + */ + + if (text_chars[c] != T) + return false; + + } else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */ + return false; + } else { /* 11xxxxxx begins UTF-8 */ + int following; + + if ((c & 0x20) == 0) { /* 110xxxxx */ + following = 1; + } else if ((c & 0x10) == 0) { /* 1110xxxx */ + following = 2; + } else if ((c & 0x08) == 0) { /* 11110xxx */ + following = 3; + } else if ((c & 0x04) == 0) { /* 111110xx */ + following = 4; + } else if ((c & 0x02) == 0) { /* 1111110x */ + following = 5; + } else + return false; + + for (n = 0; n < following; n++) { + i++; + if (!(c = buf[i])) + goto done; + + if ((c & 0x80) == 0 || (c & 0x40)) + return false; + } + gotone = true; + } + } +done: + return gotone; /* don't claim it's UTF-8 if it's all 7-bit */ +} +#undef F +#undef T +#undef I +#undef X + +TQString TDevHTMLPart::resolveEnvVarsInURL(const TQString& url) +{ + // check for environment variables and make necessary translations + TQString path = url; + int nDollarPos = path.find( '$' ); + + // Note: the while loop below is a copy of code in tdecore/tdeconfigbase.cpp ;) + while( nDollarPos != -1 && nDollarPos+1 < static_cast(path.length())) { + // there is at least one $ + if( (path)[nDollarPos+1] == '(' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + while ( (nEndPos <= path.length()) && (path[nEndPos]!=')') ) + nEndPos++; + nEndPos++; + TQString cmd = path.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + + TQString result; + FILE *fs = popen(TQFile::encodeName(cmd).data(), "r"); + if (fs) + { + TQTextStream ts(fs, IO_ReadOnly); + result = ts.read().stripWhiteSpace(); + pclose(fs); + } + path.replace( nDollarPos, nEndPos-nDollarPos, result ); + } else if( (path)[nDollarPos+1] != '$' ) { + uint nEndPos = nDollarPos+1; + // the next character is no $ + TQString aVarName; + if (path[nEndPos]=='{') + { + while ( (nEndPos <= path.length()) && (path[nEndPos]!='}') ) + nEndPos++; + nEndPos++; + aVarName = path.mid( nDollarPos+2, nEndPos-nDollarPos-3 ); + } + else + { + while ( nEndPos <= path.length() && (path[nEndPos].isNumber() + || path[nEndPos].isLetter() || path[nEndPos]=='_' ) ) + nEndPos++; + aVarName = path.mid( nDollarPos+1, nEndPos-nDollarPos-1 ); + } + const char* pEnv = 0; + if (!aVarName.isEmpty()) + pEnv = getenv( aVarName.ascii() ); + if( pEnv ) { + // !!! Sergey A. Sukiyazov !!! + // A environment variables may contain values in 8bit + // locale cpecified encoding or in UTF8 encoding. + if (isUtf8( pEnv )) + path.replace( nDollarPos, nEndPos-nDollarPos, TQString::fromUtf8(pEnv) ); + else + path.replace( nDollarPos, nEndPos-nDollarPos, TQString::fromLocal8Bit(pEnv) ); + } else + path.remove( nDollarPos, nEndPos-nDollarPos ); + } else { + // remove one of the dollar signs + path.remove( nDollarPos, 1 ); + nDollarPos++; + } + nDollarPos = path.find( '$', nDollarPos ); + } + + return path; +} + +bool TDevHTMLPart::openURL(const KURL &url) +{ + TQString path = resolveEnvVarsInURL(url.url()); + KURL newUrl(path); + + bool retval = TDEHTMLPart::openURL(newUrl); + if ( retval ) + { + emit fileNameChanged(this); + if ( !m_restoring ) + { + addHistoryEntry(); + } + } + + m_backAction->setEnabled( m_Current != m_history.begin() ); + m_forwardAction->setEnabled( m_Current != m_history.fromLast() ); + + return retval; +} + +void TDevHTMLPart::openURLRequest(const KURL &url) +{ + openURL( url ); +} + +void TDevHTMLPart::slotReload( ) +{ + openURL( url() ); +} + +void TDevHTMLPart::slotStop( ) +{ + closeURL(); +} + +void TDevHTMLPart::slotStarted( TDEIO::Job * ) +{ + stopAction->setEnabled(true); +} + +void TDevHTMLPart::slotCompleted( ) +{ + stopAction->setEnabled(false); +} + +void TDevHTMLPart::slotCancelled( const TQString & /*errMsg*/ ) +{ + stopAction->setEnabled(false); +} + +/*void TDevHTMLPart::slotDuplicate( ) +{ + PartController::getInstance()->showDocument(url(), true); +}*/ + +void TDevHTMLPart::slotPrint( ) +{ + view()->print(); +} + +void TDevHTMLPart::slotBack() +{ + if ( m_Current != m_history.begin() ) + { + --m_Current; + m_restoring = true; + openURL( (*m_Current).url ); + m_restoring = false; + } +} + +void TDevHTMLPart::slotForward() +{ + if ( m_Current != m_history.fromLast() ) + { + ++m_Current; + m_restoring = true; + openURL( (*m_Current).url ); + m_restoring = false; + } +} + +void TDevHTMLPart::slotBackAboutToShow() +{ + TDEPopupMenu *popup = m_backAction->popupMenu(); + popup->clear(); + + if ( m_Current == m_history.begin() ) return; + + TQValueList::Iterator it = m_Current; + --it; + + int i = 0; + while( i < 10 ) + { + if ( it == m_history.begin() ) + { + popup->insertItem( (*it).url.url(), (*it).id ); + return; + } + + popup->insertItem( (*it).url.url(), (*it).id ); + ++i; + --it; + } +} + +void TDevHTMLPart::slotForwardAboutToShow() +{ + TDEPopupMenu *popup = m_forwardAction->popupMenu(); + popup->clear(); + + if ( m_Current == m_history.fromLast() ) return; + + TQValueList::Iterator it = m_Current; + ++it; + + int i = 0; + while( i < 10 ) + { + if ( it == m_history.fromLast() ) + { + popup->insertItem( (*it).url.url(), (*it).id ); + return; + } + + popup->insertItem( (*it).url.url(), (*it).id ); + ++i; + ++it; + } +} + +void TDevHTMLPart::slotPopupActivated( int id ) +{ + kdDebug(9000) << "id: " << id << endl; + + TQValueList::Iterator it = m_history.begin(); + while( it != m_history.end() ) + { + kdDebug(9000) << "(*it).id: " << (*it).id << endl; + if ( (*it).id == id ) + { + m_Current = it; + m_restoring = true; + openURL( (*m_Current).url ); + m_restoring = false; + return; + } + ++it; + } +} + +void TDevHTMLPart::addHistoryEntry() +{ + TQValueList::Iterator it = m_Current; + + // if We're not already the last entry, we truncate the list here before adding an entry + if ( it != m_history.end() && it != m_history.fromLast() ) + { + m_history.erase( ++it, m_history.end() ); + } + + DocumentationHistoryEntry newEntry( url() ); + + // Only save the new entry if it is different from the last + if ( newEntry.url != (*m_Current).url ) + { + m_history.append( newEntry ); + m_Current = m_history.fromLast(); + } +} + +void TDevHTMLPart::slotCopy( ) +{ + TQString text = selectedText(); + text.replace( TQChar( 0xa0 ), ' ' ); + TQClipboard *cb = TQApplication::clipboard(); + disconnect( cb, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotClearSelection() ) ); + cb->setText(text); + connect( cb, TQT_SIGNAL( selectionChanged() ), this, TQT_SLOT( slotClearSelection() ) ); +} + +void TDevHTMLPart::slotSelectionChanged( ) +{ + if (selectedText().isEmpty()) + copyAction->setEnabled(false); + else + copyAction->setEnabled(true); +} + +#include "tdevhtmlpart.moc" diff --git a/lib/widgets/tdevhtmlpart.h b/lib/widgets/tdevhtmlpart.h new file mode 100644 index 00000000..e822488b --- /dev/null +++ b/lib/widgets/tdevhtmlpart.h @@ -0,0 +1,111 @@ +#ifndef __TDEVHTMLPART_H__ +#define __TDEVHTMLPART_H__ + +#include + +#include + +#include + +/** +@file tdevhtmlpart.h +Customized TDEHTML part for KDevelop. +*/ + +class TDEAction; +class TDEToolBarPopupAction; + +struct DocumentationHistoryEntry { + KURL url; + int id; + + DocumentationHistoryEntry() {} + DocumentationHistoryEntry( const KURL& u ): url( u ) + { + id = abs( TQTime::currentTime().msecsTo( TQTime() ) ); // nasty, but should provide a reasonably unique number + } +}; + +/** +Customized TDEHTML part for KDevelop. +Used as HTML documentation and file viewer. + +Represents customized BrowserViewGUI mode of TDEHTMLPart. Provides also actions for: +- reload; +- stop; +- duplicate; +- print; +- copy text; +- back; +- forward. +. +It has it's own popup menu and font/zoom settings. +*/ +class TDevHTMLPart : public TDEHTMLPart +{ + Q_OBJECT + + +public: + + enum Options { CanDuplicate=1, CanOpenInNewWindow=2 }; + + TDevHTMLPart(); + + void setContext(const TQString &context); + TQString context() const; + virtual bool openURL(const KURL &url); + static TQString resolveEnvVarsInURL(const TQString& url); + + void setOptions(int options) { m_options = options; } + +signals: + void fileNameChanged(KParts::ReadOnlyPart *part); + +protected slots: + + void slotStarted(TDEIO::Job *); + void slotCompleted(); + void slotCancelled(const TQString &errMsg); + + void openURLRequest(const KURL &url); + void popup( const TQString & url, const TQPoint & p ); + + void slotReload(); + void slotStop(); + virtual void slotDuplicate() = 0; + virtual void slotOpenInNewWindow(const KURL &url) = 0; + void slotPrint(); + void slotCopy(); + void slotSelectionChanged(); + + void slotBack(); + void slotForward(); + void slotBackAboutToShow(); + void slotForwardAboutToShow(); + + void slotPopupActivated( int id ); + void addHistoryEntry(); + + +private: + + TQValueList< DocumentationHistoryEntry > m_history; + TQValueList< DocumentationHistoryEntry >::Iterator m_Current; + + TDEToolBarPopupAction* m_backAction; + TDEToolBarPopupAction* m_forwardAction; + + bool m_restoring; + + TQString m_context; + TDEAction *stopAction; + TDEAction *reloadAction; + TDEAction *duplicateAction; + TDEAction *printAction; + TDEAction *copyAction; + + int m_options; +}; + +#endif diff --git a/lib/widgets/tdevtabwidget.cpp b/lib/widgets/tdevtabwidget.cpp new file mode 100644 index 00000000..adfd4566 --- /dev/null +++ b/lib/widgets/tdevtabwidget.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2001-2003 * + * The KDevelop Team * + * * + * 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. * + * * + ***************************************************************************/ + +#include + +#include +#include +#include +#include + +#include "tdevtabwidget.h" + +TDevTabWidget::TDevTabWidget(TQWidget *parent, const char *name) : TQTabWidget(parent,name) +{ + m_pTabBar = new KTabBar(this, "tabbar"); + setTabBar(m_pTabBar); + connect(m_pTabBar, TQT_SIGNAL(closeWindow(const TQWidget*)), this, TQT_SIGNAL(closeWindow(const TQWidget*))); + connect(m_pTabBar, TQT_SIGNAL(closeOthers(TQWidget*)), this, TQT_SIGNAL(closeOthers(TQWidget*))); +} + +KTabBar::KTabBar(TQWidget *parent, const char *name) : TQTabBar(parent,name) +{ + m_pPopupMenu = new TQPopupMenu(this); + + TQPixmap closePixmap = TDEGlobal::instance()->iconLoader()->loadIcon( "tab_remove", TDEIcon::Small, 0, TDEIcon::DefaultState, 0, true ); + if (closePixmap.isNull()) + closePixmap = SmallIcon("fileclose"); + + m_pPopupMenu->insertItem(closePixmap, i18n("&Close"), this, TQT_SLOT(closeWindowSlot())); + m_pPopupMenu->insertItem(i18n("Close &Others"), this, TQT_SLOT(closeOthersSlot())); +} + +void KTabBar::closeWindowSlot() +{ + emit closeWindow(m_pPage); +} + +void KTabBar::closeOthersSlot() +{ + emit closeOthers(m_pPage); +} + +void KTabBar::mousePressEvent(TQMouseEvent *e) +{ + if(e->button() == Qt::RightButton) { + + TQTab *tab = selectTab(e->pos() ); + if( tab == 0L ) return; + + m_pPage = ((TDevTabWidget*)parent())->page(indexOf(tab->identifier() ) ); + if(m_pPage == 0L) return; + + m_pPopupMenu->exec(mapToGlobal(e->pos())); + } + TQTabBar::mousePressEvent(e); +} + +#include "tdevtabwidget.moc" -- cgit v1.2.3