1 /**
2  * Copyright (C) 2006 by Koos Vriezen <koos.vriezen@gmail.com>
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License version 2 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Library General Public License
14  *  along with this library; see the file COPYING.LIB.  If not, write to
15  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
16  *  Boston, MA 02110-1301, USA.
17  **/
18 
19 #include <stdio.h>
20 
21 #include "config-kmplayer.h"
22 // include files for Qt
23 #include <qapplication.h>
24 #include <qclipboard.h>
25 #include <QMenu>
26 #include <QIcon>
27 #include <qdrawutil.h>
28 #include <qpainter.h>
29 #include <QAbstractItemDelegate>
30 #include <QDropEvent>
31 #include <qstyle.h>
32 #include <QDropEvent>
33 #include <QPalette>
34 #include <qregexp.h>
35 #include <QtCore/QAbstractItemModel>
36 #include <QtCore/QList>
37 #include <QItemSelectionModel>
38 #include <QMimeData>
39 
40 #include <kiconloader.h>
41 #include <kstandardaction.h>
42 #include <kfinddialog.h>
43 #include <kfind.h>
44 #include <kaction.h>
45 #include <klocale.h>
46 #include <kdebug.h>
47 #include <KActionCollection>
48 
49 #include "playlistview.h"
50 #include "playmodel.h"
51 #include "kmplayerview.h"
52 #include "kmplayercontrolpanel.h"
53 
54 #include <kurl.h>
55 
56 using namespace KMPlayer;
57 
58 namespace {
59 
60 class ItemDelegate : public QAbstractItemDelegate
61 {
62     QAbstractItemDelegate *default_item_delegate;
63     PlayListView *playlist_view;
64 public:
ItemDelegate(PlayListView * v,QAbstractItemDelegate * def)65     ItemDelegate (PlayListView *v, QAbstractItemDelegate *def)
66         : QAbstractItemDelegate (v),
67           default_item_delegate (def),
68           playlist_view (v)
69     {}
createEditor(QWidget * w,const QStyleOptionViewItem & o,const QModelIndex & i) const70     QWidget *createEditor (QWidget *w, const QStyleOptionViewItem &o, const QModelIndex &i) const
71     {
72         return default_item_delegate->createEditor (w, o, i);
73     }
editorEvent(QEvent * e,QAbstractItemModel * m,const QStyleOptionViewItem & o,const QModelIndex & i)74     bool editorEvent (QEvent *e, QAbstractItemModel *m, const QStyleOptionViewItem &o, const QModelIndex &i)
75     {
76         return default_item_delegate->editorEvent (e, m, o, i);
77     }
eventFilter(QObject * editor,QEvent * event)78     bool eventFilter (QObject *editor, QEvent *event)
79     {
80         return default_item_delegate->eventFilter (editor, event);
81     }
paint(QPainter * p,const QStyleOptionViewItem & o,const QModelIndex & i) const82     void paint (QPainter *p, const QStyleOptionViewItem &o, const QModelIndex &i) const
83     {
84         playlist_view->paintCell (default_item_delegate, p, o, i);
85     }
setEditorData(QWidget * e,const QModelIndex & i) const86     void setEditorData (QWidget *e, const QModelIndex &i) const
87     {
88         default_item_delegate->setEditorData (e, i);
89     }
setModelData(QWidget * e,QAbstractItemModel * m,const QModelIndex & i) const90     void setModelData (QWidget *e, QAbstractItemModel *m, const QModelIndex &i) const
91     {
92         default_item_delegate->setModelData (e, m, i);
93     }
sizeHint(const QStyleOptionViewItem & o,const QModelIndex & i) const94     QSize sizeHint (const QStyleOptionViewItem &o, const QModelIndex &i) const
95     {
96         QSize size = default_item_delegate->sizeHint (o, i);
97         return QSize (size.width (), size.height () + 2);
98     }
updateEditorGeometry(QWidget * e,const QStyleOptionViewItem & o,const QModelIndex & i) const99     void updateEditorGeometry (QWidget *e, const QStyleOptionViewItem &o, const QModelIndex &i) const
100     {
101         default_item_delegate->updateEditorGeometry (e, o, i);
102     }
103 };
104 
105 }
106 
107 //-----------------------------------------------------------------------------
108 
PlayListView(QWidget *,View * view,KActionCollection * ac)109 KDE_NO_CDTOR_EXPORT PlayListView::PlayListView (QWidget *, View *view, KActionCollection * ac)
110  : //QTreeView (parent),
111    m_view (view),
112    m_find_dialog (0L),
113    m_active_color (30, 0, 255),
114    last_drag_tree_id (0),
115    m_ignore_expanded (false) {
116     setHeaderHidden (true);
117     setSortingEnabled (false);
118     setAcceptDrops (true);
119     setDragDropMode (DragDrop);
120     setDropIndicatorShown (true);
121     setDragDropOverwriteMode (false);
122     setRootIsDecorated (false);
123     setSelectionMode (SingleSelection);
124     setSelectionBehavior (SelectItems);
125     setIndentation (4);
126     //setItemsExpandable (false);
127     //setAnimated (true);
128     setUniformRowHeights (true);
129     setItemDelegateForColumn (0, new ItemDelegate (this, itemDelegate ()));
130     setEditTriggers (EditKeyPressed);
131     QPalette palette;
132     palette.setColor (foregroundRole(), QColor (0, 0, 0));
133     palette.setColor (backgroundRole(), QColor (0xB2, 0xB2, 0xB2));
134     setPalette (palette);
135     m_itemmenu = new QMenu (this);
136     m_find = KStandardAction::find (this, SLOT (slotFind ()), this);
137     m_find_next = KStandardAction::findNext (this, SLOT(slotFindNext()), this);
138     m_find_next->setEnabled (false);
139     m_edit_playlist_item = ac->addAction ("edit_playlist_item");
140     m_edit_playlist_item->setText (i18n ("Edit &item"));
141     connect (m_edit_playlist_item, SIGNAL (triggered (bool)),
142              this, SLOT (renameSelected ()));
143     connect (this, SIGNAL (expanded (const QModelIndex&)),
144              this, SLOT (slotItemExpanded (const QModelIndex&)));
145 }
146 
~PlayListView()147 KDE_NO_CDTOR_EXPORT PlayListView::~PlayListView () {
148 }
149 
paintCell(const QAbstractItemDelegate * def,QPainter * p,const QStyleOptionViewItem & o,const QModelIndex i)150 void PlayListView::paintCell (const QAbstractItemDelegate *def,
151         QPainter *p, const QStyleOptionViewItem &o, const QModelIndex i)
152 {
153     PlayItem *item = playModel ()->itemFromIndex (i);
154     if (item) {
155         TopPlayItem *ritem = item->rootItem ();
156         if (ritem == item) {
157             QStyleOptionViewItem option (o);
158             if (currentIndex () == i) {
159                 // no highlighting for the top items
160                 option.palette.setColor (QPalette::Highlight,
161                         topLevelWidget()->palette ().color (QPalette::Background));
162                 option.palette.setColor (QPalette::HighlightedText,
163                         topLevelWidget()->palette ().color (QPalette::Foreground));
164             } else {
165                 p->fillRect(o.rect, QBrush (topLevelWidget()->palette ().color (QPalette::Background)));
166                 option.palette.setColor (QPalette::Text,
167                         topLevelWidget()->palette ().color (QPalette::Foreground));
168             }
169             option.font = topLevelWidget()->font ();
170             def->paint (p, option, i);
171             qDrawShadeRect (p, o.rect, option.palette, !isExpanded (i));
172         } else {
173             QStyleOptionViewItem option (o);
174             option.palette.setColor (QPalette::Text,
175                     item->node && item->node->state == Node::state_began
176                     ? m_active_color
177                     : palette ().color (foregroundRole ()));
178             def->paint (p, option, i);
179         }
180     }
181 }
182 
modelUpdating(const QModelIndex &)183 void PlayListView::modelUpdating (const QModelIndex &)
184 {
185     m_ignore_expanded = true;
186     QModelIndex index = selectionModel()->currentIndex ();
187     if (index.isValid ())
188         closePersistentEditor(index);
189 }
190 
modelUpdated(const QModelIndex & r,const QModelIndex & i,bool sel,bool exp)191 void PlayListView::modelUpdated (const QModelIndex& r, const QModelIndex& i, bool sel, bool exp)
192 {
193     if (exp)
194         setExpanded (r, true);
195     if (i.isValid () && sel) {
196         setCurrentIndex (i);
197         scrollTo (i);
198     }
199     m_find_next->setEnabled (!!m_current_find_elm);
200     TopPlayItem *ti = static_cast<TopPlayItem*>(playModel()->itemFromIndex(r));
201     if (!ti->have_dark_nodes && ti->show_all_nodes && !m_view->editMode())
202         toggleShowAllNodes (); // redo, because the user can't change it anymore
203     m_ignore_expanded = false;
204 }
205 
index(PlayItem * item) const206 QModelIndex PlayListView::index (PlayItem *item) const
207 {
208     return playModel ()->indexFromItem (item);
209 }
210 
selectItem(const QString &)211 void PlayListView::selectItem(const QString&) {
212     /*QTreeWidgetItem * item = selectedItem ();
213     if (item && item->text (0) == txt)
214         return;
215     item = findItem (txt, 0);
216     if (item) {
217         item->setSelected (true);
218         //ensureItemVisible (item);
219     }*/
220 }
221 
222 /*KDE_NO_EXPORT Q3DragObject * PlayListView::dragObject () {
223     PlayItem * item = static_cast <PlayItem *> (selectedItem ());
224     if (item && item->node) {
225         QString txt = item->node->isPlayable ()
226             ? item->node->mrl ()->src : item->node->outerXML ();
227         Q3TextDrag * drag = new Q3TextDrag (txt, this);
228         last_drag_tree_id = rootItem (item)->id;
229         m_last_drag = item->node;
230         drag->setIcon (*item->pixmap (0));
231         if (!item->node->isPlayable ())
232             drag->setSubtype ("xml");
233         return drag;
234     }
235     return 0;
236 }*/
237 
setFont(const QFont & fnt)238 KDE_NO_EXPORT void PlayListView::setFont (const QFont & fnt) {
239     //setTreeStepSize (QFontMetrics (fnt).boundingRect ('m').width ());
240     QTreeView::setFont (fnt);
241 }
242 
contextMenuEvent(QContextMenuEvent * event)243 KDE_NO_EXPORT void PlayListView::contextMenuEvent (QContextMenuEvent *event)
244 {
245     PlayItem *item = playModel ()->itemFromIndex (indexAt (event->pos ()));
246     if (item) {
247         if (item->node || item->attribute) {
248             TopPlayItem *ritem = item->rootItem ();
249             if (m_itemmenu->actions().count () > 0) {
250                 m_find->setVisible (false);
251                 m_find_next->setVisible (false);
252                 m_itemmenu->clear ();
253             }
254             m_itemmenu->addAction (QIcon::fromTheme("edit-copy"),
255                     i18n ("&Copy to Clipboard"),
256                     this, SLOT (copyToClipboard ()));
257             if (item->attribute ||
258                     (item->node && (item->node->isPlayable () ||
259                                     item->node->isDocument ()) &&
260                      item->node->mrl ()->bookmarkable))
261                 m_itemmenu->addAction (QIcon::fromTheme("bookmark-new"),
262                         i18n ("&Add Bookmark"),
263                         this, SLOT (addBookMark ()));
264             if (ritem->have_dark_nodes) {
265                 QAction *act = m_itemmenu->addAction (i18n ("&Show all"),
266                         this, SLOT (toggleShowAllNodes ()));
267                 act->setCheckable (true);
268                 act->setChecked (ritem->show_all_nodes);
269             }
270             if (item->item_flags & Qt::ItemIsEditable)
271                 m_itemmenu->addAction (m_edit_playlist_item);
272             m_itemmenu->addSeparator ();
273             m_find->setVisible (true);
274             m_find_next->setVisible (true);
275             emit prepareMenu (item, m_itemmenu);
276             m_itemmenu->exec (event->globalPos ());
277         }
278     } else {
279         m_view->controlPanel ()->popupMenu->exec (event->globalPos ());
280     }
281 }
282 
slotItemExpanded(const QModelIndex & index)283 void PlayListView::slotItemExpanded (const QModelIndex &index) {
284     int chlds = model ()->rowCount (index);
285     if (chlds > 0) {
286         if (!m_ignore_expanded && chlds == 1)
287             setExpanded (model ()->index (0, 0, index), true);
288         scrollTo (model ()->index (chlds - 1, 0, index));
289         scrollTo (index);
290     }
291 }
292 
rootItem(int id) const293 TopPlayItem * PlayListView::rootItem (int id) const {
294     PlayItem *root_item = playModel ()->rootItem ();
295     return static_cast<TopPlayItem*>(root_item->child (id));
296 }
297 
selectedItem() const298 PlayItem *PlayListView::selectedItem () const {
299     return playModel ()->itemFromIndex (currentIndex ());
300 }
301 
copyToClipboard()302 void PlayListView::copyToClipboard () {
303     QModelIndex i = currentIndex ();
304     if (i.isValid ()) {
305         QString s;
306 
307         QVariant v = i.data (PlayModel::UrlRole);
308         if (v.isValid ())
309             s = v.toString ();
310         if (s.isEmpty ())
311             s = i.data ().toString ();
312 
313         if (!s.isEmpty ())
314             QApplication::clipboard()->setText (s);
315     }
316 }
317 
addBookMark()318 void PlayListView::addBookMark () {
319     PlayItem * item = selectedItem ();
320     if (item->node) {
321         Mrl * mrl = item->node->mrl ();
322         KURL url (mrl ? mrl->src : QString (item->node->nodeName ()));
323         emit addBookMark (mrl->title.isEmpty () ? url.prettyUrl () : mrl->title, url.url ());
324     }
325 }
326 
toggleShowAllNodes()327 void PlayListView::toggleShowAllNodes () {
328     PlayItem * cur_item = selectedItem ();
329     if (cur_item) {
330         TopPlayItem *ritem = cur_item->rootItem ();
331         showAllNodes (ritem, !ritem->show_all_nodes);
332     }
333 }
334 
showAllNodes(TopPlayItem * ri,bool show)335 KDE_NO_EXPORT void PlayListView::showAllNodes(TopPlayItem *ri, bool show) {
336     if (ri && ri->show_all_nodes != show) {
337         PlayItem * cur_item = selectedItem ();
338         ri->show_all_nodes = show;
339         playModel()->updateTree (ri->id, ri->node, cur_item->node, true, false);
340         if (m_current_find_elm &&
341                 ri->node->document() == m_current_find_elm->document() &&
342                 !ri->show_all_nodes) {
343             if (!m_current_find_elm->role (RolePlaylist))
344                 m_current_find_elm = 0L;
345             m_current_find_attr = 0L;
346         }
347     }
348 }
349 
isDragValid(QDropEvent * event)350 KDE_NO_EXPORT bool PlayListView::isDragValid (QDropEvent *event) {
351     if (event->source() == this &&
352             event->mimeData ()
353                 ->hasFormat ("application/x-qabstractitemmodeldatalist"))
354         return true;
355     if (event->mimeData()->hasFormat ("text/uri-list")) {
356         KUrl::List uriList = KUrl::List::fromMimeData (event->mimeData ());
357         if (!uriList.isEmpty ())
358             return true;
359     } else {
360         QString text = event->mimeData ()->text ();
361         if (!text.isEmpty () && KUrl (text).isValid ())
362             return true;
363     }
364     return false;
365 }
366 
dragMoveEvent(QDragMoveEvent * event)367 KDE_NO_EXPORT void PlayListView::dragMoveEvent (QDragMoveEvent *event)
368 {
369     PlayItem *itm = playModel ()->itemFromIndex (indexAt (event->pos ()));
370     if (itm) {
371         TopPlayItem *ritem = itm->rootItem ();
372         if (ritem->itemFlags() & PlayModel::AllowDrops && isDragValid (event))
373             event->accept ();
374         else
375             event->ignore();
376     }
377 }
378 
dragEnterEvent(QDragEnterEvent * event)379 void PlayListView::dragEnterEvent (QDragEnterEvent *event)
380 {
381     if (isDragValid (event))
382         event->accept ();
383     else
384         event->ignore();
385 }
386 
dropEvent(QDropEvent * event)387 KDE_NO_EXPORT void PlayListView::dropEvent (QDropEvent *event) {
388     PlayItem *itm = playModel ()->itemFromIndex (indexAt (event->pos ()));
389     if (itm && itm->node) {
390         TopPlayItem *ritem = itm->rootItem ();
391         NodePtr n = itm->node;
392         if (ritem->id > 0 || n->isDocument ()) {
393             emit dropped (event, itm);
394         } else {
395             KUrl::List uris = KUrl::List::fromMimeData (event->mimeData());
396             if (uris.isEmpty ()) {
397                 KUrl url (event->mimeData ()->text ());
398                 if (url.isValid ())
399                     uris.push_back (url);
400             }
401             if (uris.size () > 0) {
402                 bool as_child = itm->node->hasChildNodes ();
403                 NodePtr d = n->document ();
404                 for (int i = uris.size (); i > 0; i--) {
405                     Node * ni = new KMPlayer::GenericURL (d, uris[i-1].url ());
406                     if (as_child)
407                         n->insertBefore (ni, n->firstChild ());
408                     else
409                         n->parentNode ()->insertBefore (ni, n->nextSibling ());
410                 }
411                 PlayItem * citem = selectedItem ();
412                 NodePtr cn;
413                 if (citem)
414                     cn = citem->node;
415                 m_ignore_expanded = true;
416                 citem = playModel()->updateTree (ritem, cn);
417                 modelUpdated (playModel()->indexFromItem(ritem), playModel()->indexFromItem(citem), true, false);
418                 m_ignore_expanded = false;
419             }
420         }
421     }
422 }
423 
playModel() const424 PlayModel *PlayListView::playModel () const
425 {
426     return static_cast <PlayModel *> (model());
427 }
428 
429 
renameSelected()430 KDE_NO_EXPORT void PlayListView::renameSelected () {
431     QModelIndex i = currentIndex ();
432     PlayItem *itm = playModel ()->itemFromIndex (i);
433     if (itm && itm->item_flags & Qt::ItemIsEditable)
434         edit (i);
435 }
436 
slotCurrentItemChanged(QModelIndex,QModelIndex)437 KDE_NO_EXPORT void PlayListView::slotCurrentItemChanged (QModelIndex /*cur*/, QModelIndex)
438 {
439     //TopPlayItem * ri = rootItem (qitem);
440     //setItemsRenameable (ri && (ri->item_flagsTreeEdit) && ri != qitem);
441 }
442 
slotFind()443 KDE_NO_EXPORT void PlayListView::slotFind () {
444     /*m_current_find_elm = 0L;
445     if (!m_find_dialog) {
446         m_find_dialog = new KFindDialog (this, KFind::CaseSensitive);
447         m_find_dialog->setHasSelection (false);
448         connect(m_find_dialog, SIGNAL(okClicked ()), this, SLOT(slotFindOk ()));
449     } else
450         m_find_dialog->setPattern (QString ());
451     m_find_dialog->show ();*/
452 }
453 
454 /*static QTreeWidgetItem * findNodeInTree (NodePtr n, QTreeWidgetItem * item) {
455     //kDebug () << "item:" << item->text (0) << " n:" << (n ? n->nodeName () : "null" );
456     PlayItem * pi = static_cast <PlayItem *> (item);
457     if (!n || !pi->node)
458         return 0L;
459     if (n == pi->node)
460         return item;
461     for (int i = 0; i < item->childCount (); ++i) {
462         //kDebug () << "ci:" << ci->text (0) << " n:" << n->nodeName ();
463         QTreeWidgetItem *vi = findNodeInTree (n, item->child (i));
464         if (vi)
465             return vi;
466     }
467     return 0L;
468 
469 }*/
470 
slotFindOk()471 KDE_NO_EXPORT void PlayListView::slotFindOk () {
472     /*if (!m_find_dialog)
473         return;
474     m_find_dialog->hide ();
475     long opt = m_find_dialog->options ();
476     current_find_tree_id = 0;
477     if (opt & KFind::FromCursor && currentItem ()) {
478         PlayItem * lvi = selectedItem ();
479         if (lvi && lvi->node) {
480              m_current_find_elm = lvi->node;
481              current_find_tree_id = rootItem (lvi)->id;
482         } else if (lvi && lvi->attribute) {
483             PlayItem*pi=static_cast<PlayItem*>(currentItem()->parent());
484             if (pi) {
485                 m_current_find_attr = lvi->attribute;
486                 m_current_find_elm = pi->node;
487             }
488         }
489     } else if (!(opt & KFind::FindIncremental))
490         m_current_find_elm = 0L;
491     if (!m_current_find_elm && topLevelItemCount ())
492         m_current_find_elm = static_cast <PlayItem*>(topLevelItem(0))->node;
493     if (m_current_find_elm)
494         slotFindNext ();*/
495 }
496 
497 /* A bit tricky, but between the find's PlayItems might be gone, so
498  * try to match on the generated tree following the source's document tree
499  */
slotFindNext()500 KDE_NO_EXPORT void PlayListView::slotFindNext () {
501     /*if (!m_find_dialog)
502         return;
503     QString str = m_find_dialog->pattern();
504     if (!m_current_find_elm || str.isEmpty ())
505         return;
506     long opt = m_find_dialog->options ();
507     QRegExp regexp;
508     if (opt & KFind::RegularExpression)
509         regexp = QRegExp (str);
510     bool cs = (opt & KFind::CaseSensitive);
511     bool found = false;
512     Node *node = NULL, *n = m_current_find_elm.ptr ();
513     TopPlayItem * ri = rootItem (current_find_tree_id);
514     while (!found && n) {
515         if (ri->show_all_nodes || n->role (RolePlaylist)) {
516             bool elm = n->isElementNode ();
517             QString val = n->nodeName ();
518             if (elm && !ri->show_all_nodes) {
519                 Mrl * mrl = n->mrl ();
520                 if (mrl) {
521                     if (mrl->title.isEmpty ()) {
522                         if (!mrl->src.isEmpty())
523                             val = KURL(mrl->src).prettyUrl();
524                     } else
525                         val = mrl->title;
526                 }
527             } else if (!elm)
528                 val = n->nodeValue ();
529             if (((opt & KFind::RegularExpression) &&
530                     val.find (regexp, 0) > -1) ||
531                     (!(opt & KFind::RegularExpression) &&
532                      val.find (str, 0, cs) > -1)) {
533                 node = n;
534                 m_current_find_attr = 0L;
535                 found = true;
536             } else if (elm && ri->show_all_nodes) {
537                 for (Attribute *a = static_cast <Element *> (n)->attributes ().first (); a; a = a->nextSibling ()) {
538                     QString attr = a->name ().toString ();
539                     if (((opt & KFind::RegularExpression) &&
540                                 (attr.find (regexp, 0) || a->value ().find (regexp, 0) > -1)) ||
541                                 (!(opt & KFind::RegularExpression) &&
542                                  (attr.find (str, 0, cs) > -1 || a->value ().find (str, 0, cs) > -1))) {
543                         node = n;
544                         m_current_find_attr = a;
545                         found = true;
546                         break;
547                     }
548                 }
549             }
550         }
551         if (n) { //set pointer to next
552             if (opt & KFind::FindBackwards) {
553                 if (n->lastChild ()) {
554                     n = n->lastChild ();
555                 } else if (n->previousSibling ()) {
556                     n = n->previousSibling ();
557                 } else {
558                     for (n = n->parentNode (); n; n = n->parentNode ())
559                         if (n->previousSibling ()) {
560                             n = n->previousSibling ();
561                             break;
562                         }
563                     while (!n && current_find_tree_id > 0) {
564                         ri = rootItem (--current_find_tree_id);
565                         if (ri)
566                             n = ri->node;
567                     }
568                 }
569             } else {
570                 if (n->firstChild ()) {
571                     n = n->firstChild ();
572                 } else if (n->nextSibling ()) {
573                     n = n->nextSibling ();
574                 } else {
575                     for (n = n->parentNode (); n; n = n->parentNode ())
576                         if (n->nextSibling ()) {
577                             n = n->nextSibling ();
578                             break;
579                         }
580                     while (!n) {
581                         ri = rootItem (++current_find_tree_id);
582                         if (!ri)
583                             break;
584                         n = ri->node;
585                     }
586                 }
587             }
588         }
589     }
590     m_current_find_elm = n;
591     kDebug () << " search for " << str << "=" << (node ? node->nodeName () : "not found") << " next:" << (n ? n->nodeName () : " not found");
592     if (found) {
593         QTreeWidgetItem *fc = findNodeInTree (node, ri);
594         if (!fc) {
595             m_current_find_elm = 0L;
596             kDebug () << "node not found in tree tree:" << ri->id;
597         } else {
598             fc->setSelected (true);
599             if (m_current_find_attr && fc->childCount () && fc->child (0)->childCount ())
600                 scrollToItem (fc->child (0)->child (0));
601             scrollToItem (fc);
602         }
603     }
604     m_find_next->setEnabled (!!m_current_find_elm);*/
605 }
606 
607 #include "playlistview.moc"
608