Commit 465cca54 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[REMOVE] removed ribbonMenu code. Not used.

parent 7f5f1476
......@@ -56,7 +56,7 @@ ENDIF()
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
FILE(GLOB GUI_QT4_SRC "*.cpp" "guiElements/*.cpp" "controlPanel/*.cpp" "ribbonMenu/*.cpp" "events/*.cpp" "networkEditor/*.cpp" "*.h" "guiElements/*.h" "controlPanel/*.h" "ribbonMenu/*.h" "events/*.h" "networkEditor/*.h" "../icons/WIcons.h" )
FILE(GLOB GUI_QT4_SRC "*.cpp" "guiElements/*.cpp" "controlPanel/*.cpp" "events/*.cpp" "networkEditor/*.cpp" "*.h" "guiElements/*.h" "controlPanel/*.h" "events/*.h" "networkEditor/*.h" "../icons/WIcons.h" )
IF( CMAKE_HOST_SYSTEM MATCHES Darwin )
FILE( GLOB GUIQT4_PLATFORMDEPENDENT_SRC
"platformDependent/WQtGLWidgetMac.cpp"
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <vector>
#include "WQtMenuPage.h"
WQtMenuPage::WQtMenuPage( QString name, bool persistent )
: QWidget()
{
m_name = name;
m_persistent = persistent;
m_pageLayout = new QHBoxLayout();
m_pageLayout->addStretch();
this->setLayout( m_pageLayout );
}
WQtMenuPage::~WQtMenuPage()
{
}
QString WQtMenuPage::getName()
{
return m_name;
}
std::vector< QString > WQtMenuPage::getButtons()
{
return m_ownButtons;
}
void WQtMenuPage::addButton( WQtPushButton* button )
{
int count = m_pageLayout->count();
m_pageLayout->insertWidget( count -1, button );
this->setLayout( m_pageLayout );
m_ownButtons.push_back( button->getName() );
}
bool WQtMenuPage::isPersistent() const
{
return m_persistent;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTMENUPAGE_H
#define WQTMENUPAGE_H
#include <vector>
#include <QtGui/QHBoxLayout>
#include <QtGui/QWidget>
#include "../guiElements/WQtPushButton.h"
/**
* This class represents a menu page inside the ribbon menu. It offers several methods to add buttons and manage the menu.
*/
class WQtMenuPage : public QWidget
{
public:
/**
* Constructor creates new tab.
*
* \param name name of tab
* \param persistent true if persistent
*/
WQtMenuPage( QString name, bool persistent = true );
/**
* Destructor.
*/
virtual ~WQtMenuPage();
/**
* Add a new button to this menu page in the ribbon menu.
*
* \param button the new button to add
*/
void addButton( WQtPushButton* button );
/**
* Gives back the list of buttons associated with this tab.
*
* \return the list of buttons
*/
std::vector< QString > getButtons();
/**
* Returns the name of the tab.
*
* \return the name of this menu page.
*/
QString getName();
/**
* Determines whether this tab is persistent.
*
* \return true if persistent.
*/
bool isPersistent() const;
protected:
/**
* True if the tab should not disappear when treeitem selection event occurs.
*/
bool m_persistent;
private:
QHBoxLayout* m_pageLayout; //!< Organizes the layout of the tab horizontally.
QString m_name; //!< Name of the tab.
/**
* List of buttons belonging to this tab.
*/
std::vector< QString > m_ownButtons;
};
#endif // WQTMENUPAGE_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cassert>
#include <iostream>
#include <vector>
#include <map>
#include "WQtRibbonMenu.h"
WQtRibbonMenu::WQtRibbonMenu( const QString & title, QWidget* parent )
: QToolBar( title, parent )
{
this->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
m_tabWidget = new QTabWidget();
this->addWidget( m_tabWidget );
}
WQtRibbonMenu::~WQtRibbonMenu()
{
}
WQtMenuPage* WQtRibbonMenu::addTab( QString name, bool persistent )
{
// don't add a tab with the same name twice
assert( m_tabList.count( name ) == 0 );
WQtMenuPage* tab = new WQtMenuPage( name, persistent );
m_tabWidget->addTab( tab, name );
m_tabList[name] = tab;
return tab;
}
WQtPushButton* WQtRibbonMenu::addPushButton( QString name, QString tabName, QIcon icon, QString label )
{
assert( m_tabList.count( tabName ) == 1 );
assert( m_buttonList.count( name ) == 0 );
WQtPushButton* button = new WQtPushButton( icon, label );
button->setName( name );
m_tabList[tabName]->addButton( button );
m_buttonList[name] = button;
return button;
}
WQtPushButton* WQtRibbonMenu::getButton( QString name )
{
assert( m_buttonList.count( name ) == 1 );
return m_buttonList[name];
}
void WQtRibbonMenu::clearNonPersistentTabs()
{
for ( std::map< QString, WQtMenuPage*>::iterator iter = m_tabList.begin(); iter != m_tabList.end(); )
{
int idx = m_tabWidget->indexOf( ( *iter ).second );
if ( !( *iter ).second->isPersistent() )
{
std::vector< QString > buttons = ( *iter ).second->getButtons();
for ( std::vector< QString >::iterator bIter = buttons.begin(); bIter != buttons.end(); ++bIter )
{
m_buttonList.erase( *bIter );
}
m_tabWidget->removeTab( idx );
m_tabList.erase( iter++ );
}
else
{
++iter;
}
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTRIBBONMENU_H
#define WQTRIBBONMENU_H
#include <map>
#include <QtGui/QTabWidget>
#include <QtGui/QToolBar>
#include "WQtMenuPage.h"
#include "../guiElements/WQtPushButton.h"
/**
* implementation of a ribbon menu like widget
*/
class WQtRibbonMenu : public QToolBar
{
public:
/**
* default constructor
* \param title name of the ribbon menu.
* \param parent the parent widget of this widget, i.e. the widget that manages it.
*/
explicit WQtRibbonMenu( const QString & title, QWidget* parent );
/**
* destructor
*/
virtual ~WQtRibbonMenu();
/**
* Adds a new tab to the ribbon menu and gives it a name.
* \param name The name of the tab.
* \param persistent Determines whether the new will be removed when removing non-persistent tabs.
*/
WQtMenuPage* addTab( QString name, bool persistent = true );
/**
* Adds a push button to the menu. The button is identifiable by its name.
* \param name a name for the new button to identifie it
* \param tabName the name of the tab to which the button is added.
* \param icon and icon for the button
* \param label The optional text that is displayed besides the icon on the button.
*/
WQtPushButton* addPushButton( QString name, QString tabName, QIcon icon, QString label = 0 );
/**
* Get a button by its name.
* \param name The name that identifies the button.
*/
WQtPushButton* getButton( QString name );
/**
* Removes tabs that are not marked persistent.
*/
void clearNonPersistentTabs();
protected:
private:
std::map< QString, WQtMenuPage*> m_tabList; //!< List holding the widgets representing the tabs of the menu.
std::map< QString, WQtPushButton*> m_buttonList; //!< List holding the buttons that appear in the menu.
QTabWidget* m_tabWidget; //!< The tab widget beeing the basis for the ribbon menu.
};
#endif // WQTRIBBONMENU_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment