Merge branch 'master' into fx-mixer-rework

This commit is contained in:
Tobias Doerffel
2009-11-26 01:47:38 +01:00
304 changed files with 28806 additions and 15914 deletions

View File

@@ -30,7 +30,8 @@
#ifdef LMMS_HAVE_ALSA
#include <alsa/asoundlib.h>
#include "QAbstractListModel"
#include <QAbstractListModel>
#include <QPair>
class AlsaDeviceListModel : public QAbstractListModel

View File

@@ -79,6 +79,7 @@ private:
virtual void applyQualitySettings();
virtual void run();
volatile bool m_quit;
bool m_convertEndian;

View File

@@ -0,0 +1,46 @@
/*
* DirectorySelectDialog.h - header file for DirectorySelectDialog
*
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _DIRECTORY_SELECT_DIALOG_H
#define _DIRECTORY_SELECT_DIALOG_H
#include "ResourceSelectDialog.h"
namespace Ui { class DirectorySelectDialog; }
class DirectorySelectDialog : public ResourceSelectDialog
{
public:
DirectorySelectDialog( QWidget * _parent,
DatabaseScope _databaseScope = AllResources );
~DirectorySelectDialog();
private:
Ui::DirectorySelectDialog * ui;
} ;
#endif

View File

@@ -69,8 +69,6 @@ public:
return m_toolBar;
}
// show MainWidget or WelcomeScreen
void setMainWidgetVisible( bool _visible );
//int addWidgetToToolBar( QWidget * _w, int _row = -1, int _col = -1 );
//void addSpacingToToolBar( int _size );
@@ -109,6 +107,7 @@ public:
void setPlaybackMode( ProjectPlaybackMode _playbackMode );
void showWelcomeScreen(bool _visible = true);
public slots:
void resetWindowTitle();
@@ -126,6 +125,7 @@ public slots:
bool saveProject();
bool saveProjectAs();
void showSettingsDialog();
void showPreferencesDialog();
void aboutLMMS();
void help();
void toggleAutomationEditorWin();
@@ -145,6 +145,7 @@ public slots:
protected:
virtual void closeEvent( QCloseEvent * _ce );
virtual void showEvent( QShowEvent * _se );
virtual void focusOutEvent( QFocusEvent * _fe );
virtual void keyPressEvent( QKeyEvent * _ke );
virtual void keyReleaseEvent( QKeyEvent * _ke );

View File

@@ -0,0 +1,43 @@
/*
* PreferencesDialog.h - declaration of class PreferencesDialog
*
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _PREFERENCES_DIALOG_H
#define _PREFERENCES_DIALOG_H
#include <QtGui/QDialog>
namespace Ui { class PreferencesDialog; }
class PreferencesDialog : public QDialog
{
public:
PreferencesDialog();
private:
Ui::PreferencesDialog * ui;
} ;
#endif

View File

@@ -25,29 +25,22 @@
#ifndef _QUICK_LOAD_DIALOG_H
#define _QUICK_LOAD_DIALOG_H
#include <QtGui/QDialog>
#include "ResourceItem.h"
#include "ResourceSelectDialog.h"
namespace Ui { class QuickLoadDialog; }
class ResourceListModel;
class QuickLoadDialog : public QDialog
class QuickLoadDialog : public ResourceSelectDialog
{
Q_OBJECT
public:
QuickLoadDialog( QWidget * _parent, ResourceItem::Type _typeFilter =
ResourceItem::TypeUnknown );
ResourceItem::TypeUnknown,
DatabaseScope _databaseScope = AllResources );
virtual ~QuickLoadDialog();
private slots:
void setTypeFilter( int );
private:
Ui::QuickLoadDialog * ui;
ResourceListModel * m_listModel;
} ;

View File

@@ -30,35 +30,60 @@ class trackContainer;
class ResourceItem;
/*! \brief The ResourceAction class provides centralized functionality for all actions
* related to a ResourceItem.
*
* These actions are for example loading projects, samples, presets,
* plugin-specific presets etc. Using this class we can avoid duplicated
* functionality in ResourcePreviewer, ResourceBrowser, TrackContainerView,
* InstrumentTrack & Co.
*/
class ResourceAction
{
public:
/*! Lists all supported actions. */
enum Actions
{
EditProperties,
LoadProject,
LoadInNewTrackSongEditor,
LoadInNewTrackBBEditor,
LoadInActiveInstrumentTrack,
DownloadIntoCollection,
UploadToWWW,
DeleteLocalResource,
ImportFile,
EditProperties, /*!< Open a dialog to edit properties of the ResourceItem */
LoadProject, /*!< Load the project represented by the ResourceItem */
LoadInNewTrackSongEditor, /*!< Load preset, sample etc. in a new track in Song Editor */
LoadInNewTrackBBEditor, /*!< Load preset, sample etc. in a new track in BB Editor */
LoadInActiveInstrumentTrack,/*!< Load preset, sample etc. in active instrument track */
DownloadIntoCollection, /*!< Download the resource into local collection */
UploadToWWW, /*!< Upload the resource to Web */
DeleteLocalResource, /*!< Delete local resource (=file) */
ImportFile, /*!< Try to import the resource via import filter plugins */
NumActions
} ;
typedef Actions Action;
ResourceAction( const ResourceItem * _item,
Action _action = NumActions ) :
m_action( _action ),
m_item( _item )
/*! \brief Constructs a ResourceAction object.
* \param item The ResourceItem the action is about
* \param action An optional action from the Action enumeration used for the defaultTrigger() method
*/
ResourceAction( const ResourceItem * item,
Action action = NumActions ) :
m_action( action ),
m_item( item )
{
}
bool loadProject();
bool loadByPlugin( InstrumentTrack * _target );
bool loadPreset( InstrumentTrack * _target );
bool importProject( trackContainer * _target );
bool loadByPlugin( InstrumentTrack * target );
bool loadPreset( InstrumentTrack * target );
bool importProject( trackContainer * target );
/*! \brief Triggers the action passed to the constructor without any further options.
*
* Most actions can be triggered without any further information.
* This allows simple but powerful code constructs:
* \code
* ResourceAction( myItem, ResourceAction::LoadProject ).defaultTrigger();
* \endcode
* \return true if the operation succeeded, otherwise false.
*/
bool defaultTrigger();
private:

View File

@@ -26,9 +26,10 @@
#ifndef _RESOURCE_BROWSER_H
#define _RESOURCE_BROWSER_H
#include "ResourceAction.h"
#include "ResourcePreviewer.h"
#include "ResourceTreeModel.h"
#include "side_bar_widget.h"
#include "SideBarWidget.h"
class QAction;
class QLabel;
@@ -36,24 +37,10 @@ class ResourceItem;
class ResourceTreeView;
class ResourceBrowser : public sideBarWidget
class ResourceBrowser : public SideBarWidget
{
Q_OBJECT
public:
enum Actions
{
EditProperties,
LoadProject,
LoadInNewTrackSongEditor,
LoadInNewTrackBBEditor,
LoadInActiveInstrumentTrack,
DownloadIntoCollection,
UploadToWWW,
DeleteLocalResource,
ImportFile,
NumActions
} ;
ResourceBrowser( QWidget * _parent );
virtual ~ResourceBrowser();
@@ -72,9 +59,9 @@ private slots:
private:
void triggerAction( Actions _action, ResourceItem * _item );
void triggerAction( ResourceAction::Action _action, ResourceItem * _item );
QAction * m_actions[NumActions];
QAction * m_actions[ResourceAction::NumActions];
// the object that will preview individual resources
ResourcePreviewer m_previewer;

View File

@@ -34,20 +34,45 @@
#include "ResourceItem.h"
/*! \brief The ResourceDB class organizes and caches ResourceItems.
*
* ResourceItem sets are organized in the ResourceDB::ItemHashMap. This
* allows fast lookup of ResourceItems by hash string. ResourceItems are added
* and removed by a ResourceProvider.
*
* The ResourceItem array can be cached to a file and restored later. This is
* essential as otherwise e.g. the LocalResourceProvider would have to re-read
* all directories and files and recompute hash strings based on file contents.
*
* One can also descend the hierarchical ResourceItem tree by starting from
* ResourceDB::topLevelNode().
*/
class EXPORT ResourceDB : public QObject
{
Q_OBJECT
public:
/*! A QHash instantiation used for storing ResourceItems and allow lookup
* by hash string */
typedef QHash<QString, ResourceItem *> ItemHashMap;
ResourceDB( ResourceProvider * _provider );
/*! \brief Constructs a ResourceDB object.
* \param provider The ResourceProvider that will manage ResourceItems in this DB
*/
ResourceDB( ResourceProvider * provider );
~ResourceDB();
/*! \brief Initializes ResourceDB object, i.e. restore cache and update itself via the ResourceProvider. */
void init();
void load( const QString & _file );
void save( const QString & _file );
/*! \brief Dumps all ResourceItems with their relations to a file.
* \param file The filename to save data to */
void load( const QString & file );
/*! \brief Restores ResourceItems with their relations from a file.
* \param file The filename to load data from */
void save( const QString & file );
inline ResourceProvider * provider()
{
@@ -69,21 +94,31 @@ public:
return &m_topLevelNode;
}
// similiar to items()[_hash] but faster and returns NULL if not found
const ResourceItem * itemByHash( const QString & _hash ) const;
/*! \brief Looks up a ResourceItem by hash string - similiar to items()[hash]
* but faster and returns NULL if not found.
* \param hash The hash string that is searched for
* \return A const pointer to the matching ResourceItem */
const ResourceItem * itemByHash( const QString & hash ) const;
// return a list of ResourceItems who somehow match the given keywords
ResourceItemList matchItems( const QStringList & _keyWords );
/*! \brief Return a list of ResourceItems which somehow match the given keywords.
* \param keywords A list of keywords that are searched for
* \return A ResourceItemList which the result */
ResourceItemList matchItems( const QStringList & keywords );
// return an item which matches a resource desceibed in _item as
// good as possible
const ResourceItem * nearestMatch( const ResourceItem & _item );
/*! \brief Returns a ResourceItem which matches a given ResourceItem best.
* \param item A ResourceItem to search the best match for
* \return A const pointer to the best marching ResourceItem in the DB */
const ResourceItem * nearestMatch( const ResourceItem & item );
// add given item to DB
void addItem( ResourceItem * _newItem );
/*! \brief Adds given ResourceItem to DB.
* \param newItem The ResourceItem to be added */
void addItem( ResourceItem * newItem );
void recursiveRemoveItems( ResourceItem::Relation * parent,
bool removeTopLevelParent = true );
/*! \brief Remove items recursively starting from a certain ResourceItem::Relation
* \param parent The parent relation to start from with removing
* \param removeParent A boolean which specifies whether to also remove the parent item */
void removeItemsRecursively( ResourceItem::Relation * parent,
bool removeParent = true );
private:
@@ -140,9 +175,12 @@ private:
signals:
/*! \brief Forwarded signal of ResourceProvider::itemsChanged() */
void itemsChanged();
void directoryItemAdded( const QString & _path );
void directoryItemRemoved( const QString & _path );
/*! \brief Emitted whenever a ResourceItem of type ResourceItem::TypeDirectory is added */
void directoryItemAdded( const QString & path );
/*! \brief Emitted whenever a ResourceItem of type ResourceItem::TypeDirectory is removed */
void directoryItemRemoved( const QString & path );
} ;

View File

@@ -35,59 +35,96 @@
#include "TreeRelation.h"
/*! \brief The ResourceItem class provides information about a local/remote file/directory.
*
* All relevant properties of a file or directory are stored within a
* ResourceItem and can be accessed easily. All resources are identified by
* a unique hash (based on file content or (absolute) directory name).
*
* ResourceItems are managed within a ResourceDB. Reading and writing resource
* data is abstracted into the ResourceProvider class.
*
* The ResourceItem class does not provide any actual functionality.
* Use ResourceAction or more high level classes like ResourcePreviewer and
* ResourceBrowser.
*/
class EXPORT ResourceItem
{
public:
/*! A relation specifies how ResourceItems are organized among each other.
* See documentation of TreeRelation for details. */
typedef TreeRelation<ResourceItem> Relation;
/*! Lists all supported base directories for ResourceItems. */
enum BaseDirectories
{
BaseRoot,
BaseWorkingDir,
BaseDataDir,
BaseHome,
BaseURL,
BaseRoot, /*!< Item is relative to root directory */
BaseWorkingDir, /*!< Item is relative to working directory */
BaseDataDir, /*!< Item is relative to LMMS' data directory */
BaseHome, /*!< Item is relative to user's home directory */
BaseURL, /*!< Item is relative to the URL of the ResourceProvider */
NumBaseDirectories
} ;
typedef BaseDirectories BaseDirectory;
/*! Lists all supported ResourceItem types. */
enum Types
{
TypeUnknown,
TypeDirectory,
TypeSample,
TypePreset,
TypePluginSpecificResource,
TypeProject,
TypeMidiFile,
TypeForeignProject,
TypePlugin,
TypeImage,
TypeUnknown, /*!< No known resource type */
TypeDirectory, /*!< Item is a directory */
TypeSample, /*!< Item is a supported sample file */
TypePreset, /*!< Item is a LMMS-specific preset */
TypePluginSpecificResource, /* Item is a file supported by one of the available plugins */
TypeProject, /*!< Item is a LMMS project */
TypeMidiFile, /*!< Item is a MIDI file (and can be imported via MIDI import filter) */
TypeForeignProject, /*!< Item is any other kind of project which can be imported via an ImportFilter plugin */
TypePlugin, /*!< Item is a Plugin binary */
TypeImage, /*!< Item is an image */
NumTypes
} ;
typedef Types Type;
ResourceItem( ResourceProvider * _provider,
const QString & _name,
/*! \brief Constructs a ResourceItem object.
* \param provider The provider this item belongs to
* \param name The name used to identify the item towards the user
* \param baseDir The base directory this item is relative to
* \param path The path from base directory to this item
* \param hash A unique hash based on file content, pass QString::null to compute it automatically
* \param author A string describing the author
* \param tags A comma-separated list of tags for this item
* \param size The size of the item, pass -1 to compute it automatically
* \param lastMod The date and time of the last modification of the item
*/
ResourceItem( ResourceProvider * provider,
const QString & name,
Type _type,
BaseDirectory _base_dir = BaseWorkingDir,
const QString & _path = QString::null,
const QString & _hash = QString::null,
const QString & _author = QString::null,
const QString & _tags = QString::null,
int _size = -1,
const QDateTime & _last_mod = QDateTime() );
// copy constructor
ResourceItem( const ResourceItem & _item );
BaseDirectory baseDir = BaseWorkingDir,
const QString & path = QString::null,
const QString & hash = QString::null,
const QString & author = QString::null,
const QString & tags = QString::null,
int size = -1,
const QDateTime & lastMod = QDateTime() );
/*! \brief Copy constructor. */
ResourceItem( const ResourceItem & item );
inline void setHidden( bool _h, const QAbstractItemModel * _model )
/*! \brief Sets hidden property for the given item model
* \param hidden A boolean specifying the desired value
* \param model A pointer to a QAbstractItemModel (allows to use this item
* for multiple models and views) */
inline void setHidden( bool hidden, const QAbstractItemModel * model )
{
m_hidden[_model] = _h;
m_hidden[model] = hidden;
}
inline bool isHidden( const QAbstractItemModel * _model ) const
/*! \brief Returns whether item is hidden for the given item model
* \param model A pointer to a QAbstractItemModel (allows to use this item
* for multiple models and views)
* \return true if the item is hidden, false otherwise */
inline bool isHidden( const QAbstractItemModel * model ) const
{
return m_hidden[_model];
return m_hidden[model];
}
@@ -206,6 +243,8 @@ public:
return m_provider->dataSize( this );
}
/*! \brief Fetch data (contents) of the resource via ResourceProvider.
* \return QByteArray with complete contents of the resource */
QByteArray fetchData( int _maxSize = -1 ) const
{
return m_provider->fetchData( this );
@@ -213,15 +252,19 @@ public:
void reload();
// returns true if all given keywords match name, tags etc.
/*! \brief Returns, whether keywords match certain properties.
* \return true if all given keywords match name, tags etc. */
bool keywordMatch( const QStringList & _keywords ) const;
// return true, if given ResourceItem is equal
/*! \brief Tests for equality with another ResourceItem.
* \return true, if given ResourceItem is equal */
bool operator==( const ResourceItem & _other ) const;
// rates equality with given item
/*! \brief Rates equality with another ResourceItem.
* \return An integer specifying how close the two ResourceItems are (between 0 and about 250) */
int equalityLevel( const ResourceItem & _other ) const;
/*! \brief Guesses resource type by various criteria */
Type guessType() const;
static const char * mimeKey()

View File

@@ -56,7 +56,7 @@ public:
// used for drag'n'drop - return proper MIME data for indexes
virtual QMimeData * mimeData( const QModelIndexList & _indexes ) const;
// return ResourceTreeItem belonging to a certain index
// return ResourceItem::Relation belonging to a certain index
static inline ResourceItem::Relation * relation( const QModelIndex & _idx )
{
return static_cast<ResourceItem::Relation *>( _idx.internalPointer() );

View File

@@ -0,0 +1,73 @@
/*
* ResourceSelectDialog.h - header file for ResourceSelectDialog
*
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _RESOURCE_SELECT_DIALOG_H
#define _RESOURCE_SELECT_DIALOG_H
#include <QtGui/QDialog>
class ResourceItem;
class ResourceModel;
class ResourceSelectDialog : public QDialog
{
Q_OBJECT
public:
enum ModelTypes
{
ListModel,
TreeModel
} ;
enum DatabaseScope
{
WorkingDirResources,
WebResources,
AllResources
} ;
ResourceSelectDialog( QWidget * _parent, ModelTypes _modelType,
DatabaseScope _databaseScope = AllResources );
virtual ~ResourceSelectDialog();
// returns the selected item (NULL if the dialog was not accepted or no
// valid item was selected)
ResourceItem * selectedItem();
protected:
void setupUi();
private slots:
void setTypeFilter( int );
private:
ResourceModel * m_model;
} ;
#endif

View File

@@ -34,7 +34,10 @@ class ResourceTreeView : public QTreeView
{
Q_OBJECT
public:
ResourceTreeView( ResourceTreeModel * _tm, QWidget * _parent );
ResourceTreeView( QWidget * _parent, ResourceTreeModel * _tm = NULL );
virtual ~ResourceTreeView();
virtual void setModel( QAbstractItemModel * _model );
public slots:
@@ -51,7 +54,7 @@ protected:
private:
ResourceTreeModel * m_tm;
ResourceTreeModel * m_treeModel;
QString m_lastFilter;

57
include/SideBar.h Normal file
View File

@@ -0,0 +1,57 @@
/*
* SideBar.h - side-bar in LMMS' MainWindow
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _SIDE_BAR_H
#define _SIDE_BAR_H
#include <QtCore/QMap>
#include <QtGui/QButtonGroup>
#include <QtGui/QToolBar>
class QToolButton;
class SideBarWidget;
class SideBar : public QToolBar
{
Q_OBJECT
public:
SideBar( Qt::Orientation _orientation, QWidget * _parent );
virtual ~SideBar();
void appendTab( SideBarWidget * _sbw );
private slots:
void toggleButton( QAbstractButton * _btn );
private:
QButtonGroup m_btnGroup;
typedef QMap<QToolButton *, QWidget *> ButtonMap;
ButtonMap m_widgets;
} ;
#endif

View File

@@ -1,8 +1,8 @@
/*
* side_bar_widget.h - base-class for all side-bar-widgets
* SideBarWidget.h - base-class for all side-bar-widgets
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
*
*/
#ifndef _SIDE_BAR_WIDGET_H
#define _SIDE_BAR_WIDGET_H
@@ -31,41 +30,42 @@
#include <QtGui/QWidget>
class sideBarWidget : public QWidget
class SideBarWidget : public QWidget
{
Q_OBJECT
public:
sideBarWidget( const QString & _title, const QPixmap & _icon,
SideBarWidget( const QString & _title, const QPixmap & _icon,
QWidget * _parent );
virtual ~sideBarWidget();
virtual ~SideBarWidget();
inline const QPixmap & icon() const
{
return( m_icon );
return m_icon;
}
inline const QString & title() const
{
return( m_title );
return m_title;
}
protected:
virtual void paintEvent( QPaintEvent * _pe );
virtual void resizeEvent( QResizeEvent * _re );
inline virtual void contextMenuEvent( QContextMenuEvent * )
virtual void contextMenuEvent( QContextMenuEvent * )
{
}
inline QWidget * contentParent()
QWidget * contentParent()
{
return( m_contents );
}
inline void addContentWidget( QWidget * _w )
void addContentWidget( QWidget * _w )
{
m_layout->addWidget( _w );
}
inline void addContentLayout( QLayout * _l )
void addContentLayout( QLayout * _l )
{
m_layout->addLayout( _l );
}
@@ -79,5 +79,4 @@ private:
} ;
#endif

View File

@@ -53,7 +53,7 @@ private slots:
private:
void switchView();
void hideWelcomeScreen();
Ui::WelcomeScreen * ui;
RecentResourceListModel * m_recentProjectsModel;

View File

@@ -1,309 +0,0 @@
/***************************************************************************
kmultitabbar.h - description
-------------------
begin : 2001
copyright : (C) 2001,2002,2003 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
/***************************************************************************
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
***************************************************************************/
#ifndef _KMultitabbar_h_
#define _KMultitabbar_h_
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtGui/QLayout>
#include <QtGui/QPushButton>
class QPixmap;
class QPainter;
class QFrame;
class QMenu;
class KMultiTabBarPrivate;
class KMultiTabBarTabPrivate;
class KMultiTabBarButtonPrivate;
class KMultiTabBarInternal;
/**
* A Widget for horizontal and vertical tabs.
* It is possible to add normal buttons to the top/left
* The handling if only one tab at a time or multiple tabs
* should be raisable is left to the "user".
*@author Joseph Wenninger
*/
class KMultiTabBar: public QWidget
{
Q_OBJECT
public:
enum KMultiTabBarMode{Horizontal, Vertical};
enum KMultiTabBarPosition{Left, Right, Top, Bottom};
/**
* The list of available styles for KMultiTabBar
* - VSNET - Visual Studio .Net like (only show the text of active tabs
* - KDEV3 - Kdevelop 3 like (always show the text)
* - KONQSBC - konqy's classic sidebar style (unthemed) (currently disabled)
*/
enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff};
KMultiTabBar(KMultiTabBarMode bm,QWidget *parent=0 );
virtual ~KMultiTabBar();
/**
* append a new button to the button area. The button can later on be accessed with button(ID)
* eg for connecting signals to it
* @param pic a pixmap for the button
* @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button
* if more than one button is connected to a signals.
* @param popup A popup menu which should be displayed if the button is clicked
* @param not_used_yet will be used for a popup text in the future
*/
int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString());
/**
* remove a button with the given ID
*/
void removeButton(int id);
/**
* append a new tab to the tab area. It can be accessed lateron with tabb(id);
* @param pic a bitmap for the tab
* @param id an arbitrary ID which can be used later on to identify the tab
* @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint
*/
int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString());
/**
* remove a tab with a given ID
*/
void removeTab(int id);
/**
* set a tab to "raised"
* @param id The ID of the tab to manipulate
* @param state true == activated/raised, false == not active
*/
void setTab(int id ,bool state);
/**
* return the state of a tab, identified by it's ID
*/
bool isTabRaised(int id) const;
/**
* get a pointer to a button within the button area identified by its ID
*/
class KMultiTabBarButton *button(int id) const;
/**
* get a pointer to a tab within the tab area, identiifed by its ID
*/
class KMultiTabBarTab *tab(int id) const;
/**
* set the real position of the widget.
* @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right
*/
void setPosition(KMultiTabBarPosition pos);
/**
* get the tabbar position.
* @return position
*/
KMultiTabBarPosition position() const;
/**
* set the display style of the tabs
*/
void setStyle(KMultiTabBarStyle style);
/**
* get the display style of the tabs
* @return display style
*/
KMultiTabBarStyle tabStyle() const;
/**
* be carefull, don't delete tabs yourself and don't delete the list itself
*/
QList<KMultiTabBarTab *>* tabs();
/**
* be carefull, don't delete buttons yourself and don't delete the list itself
*/
QList<KMultiTabBarButton *>* buttons();
/**
* might vanish, not sure yet
*/
void showActiveTabTexts(bool show=true);
protected:
friend class KMultiTabBarButton;
virtual void fontChange( const QFont& );
void updateSeparator();
private:
class KMultiTabBarInternal *m_internal;
QBoxLayout *m_l;
QFrame *m_btnTabSep;
QList<KMultiTabBarButton *> m_buttons;
KMultiTabBarPosition m_position;
KMultiTabBarPrivate *d;
};
/**
* This class should never be created except with the appendButton call of KMultiTabBar
*/
class KMultiTabBarButton: public QPushButton
{
Q_OBJECT
public:
KMultiTabBarButton(const QPixmap& pic,const QString&, QMenu *popup,
int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
KMultiTabBarButton(const QString&, QMenu *popup,
int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style);
virtual ~KMultiTabBarButton();
int id() const;
public slots:
/**
* this is used internaly, but can be used by the user, if (s)he wants to
* It the according call of KMultiTabBar is invoked though this modifications will be overwritten
*/
void setPosition(KMultiTabBar::KMultiTabBarPosition);
/**
* this is used internaly, but can be used by the user, if (s)he wants to
* It the according call of KMultiTabBar is invoked though this modifications will be overwritten
*/
void setStyle(KMultiTabBar::KMultiTabBarStyle);
/**
* modify the text of the button
*/
void setText(const QString &);
QSize sizeHint() const;
protected:
KMultiTabBar::KMultiTabBarPosition m_position;
KMultiTabBar::KMultiTabBarStyle m_style;
QString m_text;
virtual void hideEvent( class QHideEvent*);
virtual void showEvent( class QShowEvent*);
private:
int m_id;
KMultiTabBarButtonPrivate *d;
signals:
/**
* this is emitted if the button is clicked
* @param id the ID identifying the button
*/
void clicked(int id);
protected slots:
virtual void slotClicked();
};
/**
* This class should never be created except with the appendTab call of KMultiTabBar
*/
class KMultiTabBarTab: public KMultiTabBarButton
{
Q_OBJECT
public:
KMultiTabBarTab(const QPixmap& pic,const QString&,int id,QWidget *parent,
KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style);
virtual ~KMultiTabBarTab();
/**
* set the active state of the tab
* @param state true==active false==not active
*/
void setState(bool state);
/**
* choose if the text should always be displayed
* this is only used in classic mode if at all
*/
void showActiveTabText(bool show);
void resize(){ setSize( neededSize() ); }
private:
bool m_showActiveTabText;
int m_expandedSize;
KMultiTabBarTabPrivate *d;
protected:
friend class KMultiTabBarInternal;
void setSize(int);
int neededSize();
void updateState();
virtual void paintEvent(QPaintEvent *);
virtual void drawButton(QPainter *);
virtual void drawButtonLabel(QPainter *);
void drawButtonStyled(QPainter *);
void drawButtonClassic(QPainter *);
protected slots:
virtual void slotClicked();
void setTabsPosition(KMultiTabBar::KMultiTabBarPosition);
public slots:
virtual void setIcon(const QString&);
virtual void setIcon(const QPixmap&);
};
/***************************************************************************
kmultitabbar_p.h - description
-------------------
begin : 2003
copyright : (C) 2003 by Joseph Wenninger <jowenn@kde.org>
***************************************************************************/
/***************************************************************************
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
***************************************************************************/
class KMultiTabBarInternal: public QWidget
{
Q_OBJECT
public:
KMultiTabBarInternal(QWidget *parent,KMultiTabBar::KMultiTabBarMode bm);
int appendTab(const QPixmap &,int=-1,const QString& =QString());
KMultiTabBarTab *tab(int) const;
void removeTab(int);
void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos);
void setStyle(enum KMultiTabBar::KMultiTabBarStyle style);
void showActiveTabTexts(bool show);
QList<KMultiTabBarTab *>* tabs(){return &m_tabs;}
private:
friend class KMultiTabBar;
QWidget *box;
QBoxLayout *mainLayout;
QList<KMultiTabBarTab *> m_tabs;
enum KMultiTabBar::KMultiTabBarPosition m_position;
bool m_showActiveTabTexts;
enum KMultiTabBar::KMultiTabBarStyle m_style;
int m_expandedTabSize;
int m_lines;
KMultiTabBar::KMultiTabBarMode m_barMode;
protected:
virtual bool eventFilter(QObject *,QEvent*);
// virtual void paintEvent( QPaintEvent * );
virtual void resizeEvent(QResizeEvent *);
};
#endif

View File

@@ -28,14 +28,14 @@
#include <QtCore/QTimer>
#include <QtGui/QPixmap>
#include "side_bar_widget.h"
#include "SideBarWidget.h"
#include "Plugin.h"
class trackContainer;
class pluginBrowser : public sideBarWidget
class pluginBrowser : public SideBarWidget
{
Q_OBJECT
public:

View File

@@ -1,97 +0,0 @@
/*
* side_bar.h - code for side-bar in LMMS
*
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _SIDE_BAR_H
#define _SIDE_BAR_H
#include <QtCore/QMap>
#include "kmultitabbar.h"
#include "side_bar_widget.h"
class sideBar : public KMultiTabBar
{
Q_OBJECT
public:
sideBar( KMultiTabBarMode _m, QWidget * _parent ) :
KMultiTabBar( _m, _parent )
{
}
virtual ~sideBar()
{
}
inline int appendTab( sideBarWidget * _sbw, int _id )
{
int ret = KMultiTabBar::appendTab( _sbw->icon(), _id,
_sbw->title() );
m_widgets[_id] = _sbw;
_sbw->hide();
_sbw->setMinimumWidth( 200 );
connect( tab( _id ), SIGNAL( clicked( int ) ), this,
SLOT( tabClicked( int ) ) );
return( ret );
}
private slots:
inline void tabClicked( int _id )
{
// disable all other tabbar-buttons
QMap<int, QWidget *>::Iterator it;
for( it = m_widgets.begin(); it != m_widgets.end(); ++it )
{
if( it.key() != _id/* && isTabRaised(it.key()) == true*/ )
{
setTab( it.key(), false );
}
if( m_widgets[it.key()] != NULL )
{
m_widgets[it.key()]->hide();
}
}
if( m_widgets[_id] != NULL )
{
if( isTabRaised( _id ) )
{
m_widgets[_id]->show();
}
else
{
m_widgets[_id]->hide();
}
}
}
private:
QMap<int, QWidget *> m_widgets;
} ;
#endif