Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
JuK
Commits
5272402f
Commit
5272402f
authored
Apr 03, 2003
by
Scott Wheeler
Browse files
Added "reload from disk" in the RMB menu for the PlaylistBox.
svn path=/trunk/kdemultimedia/juk/; revision=218107
parent
e3edd77c
Changes
5
Hide whitespace changes
Inline
Side-by-side
juk.cpp
View file @
5272402f
...
...
@@ -139,7 +139,7 @@ void JuK::setupActions()
m_stopAction
=
new
KAction
(
i18n
(
"&Stop"
),
"player_stop"
,
0
,
this
,
SLOT
(
stop
()),
actionCollection
(),
"stop"
);
m_backAction
=
new
KAction
(
i18n
(
"Skip &Back"
),
"player_start"
,
0
,
this
,
SLOT
(
back
()),
actionCollection
(),
"back"
);
m_forwardAction
=
new
KAction
(
i18n
(
"Skip &Forward"
),
"player_end"
,
0
,
this
,
SLOT
(
forward
()),
actionCollection
(),
"forward"
);
m_loopPlaylistAction
=
new
KToggleAction
(
i18n
(
"&Loop Playlist"
),
"reload"
,
0
,
actionCollection
(),
"loopPlaylist"
);
m_loopPlaylistAction
=
new
KToggleAction
(
i18n
(
"&Loop Playlist"
),
0
,
0
,
actionCollection
(),
"loopPlaylist"
);
// tagger menu
new
KAction
(
i18n
(
"&Save"
),
"filesave"
,
"CTRL+t"
,
m_splitter
,
SLOT
(
slotSaveTag
()),
actionCollection
(),
"saveItem"
);
...
...
playlist.cpp
View file @
5272402f
...
...
@@ -198,39 +198,11 @@ Playlist::Playlist(QWidget *parent, const QString &name) : KListView(parent, nam
}
Playlist
::
Playlist
(
const
QFileInfo
&
playlistFile
,
QWidget
*
parent
,
const
char
*
name
)
:
KListView
(
parent
,
name
),
m_
playlistF
ileName
(
playlistFile
.
absFilePath
()),
m_
f
ileName
(
playlistFile
.
absFilePath
()),
m_playingItem
(
0
),
m_leftColumn
(
0
)
{
setup
();
QFile
file
(
m_playlistFileName
);
if
(
!
file
.
open
(
IO_ReadOnly
))
return
;
QTextStream
stream
(
&
file
);
// turn off non-explicit sorting
setSorting
(
columns
()
+
1
);
PlaylistItem
*
after
=
0
;
while
(
!
stream
.
atEnd
())
{
QString
itemName
=
(
stream
.
readLine
()).
stripWhiteSpace
();
QFileInfo
item
(
itemName
);
if
(
item
.
isRelative
())
item
.
setFile
(
QDir
::
cleanDirPath
(
playlistFile
.
dirPath
(
true
)
+
"/"
+
itemName
));
if
(
item
.
exists
()
&&
item
.
isFile
()
&&
item
.
isReadable
())
{
if
(
after
)
after
=
createItem
(
item
,
after
);
else
after
=
createItem
(
item
);
}
}
file
.
close
();
loadFile
(
m_fileName
,
playlistFile
);
}
Playlist
::~
Playlist
()
...
...
@@ -240,13 +212,13 @@ Playlist::~Playlist()
void
Playlist
::
save
()
{
if
(
m_
playlistF
ileName
.
isEmpty
())
if
(
m_
f
ileName
.
isEmpty
())
return
saveAs
();
QFile
file
(
m_
playlistF
ileName
);
QFile
file
(
m_
f
ileName
);
if
(
!
file
.
open
(
IO_WriteOnly
))
return
KMessageBox
::
error
(
this
,
i18n
(
"Could not save to file %1."
).
arg
(
m_
playlistF
ileName
));
return
KMessageBox
::
error
(
this
,
i18n
(
"Could not save to file %1."
).
arg
(
m_
f
ileName
));
QTextStream
stream
(
&
file
);
...
...
@@ -262,13 +234,13 @@ void Playlist::saveAs()
{
QStringList
extensions
=
PlaylistSplitter
::
playlistExtensions
();
m_
playlistF
ileName
=
KFileDialog
::
getSaveFileName
(
name
()
+
"."
+
PlaylistSplitter
::
playlistExtensions
().
first
(),
m_
f
ileName
=
KFileDialog
::
getSaveFileName
(
name
()
+
"."
+
PlaylistSplitter
::
playlistExtensions
().
first
(),
PlaylistSplitter
::
extensionsString
(
extensions
,
i18n
(
"Playlists"
)));
m_
playlistF
ileName
=
m_
playlistF
ileName
.
stripWhiteSpace
();
m_
f
ileName
=
m_
f
ileName
.
stripWhiteSpace
();
if
(
m_
playlistF
ileName
!=
QString
::
null
)
{
if
(
extensions
.
find
(
m_
playlistF
ileName
.
section
(
'.'
,
-
1
))
==
extensions
.
end
())
m_
playlistF
ileName
.
append
(
'.'
+
extensions
.
first
());
if
(
m_
f
ileName
!=
QString
::
null
)
{
if
(
extensions
.
find
(
m_
f
ileName
.
section
(
'.'
,
-
1
))
==
extensions
.
end
())
m_
f
ileName
.
append
(
'.'
+
extensions
.
first
());
if
(
m_playlistName
.
isEmpty
())
emit
signalNameChanged
(
name
());
...
...
@@ -383,7 +355,7 @@ PlaylistItem *Playlist::previousItem(PlaylistItem *current, bool random)
QString
Playlist
::
name
()
const
{
if
(
m_playlistName
.
isNull
())
return
m_
playlistF
ileName
.
section
(
QDir
::
separator
(),
-
1
).
section
(
'.'
,
0
,
-
2
);
return
m_
f
ileName
.
section
(
QDir
::
separator
(),
-
1
).
section
(
'.'
,
0
,
-
2
);
else
return
m_playlistName
;
}
...
...
@@ -423,7 +395,11 @@ void Playlist::paste()
void
Playlist
::
clear
()
{
clearItems
(
selectedItems
());
PlaylistItemList
l
=
selectedItems
();
if
(
l
.
isEmpty
())
l
=
items
();
clearItems
(
l
);
}
void
Playlist
::
slotGuessTagInfo
()
...
...
@@ -435,6 +411,16 @@ void Playlist::slotGuessTagInfo()
KApplication
::
restoreOverrideCursor
();
}
void
Playlist
::
slotReload
()
{
QFileInfo
fileInfo
(
m_fileName
);
if
(
!
fileInfo
.
exists
()
||
!
fileInfo
.
isFile
()
||
!
fileInfo
.
isReadable
())
return
;
clear
();
loadFile
(
m_fileName
,
fileInfo
);
}
////////////////////////////////////////////////////////////////////////////////
// protected members
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -742,6 +728,38 @@ void Playlist::setup()
connect
(
header
(),
SIGNAL
(
indexChange
(
int
,
int
,
int
)),
this
,
SLOT
(
slotColumnOrderChanged
(
int
,
int
,
int
)));
}
void
Playlist
::
loadFile
(
const
QString
&
fileName
,
const
QFileInfo
&
fileInfo
)
{
QFile
file
(
fileName
);
if
(
!
file
.
open
(
IO_ReadOnly
))
return
;
QTextStream
stream
(
&
file
);
// turn off non-explicit sorting
setSorting
(
columns
()
+
1
);
PlaylistItem
*
after
=
0
;
while
(
!
stream
.
atEnd
())
{
QString
itemName
=
(
stream
.
readLine
()).
stripWhiteSpace
();
QFileInfo
item
(
itemName
);
if
(
item
.
isRelative
())
item
.
setFile
(
QDir
::
cleanDirPath
(
fileInfo
.
dirPath
(
true
)
+
"/"
+
itemName
));
if
(
item
.
exists
()
&&
item
.
isFile
()
&&
item
.
isReadable
())
{
if
(
after
)
after
=
createItem
(
item
,
after
);
else
after
=
createItem
(
item
);
}
}
file
.
close
();
}
void
Playlist
::
setPlaying
(
PlaylistItem
*
item
,
bool
playing
)
{
if
(
playing
)
{
...
...
playlist.h
View file @
5272402f
...
...
@@ -91,8 +91,8 @@ public:
*/
virtual
PlaylistItem
*
createItem
(
const
QFileInfo
&
file
,
QListViewItem
*
after
=
0
);
QString
fileName
()
const
{
return
m_
playlistF
ileName
;
}
void
setFileName
(
const
QString
&
n
)
{
m_
playlistF
ileName
=
n
;
}
QString
fileName
()
const
{
return
m_
f
ileName
;
}
void
setFileName
(
const
QString
&
n
)
{
m_
f
ileName
=
n
;
}
void
hideColumn
(
int
c
);
void
showColumn
(
int
c
);
...
...
@@ -147,6 +147,10 @@ public slots:
virtual
void
selectAll
()
{
KListView
::
selectAll
(
true
);
}
void
slotGuessTagInfo
();
/**
* Reload the playlist contents from the m3u file.
*/
void
slotReload
();
protected:
/**
...
...
@@ -199,6 +203,7 @@ signals:
private:
void
setup
();
void
loadFile
(
const
QString
&
fileName
,
const
QFileInfo
&
fileInfo
);
void
applyTag
(
QListViewItem
*
item
,
const
QString
&
text
,
int
column
);
int
leftMostVisibleColumn
()
const
;
...
...
@@ -224,7 +229,7 @@ private:
bool
m_allowDuplicates
;
QPtrStack
<
PlaylistItem
>
m_history
;
QString
m_
playlistF
ileName
;
QString
m_
f
ileName
;
/**
* This is only defined if the playlist name is something other than the
...
...
playlistbox.cpp
View file @
5272402f
...
...
@@ -45,21 +45,23 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const char *name) : KListBox(
m_playlistContextMenu
=
new
KPopupMenu
();
m_popupIndex
[
"save"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"filesave"
),
i18n
(
"Save"
),
this
,
SLOT
(
slotContextSave
()));
m_popupIndex
[
"saveas"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"filesaveas"
),
i18n
(
"Save As..."
),
this
,
SLOT
(
slotContextSaveAs
()));
m_popupIndex
[
"rename"
]
=
m_playlistContextMenu
->
insertItem
(
i18n
(
"Rename..."
),
this
,
SLOT
(
slotContextRename
()));
m_popupIndex
[
"save"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"filesave"
),
i18n
(
"Save"
),
this
,
SLOT
(
slotContextSave
()));
m_popupIndex
[
"saveas"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"filesaveas"
),
i18n
(
"Save As..."
),
this
,
SLOT
(
slotContextSaveAs
()));
m_popupIndex
[
"rename"
]
=
m_playlistContextMenu
->
insertItem
(
i18n
(
"Rename..."
),
this
,
SLOT
(
slotContextRename
()));
m_popupIndex
[
"duplicate"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"editcopy"
),
i18n
(
"Duplicate..."
),
this
,
SLOT
(
slotContextDuplicate
()));
m_popupIndex
[
"remove"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"edittrash"
),
i18n
(
"Remove"
),
this
,
SLOT
(
slotContextDeleteItem
()));
SmallIconSet
(
"editcopy"
),
i18n
(
"Duplicate..."
),
this
,
SLOT
(
slotContextDuplicate
()));
m_popupIndex
[
"remove"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"edittrash"
),
i18n
(
"Remove"
),
this
,
SLOT
(
slotContextDeleteItem
()));
m_popupIndex
[
"reload"
]
=
m_playlistContextMenu
->
insertItem
(
SmallIconSet
(
"reload"
),
i18n
(
"Reload Playlist File"
),
this
,
SLOT
(
slotContextReload
()));
setAcceptDrops
(
true
);
setSelectionMode
(
Extended
);
...
...
@@ -261,6 +263,12 @@ void PlaylistBox::deleteItem(Item *item)
delete
item
;
}
void
PlaylistBox
::
reload
(
Item
*
item
)
{
if
(
item
&&
item
->
playlist
())
item
->
playlist
()
->
slotReload
();
}
void
PlaylistBox
::
resizeEvent
(
QResizeEvent
*
e
)
{
triggerUpdate
(
true
);
...
...
@@ -379,18 +387,16 @@ void PlaylistBox::slotShowContextMenu(QListBoxItem *item, const QPoint &point)
m_contextMenuOn
=
i
;
if
(
i
)
{
if
(
i
->
playlist
()
==
CollectionList
::
instance
())
{
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"save"
],
false
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"saveas"
],
false
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"rename"
],
false
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"remove"
],
false
);
}
else
{
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"save"
],
true
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"saveas"
],
true
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"rename"
],
true
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"remove"
],
true
);
}
bool
isCollection
=
i
->
playlist
()
==
CollectionList
::
instance
();
bool
hasFile
=
!
i
->
playlist
()
->
fileName
().
isEmpty
();
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"save"
],
!
isCollection
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"saveas"
],
!
isCollection
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"rename"
],
!
isCollection
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"remove"
],
!
isCollection
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"reload"
],
!
isCollection
);
m_playlistContextMenu
->
setItemEnabled
(
m_popupIndex
[
"reload"
],
hasFile
);
m_playlistContextMenu
->
popup
(
point
);
}
}
...
...
@@ -421,6 +427,12 @@ void PlaylistBox::slotContextDeleteItem()
m_contextMenuOn
=
0
;
}
void
PlaylistBox
::
slotContextReload
()
{
reload
(
m_contextMenuOn
);
m_contextMenuOn
=
0
;
}
////////////////////////////////////////////////////////////////////////////////
// PlaylistBox::Item public methods
////////////////////////////////////////////////////////////////////////////////
...
...
playlistbox.h
View file @
5272402f
...
...
@@ -77,6 +77,7 @@ private:
void
rename
(
Item
*
item
);
void
duplicate
(
Item
*
item
);
void
deleteItem
(
Item
*
item
);
void
reload
(
Item
*
item
);
virtual
void
resizeEvent
(
QResizeEvent
*
e
);
virtual
void
decode
(
QMimeSource
*
s
,
Item
*
item
);
...
...
@@ -106,6 +107,7 @@ private slots:
void
slotContextRename
();
void
slotContextDuplicate
();
void
slotContextDeleteItem
();
void
slotContextReload
();
private:
PlaylistSplitter
*
m_splitter
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment