1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 16:31:58 +02:00

Add ViewPageLazyLoader template

This commit is contained in:
Dominik Schmidt 2013-08-02 13:23:10 +02:00
parent d18e34771b
commit be2af20ed0
3 changed files with 78 additions and 0 deletions

@ -18,6 +18,7 @@ set( libGuiSources
DropJob.cpp
GlobalActionManager.cpp
ViewPage.cpp
ViewPageLazyLoader.cpp
ViewPagePlugin.cpp
ViewManager.cpp
LatchManager.cpp

@ -0,0 +1,19 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ViewPageLazyLoader.h"

@ -0,0 +1,58 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VIEWPAGELAZYLOADER_H
#define VIEWPAGELAZYLOADER_H
#include "ViewPagePlugin.h"
#include "DllMacro.h"
namespace Tomahawk
{
template <class T>
class ViewPageLazyLoader : public ViewPagePlugin
{
public:
ViewPageLazyLoader<T>()
: m_widget( 0 )
{
}
virtual ~ViewPageLazyLoader()
{
delete m_widget;
}
virtual T* widget()
{
if( !m_widget )
m_widget = new T();
return m_widget;
}
protected:
T* m_widget;
};
} // ns
#endif //VIEWPAGELAZYLOADER_H