Allow client-side channel buffer merges, and associated changes.
[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     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
134
135 void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config)
136 {
137     BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
138     if (filter) {
139         filter->setConfig(config);
140         setConfig(config);
141         return;
142     }
143
144     if (model()) {
145         disconnect(this, 0, model(), 0);
146         disconnect(model(), 0, this, 0);
147     }
148
149     if (!model_) {
150         setModel(model_);
151     }
152     else {
153         BufferViewFilter *filter = new BufferViewFilter(model_, config);
154         setModel(filter);
155         connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
156     }
157     setConfig(config);
158 }
159
160
161 void BufferView::setConfig(BufferViewConfig *config)
162 {
163     if (_config == config)
164         return;
165
166     if (_config) {
167         disconnect(_config, 0, this, 0);
168     }
169
170     _config = config;
171     if (config) {
172         connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(setRootIndexForNetworkId(const NetworkId &)));
173         setRootIndexForNetworkId(config->networkId());
174     }
175     else {
176         setIndentation(10);
177         setRootIndex(QModelIndex());
178     }
179 }
180
181
182 void BufferView::setRootIndexForNetworkId(const NetworkId &networkId)
183 {
184     if (!networkId.isValid() || !model()) {
185         setIndentation(10);
186         setRootIndex(QModelIndex());
187     }
188     else {
189         setIndentation(5);
190         int networkCount = model()->rowCount();
191         QModelIndex child;
192         for (int i = 0; i < networkCount; i++) {
193             child = model()->index(i, 0);
194             if (networkId == model()->data(child, NetworkModel::NetworkIdRole).value<NetworkId>())
195                 setRootIndex(child);
196         }
197     }
198 }
199
200
201 void BufferView::joinChannel(const QModelIndex &index)
202 {
203     BufferInfo::Type bufferType = (BufferInfo::Type)index.data(NetworkModel::BufferTypeRole).value<int>();
204
205     if (bufferType != BufferInfo::ChannelBuffer)
206         return;
207
208     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
209
210     Client::userInput(bufferInfo, QString("/JOIN %1").arg(bufferInfo.bufferName()));
211 }
212
213
214 void BufferView::keyPressEvent(QKeyEvent *event)
215 {
216     if (event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) {
217         event->accept();
218         removeSelectedBuffers();
219     }
220     TreeViewTouch::keyPressEvent(event);
221 }
222
223
224 void BufferView::dropEvent(QDropEvent *event)
225 {
226     QModelIndex index = indexAt(event->pos());
227
228     QRect indexRect = visualRect(index);
229     QPoint cursorPos = event->pos();
230
231     // check if we're really _on_ the item and not indicating a move to just above or below the item
232     // Magic margin number for this is from QAbstractItemViewPrivate::position()
233     const int margin = 2;
234     if (cursorPos.y() - indexRect.top() < margin
235         || indexRect.bottom() - cursorPos.y() < margin)
236         return TreeViewTouch::dropEvent(event);
237
238     // If more than one buffer was being dragged, treat this as a rearrangement instead of a merge request
239     QList<QPair<NetworkId, BufferId> > bufferList = Client::networkModel()->mimeDataToBufferList(event->mimeData());
240     if (bufferList.count() != 1)
241         return TreeViewTouch::dropEvent(event);
242
243     // Get the Buffer ID of the buffer that was being dragged
244     BufferId bufferId2 = bufferList[0].second;
245
246     // Get the Buffer ID of the target buffer
247     BufferId bufferId1 = index.data(NetworkModel::BufferIdRole).value<BufferId>();
248
249     // If the source and target are the same buffer, this was an aborted rearrangement
250     if (bufferId1 == bufferId2)
251         return TreeViewTouch::dropEvent(event);
252
253     // Get index of buffer that was being dragged
254     QModelIndex index2 = Client::networkModel()->bufferIndex(bufferId2);
255
256     // If the buffer being dragged is a channel and we're still joined to it, treat this as a rearrangement
257     // This prevents us from being joined to a channel with no associated UI elements
258     if (index2.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && index2.data(NetworkModel::ItemActiveRole) == true)
259         return TreeViewTouch::dropEvent(event);
260
261     //If the source buffer is not mergeable(AKA not a Channel and not a Query), try rearranging instead
262     if (index2.data(NetworkModel::BufferTypeRole) != BufferInfo::ChannelBuffer && index2.data(NetworkModel::BufferTypeRole) != BufferInfo::QueryBuffer)
263         return TreeViewTouch::dropEvent(event);
264
265     // If the target buffer is not mergeable(AKA not a Channel and not a Query), try rearranging instead
266     if (index.data(NetworkModel::BufferTypeRole) != BufferInfo::ChannelBuffer && index.data(NetworkModel::BufferTypeRole) != BufferInfo::QueryBuffer)
267         return TreeViewTouch::dropEvent(event);
268
269     // Confirm that the user really wants to merge the buffers before doing so
270     int res = QMessageBox::question(0, tr("Merge buffers permanently?"),
271         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)),
272         QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
273     if (res == QMessageBox::Yes) {
274         Client::mergeBuffersPermanently(bufferId1, bufferId2);
275     }
276 }
277
278
279 void BufferView::removeSelectedBuffers(bool permanently)
280 {
281     if (!config())
282         return;
283
284     BufferId bufferId;
285     QSet<BufferId> removedRows;
286     foreach(QModelIndex index, selectionModel()->selectedIndexes()) {
287         if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
288             continue;
289
290         bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
291         if (removedRows.contains(bufferId))
292             continue;
293
294         removedRows << bufferId;
295     }
296
297     foreach(BufferId bufferId, removedRows) {
298         if (permanently)
299             config()->requestRemoveBufferPermanently(bufferId);
300         else
301             config()->requestRemoveBuffer(bufferId);
302     }
303 }
304
305
306 void BufferView::rowsInserted(const QModelIndex &parent, int start, int end)
307 {
308     TreeViewTouch::rowsInserted(parent, start, end);
309
310     // ensure that newly inserted network nodes are expanded per default
311     if (parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
312         return;
313
314     setExpandedState(parent);
315 }
316
317
318 void BufferView::on_layoutChanged()
319 {
320     int numNets = model()->rowCount(QModelIndex());
321     for (int row = 0; row < numNets; row++) {
322         QModelIndex networkIdx = model()->index(row, 0, QModelIndex());
323         setExpandedState(networkIdx);
324     }
325 }
326
327
328 void BufferView::on_configChanged()
329 {
330     Q_ASSERT(model());
331
332     // expand all active networks... collapse inactive ones... unless manually changed
333     QModelIndex networkIdx;
334     NetworkId networkId;
335     for (int row = 0; row < model()->rowCount(); row++) {
336         networkIdx = model()->index(row, 0);
337         if (model()->rowCount(networkIdx) ==  0)
338             continue;
339
340         networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
341         if (!networkId.isValid())
342             continue;
343
344         setExpandedState(networkIdx);
345     }
346
347     if (config()) {
348         // update selection to current one
349         Client::bufferModel()->synchronizeView(this);
350     }
351 }
352
353
354 void BufferView::storeExpandedState(const QModelIndex &networkIdx)
355 {
356     NetworkId networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
357
358     int oldState = 0;
359     if (isExpanded(networkIdx))
360         oldState |= WasExpanded;
361     if (model()->data(networkIdx, NetworkModel::ItemActiveRole).toBool())
362         oldState |= WasActive;
363
364     _expandedState[networkId] = oldState;
365 }
366
367
368 void BufferView::setExpandedState(const QModelIndex &networkIdx)
369 {
370     if (model()->data(networkIdx, NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
371         return;
372
373     if (model()->rowCount(networkIdx) == 0)
374         return;
375
376     NetworkId networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
377
378     bool networkActive = model()->data(networkIdx, NetworkModel::ItemActiveRole).toBool();
379     bool expandNetwork = networkActive;
380     if (_expandedState.contains(networkId)) {
381         int oldState = _expandedState[networkId];
382         if ((bool)(oldState & WasActive) == networkActive)
383             expandNetwork = (bool)(oldState & WasExpanded);
384     }
385
386     if (expandNetwork != isExpanded(networkIdx)) {
387         update(networkIdx);
388         setExpanded(networkIdx, expandNetwork);
389     }
390     storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state
391 }
392
393 #if QT_VERSION < 0x050000
394 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
395 {
396     TreeViewTouch::dataChanged(topLeft, bottomRight);
397 #else
398 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
399 {
400     TreeViewTouch::dataChanged(topLeft, bottomRight, roles);
401 #endif
402
403     // determine how many items have been changed and if any of them is a networkitem
404     // which just swichted from active to inactive or vice versa
405     if (topLeft.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
406         return;
407
408     for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
409         QModelIndex networkIdx = topLeft.sibling(i, 0);
410         setExpandedState(networkIdx);
411     }
412 }
413
414
415 void BufferView::toggleHeader(bool checked)
416 {
417     QAction *action = qobject_cast<QAction *>(sender());
418     header()->setSectionHidden((action->property("column")).toInt(), !checked);
419 }
420
421
422 void BufferView::contextMenuEvent(QContextMenuEvent *event)
423 {
424     QModelIndex index = indexAt(event->pos());
425     if (!index.isValid())
426         index = rootIndex();
427
428     QMenu contextMenu(this);
429
430     if (index.isValid()) {
431         addActionsToMenu(&contextMenu, index);
432     }
433
434     addFilterActions(&contextMenu, index);
435
436     if (!contextMenu.actions().isEmpty())
437         contextMenu.exec(QCursor::pos());
438 }
439
440
441 void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index)
442 {
443     QModelIndexList indexList = selectedIndexes();
444     // make sure the item we clicked on is first
445     indexList.removeAll(index);
446     indexList.prepend(index);
447
448     GraphicalUi::contextMenuActionProvider()->addActions(contextMenu, indexList, this, "menuActionTriggered", (bool)config());
449 }
450
451
452 void BufferView::addFilterActions(QMenu *contextMenu, const QModelIndex &index)
453 {
454     BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
455     if (filter) {
456         QList<QAction *> filterActions = filter->actions(index);
457         if (!filterActions.isEmpty()) {
458             contextMenu->addSeparator();
459             foreach(QAction *action, filterActions) {
460                 contextMenu->addAction(action);
461             }
462         }
463     }
464 }
465
466
467 void BufferView::menuActionTriggered(QAction *result)
468 {
469     ContextMenuActionProvider::ActionType type = (ContextMenuActionProvider::ActionType)result->data().toInt();
470     switch (type) {
471     case ContextMenuActionProvider::HideBufferTemporarily:
472         removeSelectedBuffers();
473         break;
474     case ContextMenuActionProvider::HideBufferPermanently:
475         removeSelectedBuffers(true);
476         break;
477     default:
478         return;
479     }
480 }
481
482
483 void BufferView::nextBuffer()
484 {
485     changeBuffer(Forward);
486 }
487
488
489 void BufferView::previousBuffer()
490 {
491     changeBuffer(Backward);
492 }
493
494
495 void BufferView::changeBuffer(Direction direction)
496 {
497     QModelIndex currentIndex = selectionModel()->currentIndex();
498     QModelIndex resultingIndex;
499
500     if (currentIndex.parent().isValid()) {
501         //If we are a child node just switch among siblings unless it's the first/last child
502         resultingIndex = currentIndex.sibling(currentIndex.row() + direction, 0);
503
504         if (!resultingIndex.isValid()) {
505             QModelIndex parent = currentIndex.parent();
506             if (direction == Backward)
507                 resultingIndex = parent;
508             else
509                 resultingIndex = parent.sibling(parent.row() + direction, 0);
510         }
511     }
512     else {
513         //If we have a toplevel node, try and get an adjacent child
514         if (direction == Backward) {
515             QModelIndex newParent = currentIndex.sibling(currentIndex.row() - 1, 0);
516             if (model()->hasChildren(newParent))
517                 resultingIndex = newParent.child(model()->rowCount(newParent) - 1, 0);
518             else
519                 resultingIndex = newParent;
520         }
521         else {
522             if (model()->hasChildren(currentIndex))
523                 resultingIndex = currentIndex.child(0, 0);
524             else
525                 resultingIndex = currentIndex.sibling(currentIndex.row() + 1, 0);
526         }
527     }
528
529     if (!resultingIndex.isValid())
530         return;
531
532     selectionModel()->setCurrentIndex(resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
533     selectionModel()->select(resultingIndex, QItemSelectionModel::ClearAndSelect);
534 }
535
536
537 void BufferView::wheelEvent(QWheelEvent *event)
538 {
539     if (ItemViewSettings().mouseWheelChangesBuffer() == (bool)(event->modifiers() & Qt::AltModifier))
540         return TreeViewTouch::wheelEvent(event);
541
542     int rowDelta = (event->delta() > 0) ? -1 : 1;
543     changeBuffer((Direction)rowDelta);
544 }
545
546
547 void BufferView::hideCurrentBuffer()
548 {
549     QModelIndex index = selectionModel()->currentIndex();
550     if (index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
551         return;
552
553     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
554
555     //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.
556     changeBuffer(Backward);
557
558     /*if(removedRows.contains(bufferId))
559       continue;
560
561     removedRows << bufferId;*/
562     /*if(permanently)
563       config()->requestRemoveBufferPermanently(bufferId);
564     else*/
565     config()->requestRemoveBuffer(bufferId);
566 }
567
568
569 QSize BufferView::sizeHint() const
570 {
571     return TreeViewTouch::sizeHint();
572
573     if (!model())
574         return TreeViewTouch::sizeHint();
575
576     if (model()->rowCount() == 0)
577         return QSize(120, 50);
578
579     int columnSize = 0;
580     for (int i = 0; i < model()->columnCount(); i++) {
581         if (!isColumnHidden(i))
582             columnSize += sizeHintForColumn(i);
583     }
584     return QSize(columnSize, 50);
585 }
586
587
588 // ****************************************
589 //  BufferViewDelgate
590 // ****************************************
591 class ColorsChangedEvent : public QEvent
592 {
593 public:
594     ColorsChangedEvent() : QEvent(QEvent::User) {};
595 };
596
597
598 BufferViewDelegate::BufferViewDelegate(QObject *parent)
599     : QStyledItemDelegate(parent)
600 {
601 }
602
603
604 void BufferViewDelegate::customEvent(QEvent *event)
605 {
606     if (event->type() != QEvent::User)
607         return;
608
609     event->accept();
610 }
611
612
613 bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
614 {
615     if (event->type() != QEvent::MouseButtonRelease)
616         return QStyledItemDelegate::editorEvent(event, model, option, index);
617
618     if (!(model->flags(index) & Qt::ItemIsUserCheckable))
619         return QStyledItemDelegate::editorEvent(event, model, option, index);
620
621     QVariant value = index.data(Qt::CheckStateRole);
622     if (!value.isValid())
623         return QStyledItemDelegate::editorEvent(event, model, option, index);
624
625     QStyleOptionViewItemV4 viewOpt(option);
626     initStyleOption(&viewOpt, index);
627
628     QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget);
629     QMouseEvent *me = static_cast<QMouseEvent *>(event);
630
631     if (me->button() != Qt::LeftButton || !checkRect.contains(me->pos()))
632         return QStyledItemDelegate::editorEvent(event, model, option, index);
633
634     Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
635     if (state == Qt::Unchecked)
636         state = Qt::PartiallyChecked;
637     else if (state == Qt::PartiallyChecked)
638         state = Qt::Checked;
639     else
640         state = Qt::Unchecked;
641     model->setData(index, state, Qt::CheckStateRole);
642     return true;
643 }
644
645
646 // ==============================
647 //  BufferView Dock
648 // ==============================
649 BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
650     : QDockWidget(parent),
651     _active(false),
652     _title(config->bufferViewName())
653 {
654     setObjectName("BufferViewDock-" + QString::number(config->bufferViewId()));
655     toggleViewAction()->setData(config->bufferViewId());
656     setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
657     connect(config, SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(bufferViewRenamed(const QString &)));
658     updateTitle();
659 }
660
661
662 void BufferViewDock::updateTitle()
663 {
664     QString title = _title;
665     if (isActive())
666         title.prepend(QString::fromUtf8("• "));
667     setWindowTitle(title);
668 }
669
670
671 void BufferViewDock::setActive(bool active)
672 {
673     if (active != isActive()) {
674         _active = active;
675         updateTitle();
676         if (active)
677             raise();  // for tabbed docks
678     }
679 }
680
681
682 void BufferViewDock::bufferViewRenamed(const QString &newName)
683 {
684     _title = newName;
685     updateTitle();
686     toggleViewAction()->setText(newName);
687 }
688
689
690 int BufferViewDock::bufferViewId() const
691 {
692     BufferView *view = bufferView();
693     if (!view)
694         return 0;
695
696     if (view->config())
697         return view->config()->bufferViewId();
698     else
699         return 0;
700 }
701
702
703 BufferViewConfig *BufferViewDock::config() const
704 {
705     BufferView *view = bufferView();
706     if (!view)
707         return 0;
708     else
709         return view->config();
710 }