From 4532c60f31091794b6d1f20f69b071f96422a9dc Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Fri, 7 Nov 2008 18:06:03 -0800 Subject: [PATCH] Bus-Dev --- src/Baulk/Control/control.cpp | 85 +++++++++++++++++++++++++++++++++++++++---- src/Baulk/Control/control.h | 5 +++ 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/Baulk/Control/control.cpp b/src/Baulk/Control/control.cpp index 0ee67bd..7af3c30 100644 --- a/src/Baulk/Control/control.cpp +++ b/src/Baulk/Control/control.cpp @@ -46,6 +46,7 @@ BaulkControl::BaulkControl( QWidget *parent ) : BaulkWidget( parent ) { dynBotLayout = new QSplitter( Qt::Vertical ); tabLayer->addWidget( dynTopLayout ); dynTopLayout->addWidget( dynBotLayout ); + invertIndex = false; // Layout Property Setup topVLayout->setContentsMargins( 0,0,0,0 ); @@ -249,8 +250,6 @@ void BaulkControl::swapOrientationTop() { } // ** Focus Control -// Note: Incrementing the coordinate is only needed on max value cases due to how Qt -// calculates max x and y, see Qt docs for more details void BaulkControl::focusDec() { int curPos = dynBotIndex(); @@ -262,6 +261,23 @@ void BaulkControl::focusDec() { dynBotLayout->widget( curPos - 1 )->setFocus(); } +void BaulkControl::focusDecBorder() { + int curPos = dynBotIndex(); + + // Use Inverted Index + invertIndex = true; + + // Boundary Case + if ( curPos == 0 ) + focusLayoutDec(); + + // Revert Inverted Index + invertIndex = false; + + // Normal Case + focusDec(); +} + void BaulkControl::focusDown() { switch ( dynBotLayout->orientation() ) { case Qt::Horizontal: @@ -275,7 +291,14 @@ void BaulkControl::focusDown() { } break; case Qt::Vertical: - focusInc(); + switch ( dynTopLayout->orientation() ) { + case Qt::Vertical: + focusIncBorder(); + break; + default: + focusInc(); + break; + } break; default: qCritical( tr("%1\n\tInvalid Orientation, Focus Down").arg( errorName() ).toUtf8() ); @@ -294,6 +317,23 @@ void BaulkControl::focusInc() { dynBotLayout->widget( curPos + 1 )->setFocus(); } +void BaulkControl::focusIncBorder() { + int curPos = dynBotIndex(); + + // Use Inverted Index + invertIndex = true; + + // Boundary Case + if ( curPos == dynBotLayout->count() - 1 ) + focusLayoutInc(); + + // Revert Inverted Index + invertIndex = false; + + // Normal Case + focusInc(); +} + void BaulkControl::focusLayoutDec() { int curPos = dynBotIndex(); int curLayoutPos = dynTopLayout->indexOf( dynBotLayout ); @@ -306,8 +346,13 @@ void BaulkControl::focusLayoutDec() { dynBotLayout = qobject_cast( dynTopLayout->widget( curLayoutPos - 1 ) ); // Set Focus - if ( curPos >= dynBotLayout->count() ) + if ( curPos >= dynBotLayout->count() ) curPos = dynBotLayout->count() - 1; + + // Orientation Case + if ( invertIndex ) + curPos = 0; + dynBotLayout->widget( curPos )->setFocus(); } @@ -331,7 +376,14 @@ void BaulkControl::focusLayoutInc() { void BaulkControl::focusLeft() { switch ( dynBotLayout->orientation() ) { case Qt::Horizontal: - focusDec(); + switch( dynTopLayout->orientation() ) { + case Qt::Horizontal: + focusDecBorder(); + break; + default: + focusDec(); + break; + } break; case Qt::Vertical: // If Layout is Vertical/Vertical then do nothing @@ -352,7 +404,13 @@ void BaulkControl::focusLeft() { void BaulkControl::focusRight() { switch ( dynBotLayout->orientation() ) { case Qt::Horizontal: - focusInc(); + switch( dynTopLayout->orientation() ) { + case Qt::Horizontal: + focusIncBorder(); + default: + focusInc(); + break; + } break; case Qt::Vertical: // If Layout is Vertical/Vertical then do nothing @@ -383,7 +441,14 @@ void BaulkControl::focusUp() { } break; case Qt::Vertical: - focusDec(); + switch( dynTopLayout->orientation() ) { + case Qt::Vertical: + focusDecBorder(); + break; + default: + focusDec(); + break; + } break; default: qCritical( tr("%1\n\tInvalid Orientation, Focus Up").arg( errorName() ).toUtf8() ); @@ -452,6 +517,9 @@ void BaulkControl::moveDec() { dynBotLayout->insertWidget( index - 1, dynBotLayout->widget( index ) ); } +void BaulkControl::moveDecBorder() { +} + void BaulkControl::moveDown() { switch ( dynBotLayout->orientation() ) { case Qt::Horizontal: @@ -487,6 +555,9 @@ void BaulkControl::moveInc() { dynBotLayout->insertWidget( index + 1, dynBotLayout->widget( index ) ); } +void BaulkControl::moveIncBorder() { +} + void BaulkControl::moveLayoutDec() { int curPos = dynBotIndex(); int curLayoutPos = dynTopLayout->indexOf( dynBotLayout ); diff --git a/src/Baulk/Control/control.h b/src/Baulk/Control/control.h index 27bd7b8..49a81f1 100644 --- a/src/Baulk/Control/control.h +++ b/src/Baulk/Control/control.h @@ -75,6 +75,7 @@ private: QSplitter *dynTopLayout; QSplitter *dynBotLayout; int lastKnownGoodIndex; + bool invertIndex; // Global QActions QList glbQActions; @@ -109,8 +110,10 @@ private slots: // Tile Manipulation // ** Focus void focusDec(); + void focusDecBorder(); void focusDown(); void focusInc(); + void focusIncBorder(); void focusLeft(); void focusLayoutDec(); void focusLayoutInc(); @@ -118,8 +121,10 @@ private slots: void focusUp(); // ** Moving void moveDec(); + void moveDecBorder(); void moveDown(); void moveInc(); + void moveIncBorder(); void moveLeft(); void moveLayoutDec(); void moveLayoutInc(); -- 2.11.4.GIT