File indexing completed on 2021-12-21 13:28:01

0001 /**
0002  * Copyright (C) 2002-2004 Scott Wheeler <wheeler@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 JUK_TAGEDITOR_H
0018 #define JUK_TAGEDITOR_H
0019 
0020 #include <QWidget>
0021 #include <QVector>
0022 #include <QMap>
0023 
0024 #include "ui_tageditor.h"
0025 
0026 class KComboBox;
0027 class KConfigGroup;
0028 
0029 class QCheckBox;
0030 
0031 class CollectionObserver;
0032 class Playlist;
0033 class PlaylistItem;
0034 
0035 typedef QVector<PlaylistItem *> PlaylistItemList;
0036 
0037 class TagEditor : public QWidget, public Ui::TagEditor
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     explicit TagEditor(QWidget *parent = 0);
0043     virtual ~TagEditor();
0044     PlaylistItemList items() const { return m_items; }
0045     void setupObservers();
0046 
0047 public slots:
0048     void slotSave() { save(m_items); }
0049     void slotSetItems(const PlaylistItemList &list);
0050     void slotRefresh();
0051     void slotClear();
0052     void slotPlaylistDestroyed(Playlist *p);
0053     /**
0054      * Update collection if we're visible, or defer otherwise
0055      */
0056     void slotUpdateCollection();
0057 
0058 private:
0059     void updateCollection();
0060 
0061     void setupActions();
0062     void setupLayout();
0063     void readConfig();
0064     void readCompletionMode(const KConfigGroup &config, KComboBox *box, const QString &key);
0065     void saveConfig();
0066     void save(const PlaylistItemList &list);
0067     void saveChangesPrompt();
0068     virtual void showEvent(QShowEvent *e) override;
0069 
0070 private slots:
0071     void slotDataChanged();
0072     void slotItemRemoved(PlaylistItem *item);
0073     void slotPlaylistRemoved() { m_currentPlaylist = 0; }
0074 
0075 private:
0076     typedef QMap<QWidget *, QCheckBox *> BoxMap;
0077     BoxMap m_enableBoxes;
0078 
0079     QStringList m_genreList;
0080 
0081     PlaylistItemList m_items;
0082     Playlist *m_currentPlaylist;
0083 
0084     CollectionObserver *m_observer;
0085 
0086     bool m_dataChanged;
0087     bool m_collectionChanged;
0088     bool m_performingSave;
0089 
0090     friend class CollectionObserver;
0091 };
0092 
0093 #endif
0094 
0095 // vim: set et sw=4 tw=0 sta: