File indexing completed on 2024-05-05 04:47:21
0001 /**************************************************************************************** 0002 * Copyright (c) 2008, 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "BookmarkManagerWidget.h" 0018 0019 #include "amarokurls/AmarokUrl.h" 0020 #include "amarokurls/BookmarkModel.h" 0021 #include "amarokurls/BookmarkCurrentButton.h" 0022 #include "amarokurls/NavigationUrlGenerator.h" 0023 #include "amarokurls/PlayUrlGenerator.h" 0024 #include "widgets/ProgressWidget.h" 0025 0026 #include <QAction> 0027 #include <QHBoxLayout> 0028 #include <QIcon> 0029 #include <QLabel> 0030 #include <QVBoxLayout> 0031 0032 #include <KLocalizedString> 0033 0034 BookmarkManagerWidget::BookmarkManagerWidget( QWidget * parent ) 0035 : BoxWidget( true, parent ) 0036 { 0037 layout()->setContentsMargins( 0,0,0,0 ); 0038 0039 BoxWidget * topLayout = new BoxWidget( false, this ); 0040 0041 m_toolBar = new QToolBar( topLayout ); 0042 m_toolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); 0043 0044 QAction * addGroupAction = new QAction( QIcon::fromTheme(QStringLiteral("media-track-add-amarok") ), i18n( "Add Group" ), this ); 0045 m_toolBar->addAction( addGroupAction ); 0046 connect( addGroupAction, &QAction::triggered, BookmarkModel::instance(), &BookmarkModel::createNewGroup ); 0047 0048 /*QAction * addBookmarkAction = new QAction( QIcon::fromTheme("bookmark-new" ), i18n( "New Bookmark" ), this ); 0049 m_toolBar->addAction( addBookmarkAction ); 0050 connect( addBookmarkaction, &QAction::triggered, BookmarkModel::instance(), &BookmarkModel::createNewBookmark );*/ 0051 0052 m_toolBar->addWidget( new BookmarkCurrentButton( nullptr ) ); 0053 0054 m_searchEdit = new Amarok::LineEdit( topLayout ); 0055 m_searchEdit->setPlaceholderText( i18n( "Filter bookmarks" ) ); 0056 m_searchEdit->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 0057 m_searchEdit->setClearButtonEnabled( true ); 0058 m_searchEdit->setFrame( true ); 0059 m_searchEdit->setToolTip( i18n( "Start typing to progressively filter the bookmarks" ) ); 0060 m_searchEdit->setFocusPolicy( Qt::ClickFocus ); // Without this, the widget goes into text input mode directly on startup 0061 0062 m_bookmarkView = new BookmarkTreeView( this ); 0063 0064 m_proxyModel = new QSortFilterProxyModel( this ); 0065 m_proxyModel->setSourceModel( BookmarkModel::instance() ); 0066 m_proxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive ); 0067 m_proxyModel->setSortCaseSensitivity( Qt::CaseInsensitive ); 0068 m_proxyModel->setDynamicSortFilter( true ); 0069 m_proxyModel->setFilterKeyColumn ( -1 ); //filter on all columns 0070 0071 m_bookmarkView->setModel( m_proxyModel ); 0072 m_bookmarkView->setProxy( m_proxyModel ); 0073 m_bookmarkView->setSortingEnabled( true ); 0074 m_bookmarkView->resizeColumnToContents( 0 ); 0075 0076 connect( BookmarkModel::instance(), &BookmarkModel::editIndex, m_bookmarkView, &BookmarkTreeView::slotEdit ); 0077 connect( m_searchEdit, &Amarok::LineEdit::textChanged, m_proxyModel, &QSortFilterProxyModel::setFilterFixedString ); 0078 0079 m_currentBookmarkId = -1; 0080 0081 } 0082 0083 BookmarkManagerWidget::~BookmarkManagerWidget() 0084 { 0085 } 0086 0087 0088 BookmarkTreeView * BookmarkManagerWidget::treeView() 0089 { 0090 return m_bookmarkView; 0091 } 0092 0093 0094 0095