~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/tron/tron.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// tron.h
 
2
//
 
3
// Copyright (C) 2000, 2001 Neil Stevens <multivac@fcmail.com>
 
4
//
 
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
6
// of this software and associated documentation files (the "Software"), to deal
 
7
// in the Software without restriction, including without limitation the rights
 
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
9
// copies of the Software, and to permit persons to whom the Software is
 
10
// furnished to do so, subject to the following conditions:
 
11
// 
 
12
// The above copyright notice and this permission notice shall be included in
 
13
// all copies or substantial portions of the Software.
 
14
// 
 
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
19
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
20
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
21
// 
 
22
// Except as contained in this notice, the name(s) of the author(s) shall not be
 
23
// used in advertising or otherwise to promote the sale, use or other dealings
 
24
// in this Software without prior written authorization from the author(s).
 
25
 
 
26
#ifndef TRON_H
 
27
#define TRON_H
 
28
 
 
29
#include <klistview.h>
 
30
#include <kmainwindow.h>
 
31
#include <kurl.h>
 
32
#include <qcolor.h>
 
33
#include <qmap.h>
 
34
 
 
35
#include "plugin.h"
 
36
 
 
37
#include "mcp.h"
 
38
 
 
39
class KAction;
 
40
class KToggleAction;
 
41
class KEdFind;
 
42
 
 
43
/**
 
44
 * TronListViewItem is just a QListViewItem, except that it checks
 
45
 * its parent to see if it should be drawn highlighted.
 
46
 */
 
47
class TronListViewItem : public QListViewItem
 
48
{
 
49
public:
 
50
        TronListViewItem(QListView *, QListViewItem *, QString = QString::null, QString = QString::null);
 
51
        virtual ~TronListViewItem();
 
52
 
 
53
        static void setColors(QColor _specialfg, QColor _specialbg);
 
54
protected:
 
55
        virtual void paintCell(QPainter *, const QColorGroup &, int, int, int);
 
56
 
 
57
private:
 
58
        static QColor *specialFG, *specialBG;
 
59
};
 
60
 
 
61
/**
 
62
 * TronListView handles the drag and drop, and makes sure that only one
 
63
 * item at a time is marked "special".
 
64
 */
 
65
class TronListView : public KListView
 
66
{
 
67
Q_OBJECT
 
68
 
 
69
public:
 
70
        TronListView(QWidget *, const char * = 0);
 
71
        virtual ~TronListView();
 
72
 
 
73
        void setSpecialItem(TronListViewItem *);
 
74
        TronListViewItem *specialItem(void);
 
75
 
 
76
        virtual void clear(void);
 
77
        virtual void takeItem(QListViewItem *);
 
78
 
 
79
signals:
 
80
        void dropped(KURL::List, QListViewItem *);
 
81
 
 
82
protected:
 
83
        virtual bool acceptDrag(QDropEvent *) const;
 
84
 
 
85
protected slots:
 
86
        void myDropEvent(QDropEvent *, QListViewItem *);
 
87
 
 
88
private:
 
89
        TronListViewItem *special;
 
90
};
 
91
 
 
92
/**
 
93
 * Tron is the plugin itself, and is the view.  It is *not* the playlist.
 
94
 * It *has* a playlist, MCP *list.
 
95
 */
 
96
class Tron : public KMainWindow, public Plugin
 
97
{
 
98
Q_OBJECT
 
99
 
 
100
public:
 
101
        Tron();
 
102
        virtual ~Tron();
 
103
 
 
104
        virtual void init();
 
105
        virtual Playlist *playlist(void) const;
 
106
 
 
107
        void setColors(QColor _highlightfg, QColor _highlightbg);
 
108
 
 
109
        enum Columns
 
110
        {
 
111
                colTitle = 1,
 
112
                colLength = 2,
 
113
                colArtist = 4,
 
114
                colAlbum = 8,
 
115
                colDate = 16,
 
116
                colComment = 32
 
117
        };
 
118
 
 
119
        void setColumns(int);
 
120
 
 
121
protected:
 
122
        void closeEvent(QCloseEvent *);
 
123
        void hideEvent(QHideEvent *);
 
124
        void showEvent(QShowEvent *);
 
125
 
 
126
private slots:
 
127
        void itemMoved(QListViewItem *, QListViewItem *, QListViewItem *);
 
128
        void itemExecuted(QListViewItem *);
 
129
        void itemDropped(KURL::List, QListViewItem *);
 
130
        void itemSelectionChanged(void);
 
131
 
 
132
        void fillView(void);
 
133
 
 
134
        void search(void);
 
135
        void searchDone(void);
 
136
 
 
137
        void cleared(void);
 
138
        void loaded(void);
 
139
        void saved(void);
 
140
        void tronadded(PlaylistItem *);
 
141
        void removed(PlaylistItem *);
 
142
        void modified(PlaylistItem *);
 
143
        void current(PlaylistItem *);
 
144
        void moved(PlaylistItem *, PlaylistItem *);
 
145
 
 
146
        void file_opennew(void);
 
147
        void file_open(void);
 
148
        void file_save(void);
 
149
        void file_saveas(void);
 
150
        void edit_add(void);
 
151
        void edit_remove(void);
 
152
        void edit_adddirectory(void);
 
153
        void edit_find(void);
 
154
        void options_shuffle(void);
 
155
        void options_volume(void);
 
156
        void options_menubar(void);
 
157
        void options_toolbar(void);
 
158
        void options_configuretoolbars(void);
 
159
 
 
160
public:
 
161
        static Tron *tronical;
 
162
 
 
163
private:
 
164
        void setModified(bool);
 
165
 
 
166
        void addItem(PlaylistItem *item);
 
167
        void initializeItem(PlaylistItem *item);
 
168
        QMap<TronListViewItem *, PlaylistItem *> viewMap;
 
169
        QMap<PlaylistItem *, TronListViewItem *> playMap;
 
170
 
 
171
        MCP *list;
 
172
        TronListView *listView;
 
173
 
 
174
        KAction *edit_removeAction;
 
175
        KToggleAction *options_shuffleAction, *options_volumeAction;
 
176
        KToggleAction *options_toolbarAction, *options_menubarAction;
 
177
 
 
178
        KURL currentPlaylistURL;
 
179
        bool currentPlaylistModified;
 
180
 
 
181
        KEdFind *findDialog;
 
182
        QListViewItem *findCurrent;
 
183
};
 
184
 
 
185
#endif