Fix expanding networks in Chat Monitor settings
[quassel.git] / src / uisupport / bufferview.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2015 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include "bufferview.h"
22
23 #include <QApplication>
24 #include <QAction>
25 #include <QFlags>
26 #include <QHeaderView>
27 #include <QLineEdit>
28 #include <QMenu>
29 #include <QMessageBox>
30 #include <QSet>
31
32 #include "action.h"
33 #include "buffermodel.h"
34 #include "bufferviewfilter.h"
35 #include "buffersettings.h"
36 #include "buffersyncer.h"
37 #include "client.h"
38 #include "contextmenuactionprovider.h"
39 #include "graphicalui.h"
40 #include "network.h"
41 #include "networkmodel.h"
42 #include "contextmenuactionprovider.h"
43
44 /*****************************************
45 * The TreeView showing the Buffers
46 *****************************************/
47 // Please be carefull when reimplementing methods which are used to inform the view about changes to the data
48 // to be on the safe side: call QTreeView's method aswell (or TreeViewTouch's)
49 BufferView::BufferView(QWidget *parent)
50     : TreeViewTouch(parent)
51 {
52     connect(this, SIGNAL(collapsed(const QModelIndex &)), SLOT(storeExpandedState(const QModelIndex &)));
53     connect(this, SIGNAL(expanded(const QModelIndex &)), SLOT(storeExpandedState(const QModelIndex &)));
54
55     setSelectionMode(QAbstractItemView::ExtendedSelection);
56
57     QAbstractItemDelegate *oldDelegate = itemDelegate();
58     BufferViewDelegate *tristateDelegate = new BufferViewDelegate(this);
59     setItemDelegate(tristateDelegate);
60     delete oldDelegate;
61 }
62
63
64 void BufferView::init()
65 {
66     header()->setContextMenuPolicy(Qt::ActionsContextMenu);
67     hideColumn(1);
68     hideColumn(2);
69     setIndentation(10);
70
71     // New entries will be expanded automatically when added; no need to call expandAll()
72
73     header()->hide(); // nobody seems to use this anyway
74
75     // breaks with Qt 4.8
76     if (QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10!
77         setAnimated(true);
78
79     // FIXME This is to workaround bug #663
80     setUniformRowHeights(true);
81
82 #ifndef QT_NO_DRAGANDDROP
83     setDragEnabled(true);
84     setAcceptDrops(true);
85     setDropIndicatorShown(true);
86 #endif
87
88     setSortingEnabled(true);
89     sortByColumn(0, Qt::AscendingOrder);
90
91     // activated() fails on X11 and Qtopia at least
92 #if defined Q_WS_QWS || defined Q_WS_X11
93     disconnect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
94     connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(joinChannel(QModelIndex)));
95 #else
96     // afaik this is better on Mac and Windows
97     disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex)));
98     connect(this, SIGNAL(activated(QModelIndex)), SLOT(joinChannel(QModelIndex)));
99 #endif
100 }
101
102
103 void BufferView::setModel(QAbstractItemModel *model)
104 {
105     delete selectionModel();
106
107     TreeViewTouch::setModel(model);
108     init();
109     // remove old Actions
110     QList<QAction *> oldactions = header()->actions();
111     foreach(QAction *action, oldactions) {
112         header()->removeAction(action);
113         action->deleteLater();
114     }
115
116     if (!model)
117         return;
118
119     QString sectionName;
120     QAction *showSection;
121     for (int i = 1; i < model->columnCount(); i++) {
122         sectionName = (model->headerData(i, Qt::Horizontal, Qt::DisplayRole)).toString();
123         showSection = new QAction(sectionName, header());
124         showSection->setCheckable(true);
125         showSection->setChecked(!isColumnHidden(i));
126         showSection->setProperty("column", i);
127         connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
128         header()->addAction(showSection);
129     }
130
131     connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged()));
132
133     // Make sure collapsation is correct after setting a model
134     // This might not be needed here, only in BufferView::setFilteredModel().  If issues arise, just
135     // move down to setFilteredModel (which calls this function).
136     setExpandedState();
137 }
138
139
140 void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config)
141 {
142     BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
143     if (filter) {
144         filter->setConfig(config);
145         setConfig(config);
146         return;
147     }
148
149     if (model()) {
150         disconnect(this, 0, model(), 0);
151         disconnect(model(), 0, this, 0);
152     }
153
154     if (!model_) {
155         setModel(model_);
156     }
157     else {
158         BufferViewFilter *filter = new BufferViewFilter(model_, config);
159         setModel(filter);
160         connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
161     }
162     setConfig(config);
163 }
164
165
166 void BufferView::setConfig(BufferViewConfig *config)
167 {
168     if (_config == config)
169         return;
170
171     if (_config) {
172         disconnect(_config, 0, this, 0);
173     }
174
175     _config = config;
176     if (config) {
177         connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(setRootIndexForNetworkId(const NetworkId &)));
178         setRootIndexForNetworkId(config->networkId());
179     }
180     else {
181         setIndentation(10);
182         setRootIndex(QModelIndex());
183     }
184 }
185
186
187 void BufferView::setRootIndexForNetworkId(const NetworkId &networkId)
188 {
189     if (!networkId.isValid() || !model()) {
190         setIndentation(10);
191         setRootIndex(QModelIndex());
192     }
193     else {
194         setIndentation(5);
195         int networkCount = model()->rowCount();
196         QModelIndex child;
197         for (int i = 0; i < networkCount; i++) {
198             child = model()->index(i, 0);
199             if (networkId == model()->data(child, NetworkModel::NetworkIdRole).value<NetworkId>())
200                 setRootIndex(child);
201         }
202     }
203 }
204
205
206 void BufferView::joinChannel(const QModelIndex &index)
207 {
208     BufferInfo::Type bufferType = (BufferInfo::Type)index.data(NetworkModel::BufferTypeRole).value<int>();
209
210     if (bufferType != BufferInfo::ChannelBuffer)
211         return;
212
213     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
214
215     Client::userInput(bufferInfo, QString("/JOIN %1").arg(bufferInfo.bufferName()));
216 }
217
218
219 void BufferView::keyPressEvent(QKeyEvent *event)
220 {
221     if (event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) {
222         event->accept();
223         removeSelectedBuffers();
224     }
225     TreeViewTouch::keyPressEvent(event);
226 }
227
228
229 void BufferView::dropEvent(QDropEvent *event)
230 {
231     QModelIndex index = indexAt(event->pos());
232
233     QRect indexRect = visualRect(index);
234     QPoint cursorPos = event->pos();
235
236     // check if we're really _on_ the item and not indicating a move to just above or below the item
237     // Magic margin number for this is from QAbstractItemViewPrivate::position()
238     const int margin = 2;
239     if (cursorPos.y() - indexRect.top() < margin
240         || indexRect.bottom() - cursorPos.y() < margin)
241         return TreeViewTouch::dropEvent(event);
242
243     // If more than one buffer was being dragged, treat this as a rearrangement instead of a merge request
244     QList<QPair<NetworkId, BufferId> > bufferList = Client::networkModel()->mimeDataToBufferList(event->mimeData());
245     if (bufferList.count() != 1)
246         return TreeViewTouch::dropEvent(event);
247
248     // Get the Buffer ID of the buffer that was being dragged
249     BufferId bufferId2 = bufferList[0].second;
250
251     // Get the Buffer ID of the target buffer
252     BufferId bufferId1 = index.data(NetworkModel::BufferIdRole).value<BufferId>();
253
254     // If the source and target are the same buffer, this was an aborted rearrangement
255     if (bufferId1 == bufferId2)
256         return TreeViewTouch::dropEvent(event);
257
258     // Get index of buffer that was being dragged
259     QModelIndex index2 = Client::networkModel()->bufferIndex(bufferId2);
260
261     // If the buffer being dragged is a channel and we're still joined to it, treat this as a rearrangement
262     // This prevents us from being joined to a channel with no associated UI elements
263     if (index2.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && index2.data(NetworkModel::ItemActiveRole) == true)
264         return TreeViewTouch::dropEvent(event);
265
266     //If the source buffer is not mergeable(AKA not a Channel and not a Query), try rearranging instead
267     if (index2.data(NetworkModel::BufferTypeRole) != BufferInfo::ChannelBuffer && index2.data(NetworkModel::BufferTypeRole) != BufferInfo::QueryBuffer)
268         return TreeViewTouch::dropEvent(event);
269
270     // If the target buffer is not mergeable(AKA not a Channel and not a Query), try rearranging instead
271     if (index.data(NetworkModel::BufferTypeRole) != BufferInfo::ChannelBuffer && index.data(NetworkModel::BufferTypeRole) != BufferInfo::QueryBuffer)
272         return TreeViewTouch::dropEvent(event);
273
274     // Confirm that the user really wants to merge the buffers before doing so
275     int res = QMessageBox::question(0, tr("Merge buffers permanently?"),
276         tr("Do you want to merge the buffer \"%1\" permanently into buffer \"%2\"?\n This cannot be reversed!").arg(Client::networkModel()->bufferName(bufferId2)).arg(Client::networkModel()->bufferName(bufferId1)),
277         QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
278     if (res == QMessageBox::Yes) {
279         Client::mergeBuffersPermanently(bufferId1, bufferId2);
280     }
281 }
282
283
284 void BufferView::removeSelectedBuffers(bool permanently)
285 {
286     if (!config())
287         return;
288
289     BufferId bufferId;
290     QSet<BufferId> removedRows;
291     foreach(QModelIndex index, selectionModel()->selectedIndexes()) {
292         if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
293             continue;
294
295         bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
296         if (removedRows.contains(bufferId))
297             continue;
298
299         removedRows << bufferId;
300     }
301
302     foreach(BufferId bufferId, removedRows) {
303         if (permanently)
304             config()->requestRemoveBufferPermanently(bufferId);
305         else
306             config()->requestRemoveBuffer(bufferId);
307     }
308 }
309
310
311 void BufferView::rowsInserted(const QModelIndex &parent, int start, int end)
312 {
313     TreeViewTouch::rowsInserted(parent, start, end);
314
315     // ensure that newly inserted network nodes are expanded per default
316     if (parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
317         return;
318
319     setExpandedState(parent);
320 }
321
322
323 void BufferView::on_layoutChanged()
324 {
325     int numNets = model()->rowCount(QModelIndex());
326     for (int row = 0; row < numNets; row++) {
327         QModelIndex networkIdx = model()->index(row, 0, QModelIndex());
328         setExpandedState(networkIdx);
329     }
330 }
331
332
333 void BufferView::on_configChanged()
334 {
335     Q_ASSERT(model());
336
337     // Expand/collapse as needed
338     setExpandedState();
339
340     if (config()) {
341         // update selection to current one
342         Client::bufferModel()->synchronizeView(this);
343     }
344 }
345
346
347 void BufferView::setExpandedState()
348 {
349     // Expand all active networks, collapse inactive ones... unless manually changed
350     QModelIndex networkIdx;
351     NetworkId networkId;
352     for (int row = 0; row < model()->rowCount(); row++) {
353         networkIdx = model()->index(row, 0);
354         if (model()->rowCount(networkIdx) ==  0)
355             continue;
356
357         networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
358         if (!networkId.isValid())
359             continue;
360
361         setExpandedState(networkIdx);
362     }
363 }
364
365
366 void BufferView::storeExpandedState(const QModelIndex &networkIdx)
367 {
368     NetworkId networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
369
370     int oldState = 0;
371     if (isExpanded(networkIdx))
372         oldState |= WasExpanded;
373     if (model()->data(networkIdx, NetworkModel::ItemActiveRole).toBool())
374         oldState |= WasActive;
375
376     _expandedState[networkId] = oldState;
377 }
378
379
380 void BufferView::setExpandedState(const QModelIndex &networkIdx)
381 {
382     if (model()->data(networkIdx, NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
383         return;
384
385     if (model()->rowCount(networkIdx) == 0)
386         return;
387
388     NetworkId networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
389
390     bool networkActive = model()->data(networkIdx, NetworkModel::ItemActiveRole).toBool();
391     bool expandNetwork = networkActive;
392     if (_expandedState.contains(networkId)) {
393         int oldState = _expandedState[networkId];
394         if ((bool)(oldState & WasActive) == networkActive)
395             expandNetwork = (bool)(oldState & WasExpanded);
396     }
397
398     if (expandNetwork != isExpanded(networkIdx)) {
399         update(networkIdx);
400         setExpanded(networkIdx, expandNetwork);
401     }
402     storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state
403 }
404
405 #if QT_VERSION < 0x050000
406 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
407 {
408     TreeViewTouch::dataChanged(topLeft, bottomRight);
409 #else
410 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
411 {
412     TreeViewTouch::dataChanged(topLeft, bottomRight, roles);
413 #endif
414
415     // determine how many items have been changed and if any of them is a networkitem
416     // which just swichted from active to inactive or vice versa
417     if (topLeft.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
418         return;
419
420     for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
421         QModelIndex networkIdx = topLeft.sibling(i, 0);
422         setExpandedState(networkIdx);
423     }
424 }
425
426
427 void BufferView::toggleHeader(bool checked)
428 {
429     QAction *action = qobject_cast<QAction *>(sender());
430     header()->setSectionHidden((action->property("column")).toInt(), !checked);
431 }
432
433
434 void BufferView::contextMenuEvent(QContextMenuEvent *event)
435 {
436     QModelIndex index = indexAt(event->pos());
437     if (!index.isValid())
438         index = rootIndex();
439
440     QMenu contextMenu(this);
441
442     if (index.isValid()) {
443         addActionsToMenu(&contextMenu, index);
444     }
445
446     addFilterActions(&contextMenu, index);
447
448     if (!contextMenu.actions().isEmpty())
449         contextMenu.exec(QCursor::pos());
450 }
451
452
453 void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index)
454 {
455     QModelIndexList indexList = selectedIndexes();
456     // make sure the item we clicked on is first
457     indexList.removeAll(index);
458     indexList.prepend(index);
459
460     GraphicalUi::contextMenuActionProvider()->addActions(contextMenu, indexList, this, "menuActionTriggered", (bool)config());
461 }
462
463
464 void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index)
465 {
466     BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
467     if (filter) {
468         QList<QAction *> filterActions = filter->actions(index);
469         if (!filterActions.isEmpty()) {
470             contextMenu->addSeparator();
471             foreach(QAction *action, filterActions) {
472                 contextMenu->addAction(action);
473             }
474         }
475     }
476 }
477
478
479 void BufferView::menuActionTriggered(QAction *result)
480 {
481     ContextMenuActionProvider::ActionType type = (ContextMenuActionProvider::ActionType)result->data().toInt();
482     switch (type) {
483     case ContextMenuActionProvider::HideBufferTemporarily:
484         removeSelectedBuffers();
485         break;
486     case ContextMenuActionProvider::HideBufferPermanently:
487         removeSelectedBuffers(true);
488         break;
489     default:
490         return;
491     }
492 }
493
494
495 void BufferView::nextBuffer()
496 {
497     changeBuffer(Forward);
498 }
499
500
501 void BufferView::previousBuffer()
502 {
503     changeBuffer(Backward);
504 }
505
506
507 void BufferView::changeBuffer(Direction direction)
508 {
509     QModelIndex currentIndex = selectionModel()->currentIndex();
510     QModelIndex resultingIndex;
511
512     if (currentIndex.parent().isValid()) {
513         //If we are a child node just switch among siblings unless it's the first/last child
514         resultingIndex = currentIndex.sibling(currentIndex.row() + direction, 0);
515
516         if (!resultingIndex.isValid()) {
517             QModelIndex parent = currentIndex.parent();
518             if (direction == Backward)
519                 resultingIndex = parent;
520             else
521                 resultingIndex = parent.sibling(parent.row() + direction, 0);
522         }
523     }
524     else {
525         //If we have a toplevel node, try and get an adjacent child
526         if (direction == Backward) {
527             QModelIndex newParent = currentIndex.sibling(currentIndex.row() - 1, 0);
528             if (model()->hasChildren(newParent))
529                 resultingIndex = newParent.child(model()->rowCount(newParent) - 1, 0);
530             else
531                 resultingIndex = newParent;
532         }
533         else {
534             if (model()->hasChildren(currentIndex))
535                 resultingIndex = currentIndex.child(0, 0);
536             else
537                 resultingIndex = currentIndex.sibling(currentIndex.row() + 1, 0);
538         }
539     }
540
541     if (!resultingIndex.isValid())
542         return;
543
544     selectionModel()->setCurrentIndex(resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
545     selectionModel()->select(resultingIndex, QItemSelectionModel::ClearAndSelect);
546 }
547
548
549 void BufferView::wheelEvent(QWheelEvent *event)
550 {
551     if (ItemViewSettings().mouseWheelChangesBuffer() == (bool)(event->modifiers() & Qt::AltModifier))
552         return TreeViewTouch::wheelEvent(event);
553
554     int rowDelta = (event->delta() > 0) ? -1 : 1;
555     changeBuffer((Direction)rowDelta);
556 }
557
558
559 void BufferView::hideCurrentBuffer()
560 {
561     QModelIndex index = selectionModel()->currentIndex();
562     if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
563         return;
564
565     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
566
567     //The check above means we won't be looking at a network, which should always be the first row, so we can just go backwards.
568     changeBuffer(Backward);
569
570     /*if(removedRows.contains(bufferId))
571       continue;
572
573     removedRows << bufferId;*/
574     /*if(permanently)
575       config()->requestRemoveBufferPermanently(bufferId);
576     else*/
577     config()->requestRemoveBuffer(bufferId);
578 }
579
580
581 QSize BufferView::sizeHint() const
582 {
583     return TreeViewTouch::sizeHint();
584
585     if (!model())
586         return TreeViewTouch::sizeHint();
587
588     if (model()->rowCount() == 0)
589         return QSize(120, 50);
590
591     int columnSize = 0;
592     for (int i = 0; i < model()->columnCount(); i++) {
593         if (!isColumnHidden(i))
594             columnSize += sizeHintForColumn(i);
595     }
596     return QSize(columnSize, 50);
597 }
598
599
600 // ****************************************
601 //  BufferViewDelgate
602 // ****************************************
603 class ColorsChangedEvent : public QEvent
604 {
605 public:
606     ColorsChangedEvent() : QEvent(QEvent::User) {};
607 };
608
609
610 BufferViewDelegate::BufferViewDelegate(QObject *parent)
611     : QStyledItemDelegate(parent)
612 {
613 }
614
615
616 void BufferViewDelegate::customEvent(QEvent *event)
617 {
618     if (event->type() != QEvent::User)
619         return;
620
621     event->accept();
622 }
623
624
625 bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
626 {
627     if (event->type() != QEvent::MouseButtonRelease)
628         return QStyledItemDelegate::editorEvent(event, model, option, index);
629
630     if (!(model->flags(index) & Qt::ItemIsUserCheckable))
631         return QStyledItemDelegate::editorEvent(event, model, option, index);
632
633     QVariant value = index.data(Qt::CheckStateRole);
634     if (!value.isValid())
635         return QStyledItemDelegate::editorEvent(event, model, option, index);
636
637 #if QT_VERSION < 0x050000
638     QStyleOptionViewItemV4 viewOpt(option);
639 #else
640     QStyleOptionViewItem viewOpt(option);
641 #endif
642     initStyleOption(&viewOpt, index);
643
644     QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget);
645     QMouseEvent *me = static_cast<QMouseEvent *>(event);
646
647     if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
648         return QStyledItemDelegate::editorEvent(event, model, option, index);
649
650     Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
651     if (state == Qt::Unchecked)
652         state = Qt::PartiallyChecked;
653     else if (state == Qt::PartiallyChecked)
654         state = Qt::Checked;
655     else
656         state = Qt::Unchecked;
657     model->setData(index, state, Qt::CheckStateRole);
658     return true;
659 }
660
661
662 // ==============================
663 //  BufferView Dock
664 // ==============================
665 BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
666     : QDockWidget(parent),
667     _active(false),
668     _title(config->bufferViewName())
669 {
670     setObjectName("BufferViewDock-" + QString::number(config->bufferViewId()));
671     toggleViewAction()->setData(config->bufferViewId());
672     setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
673     connect(config, SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(bufferViewRenamed(const QString &)));
674     updateTitle();
675 }
676
677
678 void BufferViewDock::updateTitle()
679 {
680     QString title = _title;
681     if (isActive())
682         title.prepend(QString::fromUtf8("• "));
683     setWindowTitle(title);
684 }
685
686
687 void BufferViewDock::setActive(bool active)
688 {
689     if (active != isActive()) {
690         _active = active;
691         updateTitle();
692         if (active)
693             raise();  // for tabbed docks
694     }
695 }
696
697
698 void BufferViewDock::bufferViewRenamed(const QString &newName)
699 {
700     _title = newName;
701     updateTitle();
702     toggleViewAction()->setText(newName);
703 }
704
705
706 int BufferViewDock::bufferViewId() const
707 {
708     BufferView *view = bufferView();
709     if (!view)
710         return 0;
711
712     if (view->config())
713         return view->config()->bufferViewId();
714     else
715         return 0;
716 }
717
718
719 BufferViewConfig *BufferViewDock::config() const
720 {
721     BufferView *view = bufferView();
722     if (!view)
723         return 0;
724     else
725         return view->config();
726 }