multiple selection for right-click in the Scratchpad window
This commit is contained in:
parent
a25a6567b5
commit
b7e25b5a33
2 changed files with 99 additions and 84 deletions
|
@ -100,8 +100,9 @@ ScratchpadWindow :: ScratchpadWindow (
|
||||||
treeView->connectModelSignals(treeModel);
|
treeView->connectModelSignals(treeModel);
|
||||||
|
|
||||||
// register the signal handlers for treeview
|
// register the signal handlers for treeview
|
||||||
treeView->signal_button_press_event().connect_notify(sigc::mem_fun(*this,
|
treeView->signal_button_press_event().connect(sigc::mem_fun(*this,
|
||||||
&ScratchpadWindow::onEntryClicked));
|
&ScratchpadWindow::onEntryClicked),
|
||||||
|
false /* call this first */);
|
||||||
treeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
treeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||||
&ScratchpadWindow::onDoubleClick));
|
&ScratchpadWindow::onDoubleClick));
|
||||||
treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
treeView->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||||
|
@ -183,66 +184,62 @@ ScratchpadWindow :: ScratchpadWindow (
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Event handler for an entry being clicked in the list
|
* Event handler for an entry being clicked in the list
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
bool
|
||||||
ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
ScratchpadWindow :: onEntryClicked (GdkEventButton * event) throw ()
|
||||||
{
|
{
|
||||||
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
|
||||||
Gtk::TreePath currentPath;
|
Glib::RefPtr<Gtk::TreeView::Selection>
|
||||||
Gtk::TreeViewColumn * column;
|
selection = treeView->get_selection();
|
||||||
int cell_x,
|
selectedPaths.reset(new std::vector<Gtk::TreePath>(
|
||||||
cell_y;
|
selection->get_selected_rows()));
|
||||||
bool foundValidRow = treeView->get_path_at_pos(
|
|
||||||
int(event->x), int(event->y),
|
|
||||||
currentPath, column,
|
|
||||||
cell_x, cell_y);
|
|
||||||
|
|
||||||
if (foundValidRow) {
|
if (selectedPaths->size() > 0) {
|
||||||
Gtk::TreeIter iter = treeModel->get_iter(currentPath);
|
selectedIter = selectedPaths->begin();
|
||||||
if (iter) {
|
|
||||||
currentRow = *iter;
|
|
||||||
|
|
||||||
|
if (selectedPaths->size() == 1) {
|
||||||
|
Gtk::TreeRow row = *(treeModel->get_iter(*selectedIter));
|
||||||
Ptr<Playable>::Ref
|
Ptr<Playable>::Ref
|
||||||
playable = currentRow[modelColumns.playableColumn];
|
playable = row[modelColumns.playableColumn];
|
||||||
|
|
||||||
switch (playable->getType()) {
|
if (playable->getType() == Playable::AudioClipType) {
|
||||||
case Playable::AudioClipType:
|
|
||||||
audioClipMenu->popup(event->button, event->time);
|
audioClipMenu->popup(event->button, event->time);
|
||||||
break;
|
return true;
|
||||||
|
|
||||||
case Playable::PlaylistType:
|
} else if (playable->getType() == Playable::PlaylistType) {
|
||||||
playlistMenu->popup(event->button, event->time);
|
playlistMenu->popup(event->button, event->time);
|
||||||
break;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
} else { // selectedPaths.size() > 1
|
||||||
break;
|
audioClipMenu->popup(event->button, event->time);
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Select the row which contains the playable specified.
|
* Return the next selected playable item.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
Ptr<Playable>::Ref
|
||||||
ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw ()
|
ScratchpadWindow :: getNextSelectedPlayable(void) throw ()
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::const_iterator it;
|
Ptr<Playable>::Ref playable;
|
||||||
|
|
||||||
for (it = treeModel->children().begin();
|
if (selectedPaths) {
|
||||||
it != treeModel->children().end(); ++it) {
|
if (selectedIter != selectedPaths->end()) {
|
||||||
|
Gtk::TreeRow row = *(treeModel->get_iter(*selectedIter));
|
||||||
Gtk::TreeRow row = *it;
|
playable = row[modelColumns.playableColumn];
|
||||||
Ptr<Playable>::Ref currentPlayable = row[modelColumns.playableColumn];
|
++selectedIter;
|
||||||
|
} else {
|
||||||
if (*playable->getId() == *currentPlayable->getId()) {
|
selectedPaths.reset();
|
||||||
Glib::RefPtr<Gtk::TreeView::Selection>
|
|
||||||
selection = treeView->get_selection();
|
|
||||||
selection->select(it);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return playable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,7 +272,8 @@ ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onEditPlaylist(void) throw ()
|
ScratchpadWindow :: onEditPlaylist(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable = getNextSelectedPlayable();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
gLiveSupport->openPlaylistForEditing(playable->getId());
|
gLiveSupport->openPlaylistForEditing(playable->getId());
|
||||||
} catch (XmlRpcException &e) {
|
} catch (XmlRpcException &e) {
|
||||||
|
@ -292,7 +290,7 @@ ScratchpadWindow :: onEditPlaylist(void) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable = getNextSelectedPlayable();
|
||||||
Ptr<Playlist>::Ref playlist = playable->getPlaylist();
|
Ptr<Playlist>::Ref playlist = playable->getPlaylist();
|
||||||
|
|
||||||
if (playlist) {
|
if (playlist) {
|
||||||
|
@ -309,7 +307,7 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onExportPlaylist(void) throw ()
|
ScratchpadWindow :: onExportPlaylist(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable = getNextSelectedPlayable();
|
||||||
Ptr<Playlist>::Ref playlist = playable->getPlaylist();
|
Ptr<Playlist>::Ref playlist = playable->getPlaylist();
|
||||||
|
|
||||||
if (playlist) {
|
if (playlist) {
|
||||||
|
@ -327,7 +325,9 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable;
|
||||||
|
|
||||||
|
while ((playable = getNextSelectedPlayable())) {
|
||||||
try {
|
try {
|
||||||
gLiveSupport->addToPlaylist(playable->getId());
|
gLiveSupport->addToPlaylist(playable->getId());
|
||||||
} catch (XmlRpcException &e) {
|
} catch (XmlRpcException &e) {
|
||||||
|
@ -335,6 +335,7 @@ ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
||||||
<< e.what() << std::endl;
|
<< e.what() << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,8 +346,11 @@ ScratchpadWindow :: onAddToPlaylist(void) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable;
|
||||||
|
|
||||||
|
while ((playable = getNextSelectedPlayable())) {
|
||||||
gLiveSupport->addToLiveMode(playable);
|
gLiveSupport->addToLiveMode(playable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,8 +360,11 @@ ScratchpadWindow :: onAddToLiveMode(void) throw ()
|
||||||
void
|
void
|
||||||
ScratchpadWindow :: onUploadToHub(void) throw ()
|
ScratchpadWindow :: onUploadToHub(void) throw ()
|
||||||
{
|
{
|
||||||
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
|
Ptr<Playable>::Ref playable;
|
||||||
|
|
||||||
|
while ((playable = getNextSelectedPlayable())) {
|
||||||
gLiveSupport->uploadToHub(playable);
|
gLiveSupport->uploadToHub(playable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,9 +410,13 @@ ScratchpadWindow :: onDoubleClick(const Gtk::TreeModel::Path & path,
|
||||||
const Gtk::TreeViewColumn * column)
|
const Gtk::TreeViewColumn * column)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
Gtk::TreeIter iter = treeModel->get_iter(path);
|
Glib::RefPtr<Gtk::TreeView::Selection>
|
||||||
if (iter) {
|
selection = treeView->get_selection();
|
||||||
currentRow = *iter;
|
selectedPaths.reset(new std::vector<Gtk::TreePath>(
|
||||||
|
selection->get_selected_rows()));
|
||||||
|
|
||||||
|
if (selectedPaths->size() > 0) {
|
||||||
|
selectedIter = selectedPaths->begin();
|
||||||
onAddToLiveMode();
|
onAddToLiveMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -460,13 +471,7 @@ ScratchpadWindow :: isSelectionSingle(void) throw ()
|
||||||
std::vector<Gtk::TreePath>
|
std::vector<Gtk::TreePath>
|
||||||
selectedRows = selection->get_selected_rows();
|
selectedRows = selection->get_selected_rows();
|
||||||
|
|
||||||
if (selectedRows.size() == 1) {
|
return (selectedRows.size() == 1);
|
||||||
Gtk::TreeIter iter = treeModel->get_iter(selectedRows.at(0));
|
|
||||||
currentRow = *iter;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,18 @@ class ScratchpadWindow : public GuiWindow,
|
||||||
Ptr<SchedulePlaylistWindow>::Ref schedulePlaylistWindow;
|
Ptr<SchedulePlaylistWindow>::Ref schedulePlaylistWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether exactly one row is selected, and if so, set
|
* Used to iterate over the selected rows.
|
||||||
* the currentRow variable to point to it.
|
* Reset to the first row by onEntryClicked().
|
||||||
|
* Returns a 0 pointer if nothing is selected or we have reached
|
||||||
|
* the end of the list of selected rows.
|
||||||
|
*
|
||||||
|
* @return the next selected item.
|
||||||
|
*/
|
||||||
|
Ptr<Playable>::Ref
|
||||||
|
getNextSelectedPlayable(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether exactly one row is selected.
|
||||||
*
|
*
|
||||||
* This is an auxilliary function used by onKeyPressed().
|
* This is an auxilliary function used by onKeyPressed().
|
||||||
*
|
*
|
||||||
|
@ -105,15 +115,6 @@ class ScratchpadWindow : public GuiWindow,
|
||||||
bool
|
bool
|
||||||
isSelectionSingle(void) throw ();
|
isSelectionSingle(void) throw ();
|
||||||
|
|
||||||
/**
|
|
||||||
* Select the (first) row which contains the playable specified.
|
|
||||||
* If no such row is found, then it does nothing.
|
|
||||||
*
|
|
||||||
* @param playable the playable to be selected.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
selectRow(Ptr<Playable>::Ref playable) throw ();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an item from the Scratchpad.
|
* Remove an item from the Scratchpad.
|
||||||
* If an item with the specified unique ID is found, it is removed.
|
* If an item with the specified unique ID is found, it is removed.
|
||||||
|
@ -184,9 +185,16 @@ class ScratchpadWindow : public GuiWindow,
|
||||||
ZebraTreeView * treeView;
|
ZebraTreeView * treeView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model row at the mouse pointer, set by onEntryClicked()
|
* The list of selected rows, as path references (row numbers).
|
||||||
|
* Reset by onEntryClicked();
|
||||||
*/
|
*/
|
||||||
Gtk::TreeRow currentRow;
|
Ptr<std::vector<Gtk::TreePath> >::Ref
|
||||||
|
selectedPaths;
|
||||||
|
/**
|
||||||
|
* One of the selected rows, set to the first one by onEntryClicked().
|
||||||
|
*/
|
||||||
|
std::vector<Gtk::TreePath>::const_iterator
|
||||||
|
selectedIter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cue player widget controlling the audio buttons.
|
* The cue player widget controlling the audio buttons.
|
||||||
|
@ -210,8 +218,10 @@ class ScratchpadWindow : public GuiWindow,
|
||||||
* This is used to pop up the right-click context menu.
|
* This is used to pop up the right-click context menu.
|
||||||
*
|
*
|
||||||
* @param event the button event recieved
|
* @param event the button event recieved
|
||||||
|
* @return true if the event has been handled (a popup displayed),
|
||||||
|
* false otherwise
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual bool
|
||||||
onEntryClicked(GdkEventButton * event) throw ();
|
onEntryClicked(GdkEventButton * event) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue