Commit 562654bd authored by Michael Pyne's avatar Michael Pyne

Port away from Q3WidgetStack. Not precisely sure why I bothered since I...

Port away from Q3WidgetStack.  Not precisely sure why I bothered since I figure the Great Move to Interview
will fix all this (and is necessary to completely get rid of qt3support anyways....)

svn path=/trunk/KDE/kdemultimedia/juk/; revision=913901
parent 633a873b
......@@ -55,7 +55,7 @@
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QPixmap>
#include <Q3WidgetStack>
#include <QStackedWidget>
#include <id3v1genres.h>
#include <time.h>
......
......@@ -61,7 +61,7 @@ using namespace ActionCollection;
// PlaylistBox public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistBox::PlaylistBox(QWidget *parent, Q3WidgetStack *playlistStack) :
PlaylistBox::PlaylistBox(QWidget *parent, QStackedWidget *playlistStack) :
K3ListView(parent),
PlaylistCollection(playlistStack),
m_viewModeIndex(0),
......
......@@ -48,7 +48,7 @@ public:
friend class Item;
PlaylistBox(QWidget *parent, Q3WidgetStack *playlistStack);
PlaylistBox(QWidget *parent, QStackedWidget *playlistStack);
virtual ~PlaylistBox();
virtual void raise(Playlist *playlist);
......
/***************************************************************************
copyright : (C) 2004 by Scott Wheeler
email : wheeler@kde.org
copyright : (C) 2009 by Michael Pyne
email : michael.pyne@kdemail.net
***************************************************************************/
/***************************************************************************
......@@ -16,7 +19,6 @@
#include <kurl.h>
#include <kicon.h>
#include <khbox.h>
#include <kiconloader.h>
#include <kapplication.h>
#include <kinputdialog.h>
......@@ -33,7 +35,7 @@
#include <QObject>
#include <QPixmap>
#include <Q3WidgetStack>
#include <QStackedWidget>
#include <sys/types.h>
#include <dirent.h>
......@@ -55,8 +57,6 @@
//Laurent: readd it
//#include "collectionadaptor.h"
#define widget (kapp->mainWidget())
using namespace ActionCollection;
////////////////////////////////////////////////////////////////////////////////
......@@ -69,7 +69,7 @@ PlaylistCollection *PlaylistCollection::m_instance = 0;
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistCollection::PlaylistCollection(Q3WidgetStack *playlistStack) :
PlaylistCollection::PlaylistCollection(QStackedWidget *playlistStack) :
m_playlistStack(playlistStack),
m_historyPlaylist(0),
m_upcomingPlaylist(0),
......@@ -170,8 +170,7 @@ QStringList PlaylistCollection::playlists() const
//(or qFindChildren() if you need MSVC 6 compatibility)
const QList<Playlist *> childList = m_playlistStack->findChildren<Playlist *>("Playlist");
for(QList<Playlist *>::ConstIterator it = childList.begin(); it != childList.end(); ++it) {
Playlist *p = static_cast<Playlist *>(*it);
foreach(Playlist *p, childList) {
l.append(p->name());
}
......@@ -409,6 +408,7 @@ void PlaylistCollection::duplicate()
visiblePlaylist()->name());
if(name.isEmpty())
return;
raise(new Playlist(this, visiblePlaylist()->items(), name));
}
......@@ -590,7 +590,7 @@ void PlaylistCollection::setUpcomingPlaylistEnabled(bool enable)
}
else {
action<KToggleAction>("showUpcoming")->setChecked(false);
bool raiseCollection = m_playlistStack->visibleWidget() == m_upcomingPlaylist;
bool raiseCollection = visiblePlaylist() == m_upcomingPlaylist;
delete m_upcomingPlaylist;
m_upcomingPlaylist = 0;
......@@ -622,7 +622,7 @@ Playlist *PlaylistCollection::currentPlaylist() const
Playlist *PlaylistCollection::visiblePlaylist() const
{
return static_cast<Playlist *>(m_playlistStack->visibleWidget());
return qobject_cast<Playlist *>(m_playlistStack->currentWidget());
}
void PlaylistCollection::raise(Playlist *playlist)
......@@ -635,7 +635,7 @@ void PlaylistCollection::raise(Playlist *playlist)
TrackSequenceManager::instance()->setCurrentPlaylist(playlist);
playlist->applySharedSettings();
playlist->setSearchEnabled(m_searchEnabled);
m_playlistStack->raiseWidget(playlist);
m_playlistStack->setCurrentWidget(playlist);
clearShowMore(false);
dataChanged();
}
......@@ -648,11 +648,11 @@ void PlaylistCollection::raiseDistraction()
m_belowDistraction = currentPlaylist();
if(!m_distraction) {
m_distraction = new KHBox(m_playlistStack);
m_distraction = new QWidget(m_playlistStack);
m_playlistStack->addWidget(m_distraction);
}
m_playlistStack->raiseWidget(m_distraction);
m_playlistStack->setCurrentWidget(m_distraction);
}
void PlaylistCollection::lowerDistraction()
......@@ -661,7 +661,7 @@ void PlaylistCollection::lowerDistraction()
return;
if(m_belowDistraction)
m_playlistStack->raiseWidget(m_belowDistraction);
m_playlistStack->setCurrentWidget(m_belowDistraction);
m_belowDistraction = 0;
}
......@@ -670,7 +670,7 @@ void PlaylistCollection::lowerDistraction()
// protected methods
////////////////////////////////////////////////////////////////////////////////
Q3WidgetStack *PlaylistCollection::playlistStack() const
QStackedWidget *PlaylistCollection::playlistStack() const
{
return m_playlistStack;
}
......@@ -683,6 +683,7 @@ void PlaylistCollection::setupPlaylist(Playlist *playlist, const QString &)
if(!playlist->name().isEmpty())
m_playlistNames.insert(playlist->name());
m_playlistStack->addWidget(playlist);
QObject::connect(playlist, SIGNAL(selectionChanged()),
object(), SIGNAL(signalSelectedItemsChanged()));
}
......@@ -797,18 +798,13 @@ void PlaylistCollection::dirChanged(const QString &path)
Playlist *PlaylistCollection::playlistByName(const QString &name) const
{
QList<Playlist *> l = m_playlistStack->findChildren<Playlist *>("Playlist");
Playlist *list = 0;
for(QList<Playlist *>::Iterator it = l.begin(); it != l.end(); ++it) {
Playlist *p = static_cast<Playlist*>(*it);
if(p->name() == name) {
list = p;
break;
}
for(int i = 0; i < m_playlistStack->count(); ++i) {
Playlist *p = qobject_cast<Playlist *>(m_playlistStack->widget(i));
if(p && p->name() == name)
return p;
}
return list;
return 0;
}
void PlaylistCollection::newItems(const KFileItemList &list) const
......@@ -947,7 +943,6 @@ KAction *PlaylistCollection::ActionHandler::createAction(const QString &text,
return action;
}
#undef widget
#include "playlistcollection.moc"
// vim: set et sw=4 tw=0 sta:
......@@ -25,7 +25,7 @@
#include <QPointer>
class QPixmap;
class Q3WidgetStack;
class QStackedWidget;
class KAction;
......@@ -49,7 +49,7 @@ class PlaylistCollection : public PlaylistInterface
friend class DynamicPlaylist;
public:
PlaylistCollection(Q3WidgetStack *playlistStack);
PlaylistCollection(QStackedWidget *playlistStack);
virtual ~PlaylistCollection();
static PlaylistCollection *instance() { return m_instance; }
......@@ -161,7 +161,7 @@ public:
class ActionHandler;
protected:
virtual Q3WidgetStack *playlistStack() const;
virtual QStackedWidget *playlistStack() const;
virtual void setupPlaylist(Playlist *playlist, const QString &iconName);
virtual void removePlaylist(Playlist *playlist) = 0;
......@@ -184,7 +184,7 @@ private:
void readConfig();
void saveConfig();
Q3WidgetStack *m_playlistStack;
QStackedWidget *m_playlistStack;
HistoryPlaylist *m_historyPlaylist;
UpcomingPlaylist *m_upcomingPlaylist;
ActionHandler *m_actionHandler;
......
......@@ -26,7 +26,7 @@
#include <QEvent>
#include <QVBoxLayout>
#include <QList>
#include <Q3WidgetStack>
#include <QStackedWidget>
#include <QSizePolicy>
#include "searchwidget.h"
......@@ -163,13 +163,12 @@ void PlaylistSplitter::setupLayout()
topLayout->setMargin(0);
topLayout->setSpacing(0);
m_playlistStack = new Q3WidgetStack(top, "playlistStack");
m_playlistStack = new QStackedWidget(top);
m_playlistStack->setObjectName("playlistStack");
m_playlistStack->installEventFilter(this);
m_playlistStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_playlistStack->hide(); // Will be shown after CollectionList filled.
connect(m_playlistStack, SIGNAL(aboutToShow(QWidget *)), this, SLOT(slotPlaylistChanged(QWidget *)));
m_editor = new TagEditor(editorSplitter);
m_editor->setObjectName("TagEditor");
......@@ -191,9 +190,6 @@ void PlaylistSplitter::setupLayout()
insertWidget(0, m_playlistBox);
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()),
m_editor, SLOT(slotUpdateCollection()));
NowPlaying *nowPlaying = new NowPlaying(top, m_playlistBox);
// Create the search widget -- this must be done after the CollectionList is created.
......@@ -216,6 +212,11 @@ void PlaylistSplitter::setupLayout()
topLayout->addWidget(m_searchWidget);
topLayout->addWidget(m_playlistStack, 1);
// Now that GUI setup is complete, add some auto-update signals.
connect(CollectionList::instance(), SIGNAL(signalCollectionChanged()),
m_editor, SLOT(slotUpdateCollection()));
connect(m_playlistStack, SIGNAL(currentChanged(int)), this, SLOT(slotPlaylistChanged(int)));
// Show the collection on startup.
m_playlistBox->setSelected(0, true);
}
......@@ -256,9 +257,9 @@ void PlaylistSplitter::slotPlaylistSelectionChanged()
m_editor->slotSetItems(visiblePlaylist()->selectedItems());
}
void PlaylistSplitter::slotPlaylistChanged(QWidget *w)
void PlaylistSplitter::slotPlaylistChanged(int i)
{
Playlist *p = dynamic_cast<Playlist *>(w);
Playlist *p = qobject_cast<Playlist *>(m_playlistStack->widget(i));
if(!p)
return;
......
......@@ -18,7 +18,7 @@
#include <QSplitter>
class Q3WidgetStack;
class QStackedWidget;
class Playlist;
class SearchWidget;
......@@ -28,7 +28,7 @@ class PlaylistBox;
/**
* This is the main layout class of JuK. It should contain a PlaylistBox and
* a QWidgetStack of the Playlists.
* a QStackedWidget of the Playlists.
*
* This class serves as a "mediator" (see "Design Patterns") between the JuK
* class and the playlist classes. Thus all access to the playlist classes from
......@@ -56,7 +56,7 @@ private:
/**
* This returns a pointer to the first item in the playlist on the top
* of the QWidgetStack of playlists.
* of the QStackedWidget of playlists.
*/
Playlist *visiblePlaylist() const;
......@@ -73,13 +73,13 @@ private slots:
*/
void slotShowSearchResults();
void slotPlaylistSelectionChanged();
void slotPlaylistChanged(QWidget *w);
void slotPlaylistChanged(int i);
private:
Playlist *m_newVisible;
PlaylistBox *m_playlistBox;
SearchWidget *m_searchWidget;
Q3WidgetStack *m_playlistStack;
QStackedWidget *m_playlistStack;
TagEditor *m_editor;
};
......
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