File indexing completed on 2025-01-05 04:26:37

0001 /****************************************************************************************
0002  * Copyright (c) 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 #ifndef INLINEEDITORWIDGET_H
0018 #define INLINEEDITORWIDGET_H
0019 
0020 #include "playlist/layouts/LayoutItemConfig.h"
0021 #include "widgets/BoxWidget.h"
0022 
0023 #include <QModelIndex>
0024 #include <QSplitter>
0025 
0026 /**
0027     An inline editor for a playlist item. Relies on the same item layout configuration as is used by the delegate, and strives to have a similar look.
0028 */
0029 class InlineEditorWidget : public BoxWidget
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     InlineEditorWidget(QWidget * parent, const QModelIndex &index, const Playlist::PlaylistLayout &layout, int height, int width );
0035     ~InlineEditorWidget() override;
0036 
0037     QMap<int, QString> changedValues();
0038 
0039 Q_SIGNALS:
0040     void editingDone( InlineEditorWidget * editor );
0041 
0042 protected Q_SLOTS:
0043     void editValueChanged();
0044     void ratingValueChanged();
0045     void splitterMoved( int pos, int index );
0046 
0047 private:
0048     void createChildWidgets();
0049     bool eventFilter( QObject *obj, QEvent *event ) override;
0050 
0051     QPersistentModelIndex m_index;
0052     Playlist::PlaylistLayout m_layout;
0053     int m_widgetHeight;
0054     int m_widgetWidth;
0055 
0056     QMap<QWidget *, int> m_editorRoleMap;
0057     QMap<int, QString> m_changedValues;
0058     QMap<int, QString> m_orgValues;
0059 
0060     QMap<QSplitter *, int> m_splitterRowMap;
0061     bool m_layoutChanged;
0062 
0063 };
0064 
0065 namespace Playlist
0066 {
0067     extern const qreal ALBUM_WIDTH;
0068     extern const qreal SINGLE_TRACK_ALBUM_WIDTH;
0069     extern const qreal MARGIN;
0070     extern const qreal MARGINH;
0071     extern const qreal MARGINBODY;
0072     extern const qreal PADDING;
0073 }
0074 
0075 #endif