Changeset 1895
- Timestamp:
- Thu Feb 2 20:14:00 2006
- Files:
-
- trunk/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h (modified) (diff)
- trunk/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.h (modified) (diff)
- trunk/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx (modified) (diff)
- trunk/livesupport/src/products/gLiveSupport/src/GLiveSupport.h (modified) (diff)
- trunk/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx (modified) (diff)
- trunk/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx (modified) (diff)
- trunk/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h (modified) (diff)
- trunk/livesupport/src/modules/widgets/src/ZebraTreeView.cxx (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h
r1875 r1895 471 471 */ 472 472 void 473 updateScratchpadWindow(void) throw (); 473 updateScratchpadWindow(Ptr<Playable>::Ref playable 474 = Ptr<Playable>::Ref()) 475 throw (); 474 476 475 477 /** -
trunk/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.h
r1869 r1895 100 100 selectRow(Ptr<Playable>::Ref playable) throw (); 101 101 102 /** 103 * Remove an item from the Scratchpad. 104 * If an item with the specified unique ID is found, it is removed. 105 * (There should never be more than one entry with the same ID; 106 * if there are, then only the first one is removed.) 107 * If no such item is found, the function does nothing. 108 * 109 * @param id the id of the item to remove. 110 */ 111 void 112 removeItem(Ptr<const UniqueId>::Ref id) throw (); 113 102 114 103 115 protected: … … 269 281 270 282 /** 271 * Signal handler for the "up" menu item selected from272 * the entry context menu.273 */274 virtual void275 onUpItem(void) throw ();276 277 /**278 * Signal handler for the "down" menu item selected from279 * the entry context menu.280 */281 virtual void282 onDownItem(void) throw ();283 284 /**285 * Signal handler for the "remove" menu item selected from286 * the entry context menu.287 */288 virtual void289 onRemoveItem(void) throw ();290 291 /**292 283 * Signal handler for the "edit playlist" menu item selected from 293 284 * the entry context menu. 344 335 345 336 /** 346 * Update the window contents, with the contents of the Scratchpad. 337 * Add an item to the Scratchpad. 338 * If it was already in the Scratchpad, move it to the top. 339 * 340 * @param playable the Playable object to add. 347 341 */ 348 342 void 349 showContents(void)throw ();343 addItem(Ptr<Playable>::Ref playable) throw (); 349 343 350 344 /** 351 * Remove an item from the Scratchpad. 345 * Add an item to the Scratchpad. 346 * If it was already in the Scratchpad, move it to the top. 352 347 * 353 * @param id the id of the item to remove.348 * @param id the id of the item to add. 353 348 */ 354 349 void 355 removeItem(Ptr<const UniqueId>::Ref id) throw (); 350 addItem(Ptr<UniqueId>::Ref id) throw (); 351 352 /** 353 * Return the contents of the Scratchpad. 354 * 355 * @return a space-separated list of the unique IDs, in base 10. 356 * @see restore() 357 */ 358 Ptr<Glib::ustring>::Ref 359 contents() throw (); 360 361 /** 362 * Restore the contents of the Scratchpad. 363 * The current contents are discarded, and replaced with the items 364 * listed in the 'contents' parameter. 365 * 366 * @param contents a space-separated list of unique IDs, in base 10. 367 * @see contents() 368 */ 369 void 370 restore(Ptr<Glib::ustring>::Ref contents) throw (); 356 371 }; 357 372 -
trunk/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx
r1890 r1895 546 546 } 547 547 548 loadScratchpadContents();549 548 loadWindowPositions(); 550 549 … … 574 573 windowPositions.clear(); 575 574 576 storeScratchpadContents();577 scratchpadContents->clear();578 579 575 authentication->logout(sessionId); 580 576 sessionId.reset(); … … 593 589 void 594 590 LiveSupport :: GLiveSupport :: 595 GLiveSupport :: storeScratchpadContents(void) throw () 591 GLiveSupport :: storeScratchpadContents(Ptr<ScratchpadWindow>::Ref window) 592 throw () 596 593 { 597 // just store this as a space-delimited list of ids 598 std::ostringstream prefsString; 599 GLiveSupport::PlayableList::iterator it; 600 GLiveSupport::PlayableList::iterator end; 601 Ptr<Playable>::Ref playable; 602 603 it = scratchpadContents->begin(); 604 end = scratchpadContents->end(); 605 while (it != end) { 606 playable = *it; 607 prefsString << playable->getId()->getId() << " "; 608 609 ++it; 610 } 611 612 Ptr<Glib::ustring>::Ref prefsUstring(new Glib::ustring(prefsString.str())); 594 Ptr<Glib::ustring>::Ref scratchpadContents = window->contents(); 595 613 596 try { 614 597 authentication->savePreferencesItem(sessionId, 615 598 scratchpadContentsKey, 616 prefsUstring);599 scratchpadContents); 616 599 } catch (XmlRpcException &e) { 617 600 // TODO: signal error 618 std::cerr << "error saving user preferences: " << e.what() << std::endl; 601 std::cerr << "error saving user preferences: " 602 << e.what() 603 << std::endl; 619 604 } 620 605 } … … 627 612 void 628 613 LiveSupport :: GLiveSupport :: 629 GLiveSupport :: loadScratchpadContents(void) throw () 614 GLiveSupport :: loadScratchpadContents(Ptr<ScratchpadWindow>::Ref window) 615 throw () 630 616 { 631 Ptr<Glib::ustring>::Ref prefsUstring;617 Ptr<Glib::ustring>::Ref scratchpadContents; 631 617 632 618 try { 633 prefsUstring = authentication->loadPreferencesItem(sessionId, 619 scratchpadContents = authentication->loadPreferencesItem( 620 sessionId, 634 621 scratchpadContentsKey); 635 622 } catch (XmlRpcException &e) { … … 644 631 } 645 632 646 // load the prefs, which is a space-delimited list 647 std::istringstream prefsString(prefsUstring->raw()); 648 Ptr<Playable>::Ref playable; 649 650 while (!prefsString.eof()) { 651 UniqueId::IdType idValue; 652 Ptr<UniqueId>::Ref id; 653 654 prefsString >> idValue; 655 if (prefsString.fail()) { 656 break; 657 } 658 id.reset(new UniqueId(idValue)); 659 660 // now we have the id, get the corresponding playlist or audio clip from 661 // the storage 662 if (existsPlaylist(id)) { 663 Ptr<Playlist>::Ref playlist = acquirePlaylist(id); 664 scratchpadContents->push_back(playlist); 665 } else if (existsAudioClip(id)) { 666 Ptr<AudioClip>::Ref clip = acquireAudioClip(id); 667 scratchpadContents->push_back(clip); 668 } 669 } 633 window->restore(scratchpadContents); 670 634 } 671 635 … … 782 746 783 747 /*------------------------------------------------------------------------------ 748 * Acquire an Playable object. 749 *----------------------------------------------------------------------------*/ 750 Ptr<Playable>::Ref 751 LiveSupport :: GLiveSupport :: 752 GLiveSupport :: acquirePlayable(Ptr<UniqueId>::Ref id) 753 throw (XmlRpcException) 754 { 755 Ptr<Playable>::Ref playable; 756 757 if (existsPlaylist(id)) { 758 playable = acquirePlaylist(id); 759 760 } else if (existsAudioClip(id)) { 761 playable = acquireAudioClip(id); 762 } 763 764 return playable; 765 } 766 767 768 /*------------------------------------------------------------------------------ 784 769 * Release all openned audio clips. 785 770 *----------------------------------------------------------------------------*/ … … 874 859 throw () 875 860 { 876 // make sure playable is in the appropriate cache as well877 861 if (playable->getType() == Playable::AudioClipType) { 878 862 acquireAudioClip(playable->getId()); 881 865 } 882 866 883 // erase previous reference from list, if it's still in there 884 PlayableList::iterator it; 885 for (it = scratchpadContents->begin(); it != scratchpadContents->end(); 886 ++it) { 887 Ptr<Playable>::Ref listElement = *it; 888 if (*listElement->getId() == *playable->getId()) { 889 scratchpadContents->erase(it); 890 break; 891 } 892 } 893 894 // add to list 895 scratchpadContents->push_front(playable); 896 masterPanel->updateScratchpadWindow(); 867 // this will also add it to the local cache 868 masterPanel->updateScratchpadWindow(playable); 897 869 } 898 870 -
trunk/livesupport/src/products/gLiveSupport/src/GLiveSupport.h
r1890 r1895 62 62 namespace GLiveSupport { 63 63 64 class ScratchpadWindow; // forward declaration to avoid circularity 65 64 66 using namespace LiveSupport::Core; 65 67 using namespace LiveSupport::SchedulerClient; … … 130 132 131 133 /** 132 * The type of the list for storing the Scratchpad contents.134 * The type of the list of search results. 132 134 * This is a list holding Ptr<Playable>::Ref references. 133 135 */ … … 219 221 220 222 /** 221 * The contents of a Scratchpad, stored as a list.222 */223 Ptr<PlayableList>::Ref scratchpadContents;224 225 /**226 223 * The one and only playlist that may be edited at any one time. 227 224 */ … … 273 270 274 271 /** 275 * Store the contents of the Scratchpad as a user preference.276 */277 void278 storeScratchpadContents(void) throw ();279 280 /**281 * Load the contents of the Scratchpad as a user preference.282 */283 void284 loadScratchpadContents(void) throw ();285 286 /**287 272 * Emit the "edited playlist has been modified" signal. 288 273 */ … … 356 341 cuePlayerIsPaused(false) 357 342 { 358 scratchpadContents.reset(new PlayableList());359 343 opennedAudioClips.reset(new AudioClipMap()); 360 344 opennedPlaylists.reset(new PlaylistMap()); … … 551 535 552 536 /** 553 * Return the Scratchpad contents.554 *555 * @return the list holding the Scratchpad contents.556 */557 Ptr<PlayableList>::Ref558 getScratchpadContents(void) throw ()559 {560 return scratchpadContents;561 }562 563 /**564 537 * Reset the storage behind GLiveSupport. 565 538 * Used for testing only. … … 688 661 689 662 /** 663 * Acquire a playable object. 664 * Calls either acquireAudioClip() or acquirePlaylist(). 665 * 666 * @param id the id of the playable object. 667 * @return the playable object acquired. 668 * note that the returned Playable does not have to be 669 * released, this will be done by the caching system 670 * automatically. 671 * @exception XmlRpcException if no Playable with the specified 672 * id exists, or there was a communication problem. 673 */ 674 Ptr<Playable>::Ref 675 acquirePlayable(Ptr<UniqueId>::Ref id) 676 throw (XmlRpcException); 677 678 /** 690 679 * Release all openned audio clips. 691 680 */ 1056 1045 return optionsContainer; 1057 1046 } 1047 1048 /** 1049 * Store the contents of the Scratchpad as a user preference. 1050 * 1051 * @param window the ScratchpadWindow to query. 1052 */ 1053 void 1054 storeScratchpadContents(Ptr<ScratchpadWindow>::Ref window) 1055 throw (); 1056 1057 /** 1058 * Load the contents of the Scratchpad as a user preference. 1059 * 1060 * @param window the ScratchpadWindow to restore the contents of. 1061 */ 1062 void 1063 loadScratchpadContents(Ptr<ScratchpadWindow>::Ref window) 1064 throw (); 1058 1065 }; 1059 1066 -
trunk/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx
r1875 r1895 439 439 *----------------------------------------------------------------------------*/ 440 440 void 441 MasterPanelWindow :: updateScratchpadWindow(void) throw () 441 MasterPanelWindow :: updateScratchpadWindow(Ptr<Playable>::Ref playable) 442 throw () 442 443 { 443 444 if (!scratchpadWindow.get()) { … … 450 451 } 451 452 scratchpadWindow.reset(new ScratchpadWindow(gLiveSupport, bundle)); 453 gLiveSupport->loadScratchpadContents(scratchpadWindow); 452 454 gLiveSupport->getWindowPosition(scratchpadWindow); 453 455 } 454 456 455 scratchpadWindow->showContents(); 456 457 if (playable) { 458 scratchpadWindow->addItem(playable); 459 } 460 457 461 if (!scratchpadWindow->is_visible()) { 458 462 gLiveSupport->getWindowPosition(scratchpadWindow); 607 611 } 608 612 if (scratchpadWindow.get()) { 613 gLiveSupport->storeScratchpadContents(scratchpadWindow); 609 614 if (scratchpadWindow->is_visible()) { 610 615 gLiveSupport->putWindowPosition(scratchpadWindow); -
trunk/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx
r1869 r1895 110 110 treeView = Gtk::manage(widgetFactory->createTreeView(treeModel)); 111 111 treeView->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); 112 treeView->set_reorderable(true); 112 113 treeView->set_enable_search(false); 113 114 … … 169 170 audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 170 171 *getResourceUstring("upMenuItem"), 171 sigc::mem_fun(*this, 172 &ScratchpadWindow::onUpItem))); 172 sigc::mem_fun(*treeView, 173 &ZebraTreeView::onUpMenuOption))); 173 174 audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 174 175 *getResourceUstring("downMenuItem"), 175 sigc::mem_fun(*this, 176 &ScratchpadWindow::onDownItem))); 176 sigc::mem_fun(*treeView, 177 &ZebraTreeView::onDownMenuOption))); 177 178 audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 178 179 *getResourceUstring("removeMenuItem"), 179 sigc::mem_fun(*this, 180 &ScratchpadWindow::onRemoveItem))); 180 sigc::mem_fun(*treeView, 181 &ZebraTreeView::onRemoveMenuOption))); 181 182 audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 182 183 *getResourceUstring("cueMenuItem"), … … 214 215 playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 215 216 *getResourceUstring("upMenuItem"), 216 sigc::mem_fun(*this, 217 &ScratchpadWindow::onUpItem))); 217 sigc::mem_fun(*treeView, 218 &ZebraTreeView::onUpMenuOption))); 218 219 playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 219 220 *getResourceUstring("downMenuItem"), 220 sigc::mem_fun(*this, 221 &ScratchpadWindow::onDownItem))); 221 sigc::mem_fun(*treeView, 222 &ZebraTreeView::onDownMenuOption))); 222 223 playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 223 224 *getResourceUstring("removeMenuItem"), 224 sigc::mem_fun(*this, 225 &ScratchpadWindow::onRemoveItem))); 225 sigc::mem_fun(*treeView, 226 &ZebraTreeView::onRemoveMenuOption))); 226 227 playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem( 227 228 *getResourceUstring("cueMenuItem"), … … 245 246 property_window_position().set_value(Gtk::WIN_POS_NONE); 246 247 247 showContents();248 248 show_all_children(); 249 249 } … … 251 251 252 252 /*------------------------------------------------------------------------------ 253 * Show all audio clips254 *----------------------------------------------------------------------------*/255 void256 ScratchpadWindow :: showContents(void) throw ()257 {258 Ptr<GLiveSupport::PlayableList>::Ref scratchpadContents;259 GLiveSupport::PlayableList::iterator it;260 GLiveSupport::PlayableList::iterator end;261 Ptr<Playable>::Ref playable;262 Gtk::TreeModel::Row row;263 264 scratchpadContents = gLiveSupport->getScratchpadContents();265 it = scratchpadContents->begin();266 end = scratchpadContents->end();267 treeModel->clear();268 int rowNumber = 0;269 270 Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();271 272 while (it != end) {273 playable = *it;274 row = *(treeModel->append());275 276 row[modelColumns.playableColumn] = playable;277 switch (playable->getType()) {278 case Playable::AudioClipType:279 row[modelColumns.typeColumn] = widgetFactory->getPixbuf(280 WidgetFactory::audioClipIconImage);281 break;282 283 case Playable::PlaylistType:284 row[modelColumns.typeColumn] = widgetFactory->getPixbuf(285 WidgetFactory::playlistIconImage);286 break;287 288 default:289 break;290 }291 row[modelColumns.titleColumn] = Glib::Markup::escape_text(292 *playable->getTitle());293 row[modelColumns.rowNumberColumn] = rowNumber;294 295 ++it;296 ++rowNumber;297 }298 }299 300 301 /*------------------------------------------------------------------------------302 253 * Event handler for the add to playlist button getting clicked. 303 254 *----------------------------------------------------------------------------*/ … … 327 278 ScratchpadWindow :: onClearListButtonClicked (void) throw () 328 279 { 329 Ptr<GLiveSupport::PlayableList>::Ref 330 scratchpadContents = gLiveSupport->getScratchpadContents(); 331 scratchpadContents->clear(); 332 showContents(); 280 treeModel->clear(); 333 281 } 334 282 … … 349 297 Gtk::TreeIter ti = treeModel->get_iter(*iter); 350 298 if (ti) { 351 Ptr<Playable>::Ref playable = (*ti)[modelColumns.playableColumn]; 352 removeItem(playable->getId()); 299 treeModel->erase(ti); 353 300 } 354 301 } 355 showContents();356 302 } 357 303 … … 405 351 ScratchpadWindow :: selectRow(Ptr<Playable>::Ref playable) throw () 406 352 { 407 Gtk::TreeModel::const_iterator it er;353 Gtk::TreeModel::const_iterator it; 407 353 408 for (iter = treeModel->children().begin(); 409 iter != treeModel->children().end(); ++iter) { 354 for (it = treeModel->children().begin(); 355 it != treeModel->children().end(); ++it) { 410 356 411 Gtk::TreeRow row = *it er;357 Gtk::TreeRow row = *it; 411 357 Ptr<Playable>::Ref currentPlayable = row[modelColumns.playableColumn]; 412 358 … … 416 362 Glib::RefPtr<Gtk::TreeView::Selection> 417 363 selection = treeView->get_selection(); 418 selection->select(it er);364 selection->select(it); 418 364 return; 419 365 } … … 424 370 425 371 /*------------------------------------------------------------------------------ 426 * Event handler for the Up menu item selected from the entry context menu 427 *----------------------------------------------------------------------------*/ 428 void 429 ScratchpadWindow :: onUpItem(void) throw () 430 { 431 Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; 432 433 Ptr<GLiveSupport::PlayableList>::Ref scratchpadContents; 434 GLiveSupport::PlayableList::iterator it; 435 GLiveSupport::PlayableList::iterator end; 436 437 scratchpadContents = gLiveSupport->getScratchpadContents(); 438 it = scratchpadContents->begin(); 439 end = scratchpadContents->end(); 440 while (it != end) { 441 Ptr<Playable>::Ref p= *it; 442 443 if (*p->getId() == *playable->getId()) { 444 // move one up, and insert the same before that 445 if (it == scratchpadContents->begin()) { 446 break; 447 } 448 scratchpadContents->insert(--it, playable); 449 // move back to what we've found, and erase it 450 scratchpadContents->erase(++it); 451 452 showContents(); 453 break; 454 } 455 456 it++; 457 } 458 459 selectRow(playable); 460 } 461 462 463 /*------------------------------------------------------------------------------ 464 * Event handler for the Down menu item selected from the entry context menu 465 *----------------------------------------------------------------------------*/ 466 void 467 ScratchpadWindow :: onDownItem(void) throw () 468 { 469 Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; 470 471 Ptr<GLiveSupport::PlayableList>::Ref scratchpadContents; 472 GLiveSupport::PlayableList::iterator it; 473 GLiveSupport::PlayableList::iterator end; 474 475 scratchpadContents = gLiveSupport->getScratchpadContents(); 476 it = scratchpadContents->begin(); 477 end = scratchpadContents->end(); 478 while (it != end) { 479 Ptr<Playable>::Ref p= *it; 480 481 if (*p->getId() == *playable->getId()) { 482 // move two down, and insert the same before that 483 ++it; 484 if (it == end) { 485 break; 486 } 487 scratchpadContents->insert(++it, playable); 488 // move back to what we've found, and erase it 489 --it; 490 --it; 491 scratchpadContents->erase(--it); 492 493 showContents(); 494 break; 495 } 496 497 it++; 498 } 499 500 selectRow(playable); 501 } 502 503 504 /*------------------------------------------------------------------------------ 505 * Event handler for the Remove menu item selected from the entry context menu 372 * Remove an item from the Scratchpad 506 373 *----------------------------------------------------------------------------*/ 507 374 void 508 ScratchpadWindow :: onRemoveItem(void)throw ()375 ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw () 508 375 { 509 Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; 510 removeItem(playable->getId()); 511 showContents(); 512 } 376 Gtk::TreeModel::const_iterator it; 513 377 378 for (it = treeModel->children().begin(); 379 it != treeModel->children().end(); ++it) { 514 380 515 /*------------------------------------------------------------------------------ 516 * Remove an item from the Scratchpad 517 *----------------------------------------------------------------------------*/ 518 void 519 ScratchpadWindow :: removeItem(Ptr<const UniqueId>::Ref id) throw () 520 { 521 Ptr<GLiveSupport::PlayableList>::Ref scratchpadContents; 522 GLiveSupport::PlayableList::iterator it; 523 GLiveSupport::PlayableList::iterator end; 524 525 scratchpadContents = gLiveSupport->getScratchpadContents(); 526 it = scratchpadContents->begin(); 527 end = scratchpadContents->end(); 528 while (it != end) { 529 Ptr<Playable>::Ref playable = *it; 381 Gtk::TreeRow row = *it; 382 Ptr<Playable>::Ref currentPlayable = row[modelColumns.playableColumn]; 530 383 531 if (*playable->getId() == *id) { 532 scratchpadContents->erase(it); 533 break; 384 if (*id == *currentPlayable->getId()) { 385 treeModel->erase(it); 386 return; 534 387 } 535 536 it++;537 388 } 538 389 } … … 593 444 } 594 445 446 // TODO: this should be somewhere else; figure out where 595 447 Ptr<SchedulePlaylistWindow>::Ref scheduleWindow; 596 448 scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, … … 644 496 case KeyboardShortcut::moveItemUp : 645 497 if (isSelectionSingle()) { 646 onUpItem();498 treeView->onUpMenuOption(); 646 498 return true; 647 499 } … … 651 503 case KeyboardShortcut::moveItemDown : 652 504 if (isSelectionSingle()) { 653 onDownItem();505 treeView->onDownMenuOption(); 653 505 return true; 654 506 } 699 551 } 700 552 553 554 /*------------------------------------------------------------------------------ 555 * Add an item to the Scratchpad. 556 *----------------------------------------------------------------------------*/ 557 void 558 ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable) 559 throw () 560 { 561 removeItem(playable->getId()); 562 563 Gtk::TreeModel::Row row = *treeModel->prepend(); 564 565 row[modelColumns.rowNumberColumn] = 0; 566 row[modelColumns.playableColumn] = playable; 567 568 Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance(); 569 570 switch (playable->getType()) { 571 case Playable::AudioClipType: 572 row[modelColumns.typeColumn] = widgetFactory->getPixbuf( 573 WidgetFactory::audioClipIconImage); 574 break; 575 576 case Playable::PlaylistType: 577 row[modelColumns.typeColumn] = widgetFactory->getPixbuf( 578 WidgetFactory::playlistIconImage); 579 break; 580 } 581 582 row[modelColumns.titleColumn] = Glib::Markup::escape_text( 583 *playable->getTitle()); 584 585 // cache the item if it hasn't been cached yet 586 if (!playable->getToken()) { 587 gLiveSupport->acquirePlayable(playable->getId()); 588 } 589 } 590 591 592 /*------------------------------------------------------------------------------ 593 * Add an item to the Scratchpad. 594 *----------------------------------------------------------------------------*/ 595 void 596 ScratchpadWindow :: addItem(Ptr<UniqueId>::Ref id) 597 throw () 598 { 599 Ptr<Playable>::Ref playable = gLiveSupport->acquirePlayable(id); 600 addItem(playable); 601 } 602 603 604 /*------------------------------------------------------------------------------ 605 * Return the contents of the Scratchpad. 606 *----------------------------------------------------------------------------*/ 607 Ptr<Glib::ustring>::Ref 608 ScratchpadWindow :: contents(void) throw () 609 { 610 std::ostringstream contentsStream; 611 Gtk::TreeModel::const_iterator it; 612 613 for (it = treeModel->children().begin(); 614 it != treeModel->children().end(); ++it) { 615 Gtk::TreeRow row = *it; 616 Ptr<Playable>::Ref playable = row[modelColumns.playableColumn]; 617 contentsStream << playable->getId()->getId() << " "; 618 } 619 620 Ptr<Glib::ustring>::Ref contents(new Glib::ustring( 621 contentsStream.str() )); 622 return contents; 623 } 624 625 626 /*------------------------------------------------------------------------------ 627 * Restore the contents of the Scratchpad. 628 *----------------------------------------------------------------------------*/ 629 void 630 ScratchpadWindow :: restore(Ptr<Glib::ustring>::Ref contents) 631 throw () 632 { 633 std::istringstream contentsStream(contents->raw()); 634 Ptr<Playable>::Ref playable; 635 636 treeModel->clear(); 637 638 while (!contentsStream.eof()) { 639 UniqueId::IdType idValue; 640 Ptr<UniqueId>::Ref id; 641 642 contentsStream >> idValue; 643 if (contentsStream.fail()) { 644 break; 645 } else { 646 id.reset(new UniqueId(idValue)); 647 addItem(id); 648 } 649 } 650 } 651 -
trunk/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h
r1894 r1895 153 153 renumberRows(void) throw (); 154 154 155 /** 156 * Find the selected row. 157 * Returns the selected row (if the selection type is single), 158 * or the first selected row (if the selection type is multiple). 159 * May return 0 if no row is selected. 160 * 161 * @return an iterator pointing to the selected row; or 0. 162 */ 163 Gtk::TreeModel::iterator 164 getSelectedRow(void) throw (); 165 155 166 156 167 protected: -
trunk/livesupport/src/modules/widgets/src/ZebraTreeView.cxx
r1894 r1895 360 360 ZebraTreeView :: onUpMenuOption(void) throw () 361 361 { 362 Glib::RefPtr<Gtk::TreeView::Selection> selection = get_selection(); 363 Gtk::TreeModel::iterator iter = selection->get_selected(); 364 Glib::RefPtr<Gtk::ListStore> treeModel 362 Gtk::TreeModel::iterator iter = getSelectedRow(); 363 364 Glib::RefPtr<Gtk::ListStore> treeModel 365 365 = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(get_model()); 366 ZebraTreeModelColumnRecord 366 ZebraTreeModelColumnRecord modelColumns; 366 366 367 367 if (iter && iter != treeModel->children().begin()) { … … 385 385 ZebraTreeView :: onDownMenuOption(void) throw () 386 386 { 387 Glib::RefPtr<Gtk::TreeView::Selection> selection = get_selection(); 388 Gtk::TreeModel::iterator iter = selection->get_selected(); 389 Glib::RefPtr<Gtk::ListStore> treeModel 387 Gtk::TreeModel::iterator iter = getSelectedRow(); 388 389 Glib::RefPtr<Gtk::ListStore> treeModel 390 390 = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(get_model()); 391 ZebraTreeModelColumnRecord 391 ZebraTreeModelColumnRecord modelColumns; 391 391 392 392 if (iter) { … … 412 412 ZebraTreeView :: onRemoveMenuOption(void) throw () 413 413 { 414 Glib::RefPtr<Gtk::TreeView::Selection> selection = get_selection(); 415 Gtk::TreeModel::iterator iter = selection->get_selected(); 414 Gtk::TreeModel::iterator iter = getSelectedRow(); 416 415 417 416 if (iter) { … … 428 427 throw () 429 428 { 430 Glib::RefPtr<Gtk::ListStore> 429 Glib::RefPtr<Gtk::ListStore> treeModel 430 429 = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(get_model()); 431 ZebraTreeModelColumnRecord 430 ZebraTreeModelColumnRecord modelColumns; 431 430 432 Gtk::TreeModel::iterator later = iter; 431 Gtk::TreeModel::iterator later = iter; 432 431 433 432 int rowNumber = (*iter)[modelColumns.rowNumberColumn]; 444 443 445 444 /*------------------------------------------------------------------------------ 445 * Find the selected row. 446 *----------------------------------------------------------------------------*/ 447 Gtk::TreeModel::iterator 448 ZebraTreeView :: getSelectedRow(void) throw () 449 { 450 Glib::RefPtr<Gtk::TreeView::Selection> selection = get_selection(); 451 std::vector<Gtk::TreePath> selectedRows; 452 Gtk::TreeModel::iterator it; 453 454 switch (selection->get_mode()) { 455 case Gtk::SELECTION_SINGLE: 456 it = selection->get_selected(); 457 break; 458 459 case Gtk::SELECTION_MULTIPLE: 460 selectedRows = selection->get_selected_rows(); 461 if (selectedRows.size() > 0) { 462 it = get_model()->get_iter(selectedRows.front()); 463 } 464 break; 465 466 default: 467 break; 468 } 469 470 return it; 471 } 472 473 474 /*------------------------------------------------------------------------------ 446 475 * Event handler for the row_inserted signal. 447 476 *----------------------------------------------------------------------------*/