mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Forgot to add some search widgets.
This commit is contained in:
104
src/libtomahawk/widgets/searchwidget.cpp
Normal file
104
src/libtomahawk/widgets/searchwidget.cpp
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@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 "searchwidget.h"
|
||||||
|
#include "ui_searchwidget.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
|
#include "viewmanager.h"
|
||||||
|
#include "playlist/playlistmodel.h"
|
||||||
|
|
||||||
|
#include "widgets/overlaywidget.h"
|
||||||
|
|
||||||
|
#include "sourcelist.h"
|
||||||
|
|
||||||
|
|
||||||
|
SearchWidget::SearchWidget( const QString& search, QWidget* parent )
|
||||||
|
: QWidget( parent )
|
||||||
|
, ui( new Ui::SearchWidget )
|
||||||
|
, m_search( search )
|
||||||
|
{
|
||||||
|
ui->setupUi( this );
|
||||||
|
|
||||||
|
m_resultsModel = new PlaylistModel( ui->resultsView );
|
||||||
|
ui->resultsView->setPlaylistModel( m_resultsModel );
|
||||||
|
ui->resultsView->overlay()->setEnabled( false );
|
||||||
|
|
||||||
|
m_queries << Tomahawk::Query::get( search, uuid() );
|
||||||
|
|
||||||
|
foreach ( const Tomahawk::query_ptr& query, m_queries )
|
||||||
|
{
|
||||||
|
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ), SLOT( onResultsFound( QList<Tomahawk::result_ptr> ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect( ui->buttonBox, SIGNAL( rejected() ), SLOT( cancel() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SearchWidget::~SearchWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SearchWidget::changeEvent( QEvent* e )
|
||||||
|
{
|
||||||
|
QWidget::changeEvent( e );
|
||||||
|
switch ( e->type() )
|
||||||
|
{
|
||||||
|
case QEvent::LanguageChange:
|
||||||
|
ui->retranslateUi( this );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SearchWidget::onResultsFound( const QList<Tomahawk::result_ptr>& results )
|
||||||
|
{
|
||||||
|
foreach( const Tomahawk::result_ptr& result, results )
|
||||||
|
{
|
||||||
|
if ( !result->collection().isNull() && !result->isOnline() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QList< Tomahawk::result_ptr > rl;
|
||||||
|
rl << result;
|
||||||
|
|
||||||
|
Tomahawk::query_ptr q = result->toQuery();
|
||||||
|
q->addResults( rl );
|
||||||
|
qDebug() << result->toString();
|
||||||
|
|
||||||
|
m_resultsModel->append( q );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SearchWidget::cancel()
|
||||||
|
{
|
||||||
|
emit destroyed( this );
|
||||||
|
deleteLater();
|
||||||
|
}
|
77
src/libtomahawk/widgets/searchwidget.h
Normal file
77
src/libtomahawk/widgets/searchwidget.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@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 SEARCHWIDGET_H
|
||||||
|
#define SEARCHWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "result.h"
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
#include "viewpage.h"
|
||||||
|
|
||||||
|
#include "dllmacro.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
class PlaylistModel;
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class SearchWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DLLEXPORT SearchWidget : public QWidget, public Tomahawk::ViewPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SearchWidget( const QString& search, QWidget* parent = 0 );
|
||||||
|
~SearchWidget();
|
||||||
|
|
||||||
|
virtual QWidget* widget() { return this; }
|
||||||
|
virtual PlaylistInterface* playlistInterface() const { return 0; }
|
||||||
|
|
||||||
|
virtual QString title() const { return tr( "Search" ); }
|
||||||
|
virtual QString description() const { return tr( "Results for '%1'" ).arg( m_search ); }
|
||||||
|
|
||||||
|
virtual bool showStatsBar() const { return false; }
|
||||||
|
|
||||||
|
virtual bool jumpToCurrentTrack() { return false; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void destroyed( QWidget* widget );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onResultsFound( const QList<Tomahawk::result_ptr>& results );
|
||||||
|
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SearchWidget *ui;
|
||||||
|
|
||||||
|
QString m_search;
|
||||||
|
|
||||||
|
PlaylistModel* m_resultsModel;
|
||||||
|
QList< Tomahawk::query_ptr > m_queries;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NEWPLAYLISTWIDGET_H
|
38
src/libtomahawk/widgets/searchwidget.ui
Normal file
38
src/libtomahawk/widgets/searchwidget.ui
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SearchWidget</class>
|
||||||
|
<widget class="QWidget" name="SearchWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>985</width>
|
||||||
|
<height>460</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::TabFocus</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="PlaylistView" name="resultsView"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>PlaylistView</class>
|
||||||
|
<extends>QTreeView</extends>
|
||||||
|
<header>playlist/playlistview.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
57
src/searchwidget.ui
Normal file
57
src/searchwidget.ui
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SearchWidget</class>
|
||||||
|
<widget class="QWidget" name="SearchWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>345</width>
|
||||||
|
<height>31</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>141</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="SearchLineEdit" name="searchEdit">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>27</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>180</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>SearchLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>libtomahawk/playlist/topbar/searchlineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Reference in New Issue
Block a user