[Patch] Close Other Tabs
Igor Gilitschenski
igor at gilitschenski.org
Wed Aug 14 02:17:25 BST 2002
Hi,
I wrote a patch, which adds an 'Close Other Tabs' menu item to the Tabs
popup menu.
To achieve this I wrote two slots: one to handle the popupmenu signal
and the other to handle a potential keyboard shortcut, which wasn't
implemented, since I'm not sure, wether this feature is often used.
I didn't develop with KDE and Qt for some time, so there are possibly
some Bugs in this patch (I however hope that there are not. It worked
for me).
Could you comment on it and apply it, if you consider it useful (I don't
have write access to KDE CVS) to the cvs?
CU,
Igor
--
"Ist es nicht seltsam, dass die Menschen so gern für ihre
Religion fechten und so ungern nach ihren Vorschriften leben?"
-- Georg Christoph Lichtenberg
-------------- next part --------------
Index: konq_frame.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_frame.cc,v
retrieving revision 1.150
diff -u -3 -p -r1.150 konq_frame.cc
--- konq_frame.cc 17 Jul 2002 09:46:24 -0000 1.150
+++ konq_frame.cc 14 Aug 2002 00:45:56 -0000
@@ -766,6 +766,7 @@ KonqTabBar::KonqTabBar(KonqViewManager*
m_pPopupMenu->insertItem( SmallIcon( "tab_duplicate" ), "&Duplicate Tab", m_pViewManager->mainWindow(), SLOT( slotDuplicateTabPopup() ) );
m_pPopupMenu->insertSeparator();
m_pPopupMenu->insertItem( SmallIcon( "tab_remove" ), "&Close Tab", m_pViewManager->mainWindow(), SLOT( slotRemoveTabPopup() ) );
+ m_pPopupMenu->insertItem( SmallIcon( "tab_remove" ), "Close &Other Tabs", m_pViewManager->mainWindow(), SLOT( slotRemoveOtherTabsPopup() ) );
m_pPopupMenu->insertItem( SmallIcon( "tab_breakoff" ), "&Detach Tab", m_pViewManager->mainWindow(), SLOT( slotBreakOffTabPopup() ) );
}
Index: konq_mainwindow.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.cc,v
retrieving revision 1.1040
diff -u -3 -p -r1.1040 konq_mainwindow.cc
--- konq_mainwindow.cc 11 Aug 2002 14:53:18 -0000 1.1040
+++ konq_mainwindow.cc 14 Aug 2002 00:46:20 -0000
@@ -2064,6 +2064,18 @@ void KonqMainWindow::slotRemoveTabPopup(
m_pViewManager->removeTab( m_pWorkingTab );
}
+
+void KonqMainWindow::slotRemoveOtherTabs()
+{
+ m_pViewManager->removeOtherTabs();
+}
+
+void KonqMainWindow::slotRemoveOtherTabsPopup()
+{
+ m_pViewManager->removeOtherTabs( m_pWorkingTab );
+}
+
+
void KonqMainWindow::slotDumpDebugInfo()
{
#ifndef NDEBUG
Index: konq_mainwindow.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.h,v
retrieving revision 1.365
diff -u -3 -p -r1.365 konq_mainwindow.h
--- konq_mainwindow.h 29 Jul 2002 17:32:04 -0000 1.365
+++ konq_mainwindow.h 14 Aug 2002 00:46:20 -0000
@@ -377,6 +377,8 @@ protected slots:
void slotPopupNewTabAtFront();
void slotPopupPasteTo();
void slotRemoveView();
+ void slotRemoveOtherTabs();
+ void slotRemoveOtherTabsPopup();
void slotRemoveTab();
void slotRemoveTabPopup();
void slotDumpDebugInfo();
Index: konq_viewmgr.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_viewmgr.cc,v
retrieving revision 1.191
diff -u -3 -p -r1.191 konq_viewmgr.cc
--- konq_viewmgr.cc 29 Jul 2002 15:27:42 -0000 1.191
+++ konq_viewmgr.cc 14 Aug 2002 00:46:25 -0000
@@ -549,6 +549,34 @@ void KonqViewManager::removeTab( KonqFra
#endif
}
+
+void KonqViewManager::removeOtherTabs( KonqFrameBase* tab )
+{
+
+ if (m_pDocContainer == 0L) return;
+ if (m_pDocContainer->frameType() != "Tabs") return;
+
+ KonqFrameTabs* tabContainer = static_cast<KonqFrameTabs*>(m_pDocContainer);
+
+ KonqFrameBase *currentFrame;
+
+ if ( tab == 0L )
+ currentFrame = dynamic_cast<KonqFrameBase*>(tabContainer->currentPage());
+ else
+ currentFrame = tab;
+
+
+ QPtrList<KonqFrameBase> frameList = *tabContainer->childFrameList();
+ QPtrListIterator<KonqFrameBase> it( frameList );
+
+ for ( it.toFirst(); it != 0L; ++it )
+ {
+ if( it.current() != tab)
+ removeTab(it.current());
+ }
+
+}
+
void KonqViewManager::showTab( KonqView *view )
{
static_cast<KonqFrameTabs*>( docContainer() )->showPage( view->frame() );
Index: konq_viewmgr.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_viewmgr.h,v
retrieving revision 1.63
diff -u -3 -p -r1.63 konq_viewmgr.h
--- konq_viewmgr.h 29 Jul 2002 15:27:42 -0000 1.63
+++ konq_viewmgr.h 14 Aug 2002 00:46:27 -0000
@@ -126,6 +126,12 @@ public:
void removeTab( KonqFrameBase* tab = 0L );
/**
+ * Removes all, but the specified tab. If no tab is scpecified evry tab, but the current will be removed
+ * Also takes care of setting the specified tab as active if the active view was not in this tab
+ */
+ void removeOtherTabs( KonqFrameBase* tab = 0L );
+
+ /**
* Brings the tab specified by @p view to the front of the stack
*
*/
More information about the kfm-devel
mailing list