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