Code refactoring: pointers instead of names in Palettes

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 4a051f2ac4
commit 927c77ac25
  1. 13
      src/board/UBBoardPaletteManager.cpp
  2. 8
      src/gui/UBCachePropertiesWidget.cpp
  3. 48
      src/gui/UBDockPalette.cpp
  4. 7
      src/gui/UBDockPalette.h
  5. 4
      src/gui/UBDockPaletteWidget.h

@ -202,8 +202,11 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
// The cache widget will be visible only if a cache is put on the page
mRightPalette->registerWidget(mpCachePropWidget);
// The teacher bar widget will always be there
mRightPalette->registerWidget(mpTeacherBarWidget);
mRightPalette->addTab(mpTeacherBarWidget);
// TeacherBarWidget moved to left side just for testing!!!!
mLeftPalette->registerWidget(mpTeacherBarWidget);
mLeftPalette->addTab(mpTeacherBarWidget);
// The download widget will be part of the right palette but
// will become visible only when the first download starts
mRightPalette->registerWidget(mpDownloadWidget);
@ -211,8 +214,8 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
changeMode(eUBDockPaletteWidget_BOARD, true);
// Hide the tabs that must be hidden
mRightPalette->removeTab(mpDownloadWidget->name());
mRightPalette->removeTab(mpCachePropWidget->name());
mRightPalette->removeTab(mpDownloadWidget);
mRightPalette->removeTab(mpCachePropWidget);
// mLeftPalette->showTabWidget(0);
// mRightPalette->showTabWidget(0);
@ -998,7 +1001,7 @@ void UBBoardPaletteManager::stopDownloads()
{
mDownloadInProgress = false;
mpDownloadWidget->setVisibleState(false);
mRightPalette->removeTab(mpDownloadWidget->name());
mRightPalette->removeTab(mpDownloadWidget);
}
}

@ -222,7 +222,7 @@ void UBCachePropertiesWidget::onCloseClicked()
emit cacheListEmpty();
}
emit hideTab(name());
emit hideTab(this);
}
}
@ -300,7 +300,7 @@ void UBCachePropertiesWidget::updateCurrentCache()
if("Cache" == it->data(Qt::UserRole).toString())
{
setEnabled(true);
emit showTab(name());
emit showTab(this);
mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it);
if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache)))
{
@ -331,7 +331,7 @@ void UBCachePropertiesWidget::updateCurrentCache()
// 1 - that this page has no cache
// 2 - we are not in Board mode
// 3 - we are in Board mode, but show desktop (as really - Desktop mode)
emit hideTab(name());
emit hideTab(this);
mpCurrentCache = NULL;
setDisabled(true);
}
@ -346,6 +346,6 @@ void UBCachePropertiesWidget::onSizeChanged(int newSize)
void UBCachePropertiesWidget::onCacheEnabled()
{
emit showTab(name());
emit showTab(this);
}

@ -567,19 +567,15 @@ void UBDockPalette::addTab(UBDockPaletteWidget *widget)
* \brief Remove the given tab
* @param widgetName as the tab widget name
*/
void UBDockPalette::removeTab(const QString &widgetName)
void UBDockPalette::removeTab(UBDockPaletteWidget* widget)
{
for(int i = 0; i < mTabWidgets.size(); i++)
int nWidget = mTabWidgets.indexOf(widget);
if( nWidget >= 0 )
{
UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
{
mpStackWidget->removeWidget(pCrntWidget);
mTabWidgets.remove(i);
pCrntWidget->hide();
mpStackWidget->removeWidget(widget);
mTabWidgets.remove(nWidget);
widget->hide();
update();
break;
}
}
resizeTabs();
mCurrentTab = qMax(mCurrentTab - 1, 0);
@ -607,17 +603,12 @@ int UBDockPalette::tabSpacing()
* \brief Show the given widget
* @param widgetName as the given widget name
*/
void UBDockPalette::onShowTabWidget(const QString &widgetName)
{
for(int i = 0; i < mRegisteredWidgets.size(); i++)
void UBDockPalette::onShowTabWidget(UBDockPaletteWidget* widget)
{
UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
if (mRegisteredWidgets.contains(widget))
{
pCrntWidget->setVisibleState(true);
addTab(pCrntWidget);
break;
}
widget->setVisibleState(true);
addTab(widget);
}
}
@ -625,16 +616,13 @@ void UBDockPalette::onShowTabWidget(const QString &widgetName)
* \brief Hide the given widget
* @param widgetName as the given widget name
*/
void UBDockPalette::onHideTabWidget(const QString &widgetName)
void UBDockPalette::onHideTabWidget(UBDockPaletteWidget* widget)
{
for(int i = 0; i < mRegisteredWidgets.size(); i++){
UBDockPaletteWidget* pCrntWidget = mRegisteredWidgets.at(i);
if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName)){
pCrntWidget->setVisibleState(false);
break;
}
if (mRegisteredWidgets.contains(widget))
{
widget->setVisibleState(false);
removeTab(widget);
}
removeTab(widgetName);
}
/**
@ -644,8 +632,8 @@ void UBDockPalette::connectSignals()
{
for(int i=0; i < mRegisteredWidgets.size(); i++)
{
connect(mRegisteredWidgets.at(i), SIGNAL(showTab(QString)), this, SLOT(onShowTabWidget(QString)));
connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(QString)), this, SLOT(onHideTabWidget(QString)));
connect(mRegisteredWidgets.at(i), SIGNAL(showTab(UBDockPaletteWidget*)), this, SLOT(onShowTabWidget(UBDockPaletteWidget*)));
connect(mRegisteredWidgets.at(i), SIGNAL(hideTab(UBDockPaletteWidget*)), this, SLOT(onHideTabWidget(UBDockPaletteWidget*)));
}
}
@ -747,7 +735,7 @@ bool UBDockPalette::switchMode(eUBDockPaletteWidgetMode mode)
}
else
{
removeTab(pNextWidget->name());
removeTab(pNextWidget);
}
}
}

@ -111,8 +111,9 @@ public:
void setBackgroundBrush(const QBrush& brush);
void registerWidget(UBDockPaletteWidget* widget);
void addTab(UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName);
void removeTab(UBDockPaletteWidget* widget);
void connectSignals();
@ -129,8 +130,8 @@ public:
eUBDockPaletteType paletteType(){return mPaletteType;}
public slots:
void onShowTabWidget(const QString& widgetName);
void onHideTabWidget(const QString& widgetName);
void onShowTabWidget(UBDockPaletteWidget* widget);
void onHideTabWidget(UBDockPaletteWidget* widget);
void onAllDownloadsFinished();
protected:

@ -31,8 +31,8 @@ public:
void setVisibleState(bool state){mVisibleState = state;}
signals:
void hideTab(const QString& widgetName);
void showTab(const QString& widgetName);
void hideTab(UBDockPaletteWidget* widget);
void showTab(UBDockPaletteWidget* widget);
public slots:
void slot_changeMode(eUBDockPaletteWidgetMode newMode);

Loading…
Cancel
Save