1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 09:34:53 +02:00

* Remove TemporaryPageItem from sidebar when its ViewPage gets destroyed.

This commit is contained in:
Christian Muehlhaeuser
2013-09-07 21:29:04 +02:00
parent 41aeff750b
commit 3343062fcc
2 changed files with 40 additions and 24 deletions

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -26,6 +27,7 @@
#include "widgets/SearchWidget.h" #include "widgets/SearchWidget.h"
#include "utils/ImageRegistry.h" #include "utils/ImageRegistry.h"
#include "utils/Closure.h" #include "utils/Closure.h"
#include "utils/Logger.h"
#include <QAction> #include <QAction>
@@ -79,6 +81,12 @@ TemporaryPageItem::TemporaryPageItem ( SourcesModel* mdl, SourceTreeItem* parent
NewClosure( action, SIGNAL( triggered() ), this, SLOT( linkActionTriggered( QAction* ) ), action ); NewClosure( action, SIGNAL( triggered() ), this, SLOT( linkActionTriggered( QAction* ) ), action );
} }
if ( QObject* obj = dynamic_cast< QObject* >( page ) )
{
if ( obj->metaObject()->indexOfSignal( "destroyed(QObject*)" ) > -1 )
connect( obj, SIGNAL( destroyed( QObject* ) ), SLOT( pageDestroyed() ) );
}
model()->linkSourceItemToPage( this, page ); model()->linkSourceItemToPage( this, page );
} }
@@ -125,6 +133,14 @@ TemporaryPageItem::IDValue() const
void void
TemporaryPageItem::removeFromList() TemporaryPageItem::removeFromList()
{
pageDestroyed();
ViewManager::instance()->destroyPage( m_page );
}
void
TemporaryPageItem::pageDestroyed()
{ {
model()->removeSourceItemLink( this ); model()->removeSourceItemLink( this );
@@ -134,8 +150,6 @@ TemporaryPageItem::removeFromList()
parent()->endRowsRemoved(); parent()->endRowsRemoved();
emit removed(); emit removed();
ViewManager::instance()->destroyPage( m_page );
deleteLater(); deleteLater();
} }

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2010-2013, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -50,6 +51,7 @@ signals:
private slots: private slots:
void linkActionTriggered( QAction* ); void linkActionTriggered( QAction* );
void pageDestroyed();
private: private:
Tomahawk::ViewPage* m_page; Tomahawk::ViewPage* m_page;