Re-implement Ctrl+Shift+Left/Right to move the current tab left or right. Fix float->int conversion warning.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=682750
This commit is contained in:
Robert Knight
2007-07-03 10:53:44 +00:00
parent 72241ef4a6
commit e12174c2ff
5 changed files with 106 additions and 3 deletions

View File

@@ -62,6 +62,32 @@ ViewContainer::~ViewContainer()
{
emit destroyed(this);
}
void ViewContainer::moveViewWidget( int , int ) {}
void ViewContainer::moveActiveView( MoveDirection direction )
{
const int currentIndex = _views.indexOf( activeView() ) ;
int newIndex = -1;
switch ( direction )
{
case MoveViewLeft:
newIndex = qMax( currentIndex-1 , 0 );
break;
case MoveViewRight:
newIndex = qMin( currentIndex+1 , _views.count() -1 );
break;
}
Q_ASSERT( newIndex != -1 );
moveViewWidget( currentIndex , newIndex );
_views.swap(currentIndex,newIndex);
setActiveView( _views[newIndex] );
}
void ViewContainer::setNavigationDisplayMode(NavigationDisplayMode mode)
{
_navigationDisplayMode = mode;
@@ -537,6 +563,21 @@ void TabbedViewContainerV2::tabDoubleClicked(int tab)
//emit duplicateRequest();
}
}
void TabbedViewContainerV2::moveViewWidget( int fromIndex , int toIndex )
{
QString text = _tabBar->tabText(fromIndex);
QIcon icon = _tabBar->tabIcon(fromIndex);
// FIXME - This will lose properties of the tab other than
// their text and icon when moving them
_tabBar->removeTab(fromIndex);
_tabBar->insertTab(toIndex,icon,text);
QWidget* widget = _stackWidget->widget(fromIndex);
_stackWidget->removeWidget(widget);
_stackWidget->insertWidget(toIndex,widget);
}
void TabbedViewContainerV2::currentTabChanged(int index)
{
_stackWidget->setCurrentIndex(index);