178 lines
5 KiB
C
178 lines
5 KiB
C
|
/********************************************************************
|
||
|
KWin - the KDE window manager
|
||
|
This file is part of the KDE project.
|
||
|
|
||
|
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation; either version 2 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program 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 General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*********************************************************************/
|
||
|
|
||
|
#ifndef TABBOXVIEW_H
|
||
|
#define TABBOXVIEW_H
|
||
|
|
||
|
#include <QTableView>
|
||
|
/**
|
||
|
* @file
|
||
|
* This file desfines the classes which build up the view of the TabBox.
|
||
|
*
|
||
|
* @author Martin Gräßlin <kde@martin-graesslin.com>
|
||
|
* @since 4.4
|
||
|
*/
|
||
|
|
||
|
class QModelIndex;
|
||
|
namespace Plasma
|
||
|
{
|
||
|
class FrameSvg;
|
||
|
}
|
||
|
|
||
|
namespace KWin
|
||
|
{
|
||
|
namespace TabBox
|
||
|
{
|
||
|
class DesktopItemDelegate;
|
||
|
class DesktopModel;
|
||
|
|
||
|
class ClientModel;
|
||
|
class ClientItemDelegate;
|
||
|
|
||
|
class TabBoxMainView;
|
||
|
class TabBoxAdditionalView;
|
||
|
|
||
|
/**
|
||
|
* This class is the main view of the TabBox. It is made up of two widgets:
|
||
|
* TabBoxMainView which is the "switching area" for TabBox items and
|
||
|
* TabBoxInfoView which is an optional second list view only displaying the
|
||
|
* current selected item.
|
||
|
*
|
||
|
* @author Martin Gräßlin <kde@martin-graesslin.com>
|
||
|
* @since 4.4
|
||
|
*/
|
||
|
class TabBoxView : public QWidget
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
TabBoxView( QWidget* parent = 0 );
|
||
|
~TabBoxView();
|
||
|
virtual void paintEvent( QPaintEvent* e );
|
||
|
virtual QSize sizeHint() const;
|
||
|
void updateGeometry();
|
||
|
|
||
|
/**
|
||
|
* Sets the current index in the two views.
|
||
|
* @param index The new index
|
||
|
*/
|
||
|
void setCurrentIndex( QModelIndex index );
|
||
|
/**
|
||
|
* Returns the index at the given position of the main view widget.
|
||
|
* @param pos The widget position
|
||
|
* @return The model index at given position. If there is no item
|
||
|
* at the position or the position is not in the main widget an
|
||
|
* invalid item will be returned.
|
||
|
*/
|
||
|
QModelIndex indexAt( QPoint pos );
|
||
|
|
||
|
/**
|
||
|
* @return The ClientModel used by TabBox.
|
||
|
*/
|
||
|
ClientModel* clientModel() const { return m_clientModel; }
|
||
|
/**
|
||
|
* @return The DesktopModel used by TabBox.
|
||
|
*/
|
||
|
DesktopModel* desktopModel() { return m_desktopModel; }
|
||
|
ClientItemDelegate* clientDelegate() const { return m_delegate; }
|
||
|
ClientItemDelegate* additionalClientDelegate() const { return m_additionalClientDelegate; }
|
||
|
DesktopItemDelegate* desktopDelegate() const { return m_desktopItemDelegate; }
|
||
|
DesktopItemDelegate* additionalDesktopDelegate() const { return m_additionalDesktopDelegate; }
|
||
|
|
||
|
void setPreview( bool preview );
|
||
|
bool preview() const { return m_preview; }
|
||
|
|
||
|
private slots:
|
||
|
/**
|
||
|
* This slot reacts on a changed TabBoxConfig. It changes the used
|
||
|
* item model and delegate if the TabBoxMode changed.
|
||
|
*/
|
||
|
void configChanged();
|
||
|
|
||
|
private:
|
||
|
/**
|
||
|
* The main widget used to show all items
|
||
|
*/
|
||
|
TabBoxMainView* m_tableView;
|
||
|
TabBoxAdditionalView* m_additionalView;
|
||
|
/**
|
||
|
* Model for client items
|
||
|
*/
|
||
|
ClientModel* m_clientModel;
|
||
|
/**
|
||
|
* Model for desktop items
|
||
|
*/
|
||
|
DesktopModel* m_desktopModel;
|
||
|
/**
|
||
|
* Item delegate for client items
|
||
|
*/
|
||
|
ClientItemDelegate* m_delegate;
|
||
|
ClientItemDelegate* m_additionalClientDelegate;
|
||
|
/**
|
||
|
* Item delegate for desktop items
|
||
|
*/
|
||
|
DesktopItemDelegate* m_desktopItemDelegate;
|
||
|
DesktopItemDelegate* m_additionalDesktopDelegate;
|
||
|
/**
|
||
|
* Background Frame
|
||
|
*/
|
||
|
Plasma::FrameSvg* m_frame;
|
||
|
/**
|
||
|
* TabBoxView is a preview
|
||
|
*/
|
||
|
bool m_preview;
|
||
|
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* This class is the main widget of the TabBoxView.
|
||
|
* It is the "switching area" for TabBox items.
|
||
|
*
|
||
|
* @author Martin Gräßlin <kde@martin-graesslin.com>
|
||
|
* @since 4.4
|
||
|
*/
|
||
|
class TabBoxMainView : public QTableView
|
||
|
{
|
||
|
public:
|
||
|
TabBoxMainView( QWidget* parent = 0 );
|
||
|
~TabBoxMainView();
|
||
|
|
||
|
virtual QSize sizeHint() const;
|
||
|
};
|
||
|
/**
|
||
|
* This class is the additional widget of the TabBoxView.
|
||
|
* It just displays the current item and can be turned off.
|
||
|
*
|
||
|
* @author Martin Gräßlin <kde@martin-graesslin.com>
|
||
|
* @since 4.4
|
||
|
*/
|
||
|
class TabBoxAdditionalView : public QTableView
|
||
|
{
|
||
|
public:
|
||
|
TabBoxAdditionalView( QWidget* parent = 0 );
|
||
|
~TabBoxAdditionalView();
|
||
|
|
||
|
virtual QSize sizeHint() const;
|
||
|
};
|
||
|
|
||
|
} // namespace Tabbox
|
||
|
} // namespace KWin
|
||
|
|
||
|
#endif // TABBOXVIEW_H
|