8751c93e4b4c81053baa249b821cdce7b36be6c5
[quassel.git] / src / uisupport / bufferview.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-08 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include "bufferview.h"
22
23 #include "buffermodel.h"
24 #include "bufferviewfilter.h"
25 #include "buffersettings.h"
26 #include "buffersyncer.h"
27 #include "client.h"
28 #include "iconloader.h"
29 #include "mappedselectionmodel.h"
30 #include "network.h"
31 #include "networkmodel.h"
32
33 #include "uisettings.h"
34
35 #include <QAction>
36 #include <QFlags>
37 #include <QHeaderView>
38 #include <QInputDialog>
39 #include <QLineEdit>
40 #include <QMenu>
41 #include <QMessageBox>
42 #include <QSet>
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
49 BufferView::BufferView(QWidget *parent)
50   : QTreeView(parent),
51     showChannelList(tr("Show Channel List"), this),
52     _connectNetAction(tr("Connect"), this),
53     _disconnectNetAction(tr("Disconnect"), this),
54     _joinChannelAction(tr("Join Channel"), this),
55
56     _joinBufferAction(tr("Join"), this),
57     _partBufferAction(tr("Part"), this),
58     _hideBufferTemporarilyAction(tr("Hide buffers"), this),
59     _hideBufferPermanentlyAction(tr("Hide buffers permanently"), this),
60     _removeBufferAction(tr("Delete buffer"), this),
61     _ignoreListAction(tr("Ignore list"), this),
62
63     _hideJoinAction(tr("Join Events"), this),
64     _hidePartAction(tr("Part Events"), this),
65     _hideQuitAction(tr("Quit Events"), this),
66     _hideModeAction(tr("Mode Events"), this)
67
68 {
69   _hideJoinAction.setCheckable(true);
70   _hidePartAction.setCheckable(true);
71   _hideQuitAction.setCheckable(true);
72   _hideModeAction.setCheckable(true);
73   _ignoreListAction.setEnabled(false);
74
75   showChannelList.setIcon(SmallIcon("format-list-unordered"));
76
77   connect(this, SIGNAL(collapsed(const QModelIndex &)), this, SLOT(on_collapse(const QModelIndex &)));
78   connect(this, SIGNAL(expanded(const QModelIndex &)), this, SLOT(on_expand(const QModelIndex &)));
79
80   setSelectionMode(QAbstractItemView::ExtendedSelection);
81 }
82
83 void BufferView::init() {
84   setIndentation(10);
85   header()->setContextMenuPolicy(Qt::ActionsContextMenu);
86   hideColumn(1);
87   hideColumn(2);
88   expandAll();
89
90   setAnimated(true);
91
92 #ifndef QT_NO_DRAGANDDROP
93   setDragEnabled(true);
94   setAcceptDrops(true);
95   setDropIndicatorShown(true);
96 #endif
97
98   setSortingEnabled(true);
99   sortByColumn(0, Qt::AscendingOrder);
100
101   // activated() fails on X11 and Qtopia at least
102 #if defined Q_WS_QWS or defined Q_WS_X11
103   connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(joinChannel(QModelIndex)));
104 #else
105   // afaik this is better on Mac and Windows
106   connect(this, SIGNAL(activated(QModelIndex)), SLOT(joinChannel(QModelIndex)));
107 #endif
108 }
109
110 void BufferView::setModel(QAbstractItemModel *model) {
111   delete selectionModel();
112
113   QTreeView::setModel(model);
114   init();
115   // remove old Actions
116   QList<QAction *> oldactions = header()->actions();
117   foreach(QAction *action, oldactions) {
118     header()->removeAction(action);
119     action->deleteLater();
120   }
121
122   if(!model)
123     return;
124
125   QString sectionName;
126   QAction *showSection;
127   for(int i = 1; i < model->columnCount(); i++) {
128     sectionName = (model->headerData(i, Qt::Horizontal, Qt::DisplayRole)).toString();
129     showSection = new QAction(sectionName, header());
130     showSection->setCheckable(true);
131     showSection->setChecked(!isColumnHidden(i));
132     showSection->setProperty("column", i);
133     connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
134     header()->addAction(showSection);
135   }
136
137 }
138
139 void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config) {
140   BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
141   if(filter) {
142     filter->setConfig(config);
143     setConfig(config);
144     return;
145   }
146
147   if(model()) {
148     disconnect(this, 0, model(), 0);
149     disconnect(model(), 0, this, 0);
150   }
151
152   if(!model_) {
153     setModel(model_);
154   } else {
155     BufferViewFilter *filter = new BufferViewFilter(model_, config);
156     setModel(filter);
157     connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
158   }
159   setConfig(config);
160 }
161
162 void BufferView::setSelectionModel(QItemSelectionModel *selectionModel) {
163   if(QTreeView::selectionModel())
164     disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
165                model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
166
167   QTreeView::setSelectionModel(selectionModel);
168   BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
169   if(filter) {
170     connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
171             filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
172   }
173 }
174
175 void BufferView::setConfig(BufferViewConfig *config) {
176   if(_config == config)
177     return;
178
179   if(_config) {
180     disconnect(_config, 0, this, 0);
181   }
182
183   _config = config;
184   if(config) {
185     connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(setRootIndexForNetworkId(const NetworkId &)));
186     setRootIndexForNetworkId(config->networkId());
187   } else {
188     setRootIndex(QModelIndex());
189   }
190 }
191
192 void BufferView::setRootIndexForNetworkId(const NetworkId &networkId) {
193   if(!networkId.isValid() || !model()) {
194     setRootIndex(QModelIndex());
195   } else {
196     int networkCount = model()->rowCount();
197     QModelIndex child;
198     for(int i = 0; i < networkCount; i++) {
199       child = model()->index(i, 0);
200       if(networkId == model()->data(child, NetworkModel::NetworkIdRole).value<NetworkId>())
201         setRootIndex(child);
202     }
203   }
204 }
205
206 void BufferView::joinChannel(const QModelIndex &index) {
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 void BufferView::keyPressEvent(QKeyEvent *event) {
218   if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) {
219     event->accept();
220     removeSelectedBuffers();
221   }
222   QTreeView::keyPressEvent(event);
223 }
224
225 void BufferView::removeSelectedBuffers(bool permanently) {
226   if(!config())
227     return;
228
229   BufferId bufferId;
230   QSet<BufferId> removedRows;
231   foreach(QModelIndex index, selectionModel()->selectedIndexes()) {
232     if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
233       continue;
234
235     bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
236     if(removedRows.contains(bufferId))
237       continue;
238
239     removedRows << bufferId;
240
241     if(permanently)
242       config()->requestRemoveBufferPermanently(bufferId);
243     else
244       config()->requestRemoveBuffer(bufferId);
245   }
246 }
247
248 void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) {
249   QTreeView::rowsInserted(parent, start, end);
250
251   // ensure that newly inserted network nodes are expanded per default
252   if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
253     return;
254
255   if(model()->rowCount(parent) == 1 && parent.data(NetworkModel::ItemActiveRole) == true) {
256     // without updating the parent the expand will have no effect... Qt Bug?
257     update(parent);
258     expand(parent);
259   }
260 }
261
262 void BufferView::on_configChanged() {
263   Q_ASSERT(model());
264
265   // expand all active networks... collapse inactive ones... unless manually changed
266   QModelIndex networkIdx;
267   NetworkId networkId;
268   for(int row = 0; row < model()->rowCount(); row++) {
269     networkIdx = model()->index(row, 0);
270     if(model()->rowCount(networkIdx) ==  0)
271       continue;
272
273     networkId = model()->data(networkIdx, NetworkModel::NetworkIdRole).value<NetworkId>();
274     if(!networkId.isValid())
275       continue;
276
277     update(networkIdx);
278
279     bool expandNetwork = false;
280     if(_expandedState.contains(networkId))
281       expandNetwork = _expandedState[networkId];
282     else
283       expandNetwork = model()->data(networkIdx, NetworkModel::ItemActiveRole).toBool();
284
285     if(expandNetwork)
286       expand(networkIdx);
287     else
288       collapse(networkIdx);
289   }
290
291   // update selection to current one
292   MappedSelectionModel *mappedSelectionModel = qobject_cast<MappedSelectionModel *>(selectionModel());
293   if(!config() || !mappedSelectionModel)
294     return;
295
296   mappedSelectionModel->mappedSetCurrentIndex(Client::bufferModel()->standardSelectionModel()->currentIndex(), QItemSelectionModel::Current);
297   mappedSelectionModel->mappedSelect(Client::bufferModel()->standardSelectionModel()->selection(), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
298 }
299
300 void BufferView::on_collapse(const QModelIndex &index) {
301   storeExpandedState(index.data(NetworkModel::NetworkIdRole).value<NetworkId>(), false);
302 }
303
304 void BufferView::on_expand(const QModelIndex &index) {
305   storeExpandedState(index.data(NetworkModel::NetworkIdRole).value<NetworkId>(), true);
306 }
307
308 void BufferView::storeExpandedState(NetworkId networkId, bool expanded) {
309   _expandedState[networkId] = expanded;
310 }
311
312 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
313   QTreeView::dataChanged(topLeft, bottomRight);
314
315   // determine how many items have been changed and if any of them is a networkitem
316   // which just swichted from active to inactive or vice versa
317   if(topLeft.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
318     return;
319
320   for(int i = topLeft.row(); i <= bottomRight.row(); i++) {
321     QModelIndex networkIdx = topLeft.sibling(i, 0);
322     if(model()->rowCount(networkIdx) == 0)
323       continue;
324
325     bool isActive = networkIdx.data(NetworkModel::ItemActiveRole).toBool();
326 #ifdef SPUTDEV
327     if(isExpanded(networkIdx) != isActive) setExpanded(networkIdx, true);
328 #else
329     if(isExpanded(networkIdx) != isActive) setExpanded(networkIdx, isActive);
330 #endif
331   }
332 }
333
334 void BufferView::toggleHeader(bool checked) {
335   QAction *action = qobject_cast<QAction *>(sender());
336   header()->setSectionHidden((action->property("column")).toInt(), !checked);
337 }
338
339 bool BufferView::checkRequirements(const QModelIndex &index, ItemActiveStates requiredActiveState) {
340   if(!index.isValid())
341     return false;
342
343   ItemActiveStates isActive = index.data(NetworkModel::ItemActiveRole).toBool()
344     ? ActiveState
345     : InactiveState;
346
347   if(!(isActive & requiredActiveState))
348     return false;
349
350   return true;
351 }
352
353 void BufferView::addItemToMenu(QAction &action, QMenu &menu, const QModelIndex &index, ItemActiveStates requiredActiveState) {
354   if(checkRequirements(index, requiredActiveState)) {
355     menu.addAction(&action);
356     action.setVisible(true);
357   } else {
358     action.setVisible(false);
359   }
360 }
361
362 void BufferView::addItemToMenu(QAction &action, QMenu &menu, bool condition) {
363   if(condition) {
364     menu.addAction(&action);
365     action.setVisible(true);
366   } else {
367     action.setVisible(false);
368   }
369 }
370
371
372 void BufferView::addItemToMenu(QMenu &subMenu, QMenu &menu, const QModelIndex &index, ItemActiveStates requiredActiveState) {
373   if(checkRequirements(index, requiredActiveState)) {
374     menu.addMenu(&subMenu);
375     subMenu.setVisible(true);
376   } else {
377     subMenu.setVisible(false);
378   }
379 }
380
381 void BufferView::addSeparatorToMenu(QMenu &menu, const QModelIndex &index, ItemActiveStates requiredActiveState) {
382   if(checkRequirements(index, requiredActiveState)) {
383     menu.addSeparator();
384   }
385 }
386
387 QMenu *BufferView::createHideEventsSubMenu(QMenu &menu, BufferId bufferId) {
388   int filter = BufferSettings(bufferId).messageFilter();
389   _hideJoinAction.setChecked(filter & Message::Join);
390   _hidePartAction.setChecked(filter & Message::Part);
391   _hideQuitAction.setChecked(filter & Message::Quit);
392   _hideModeAction.setChecked(filter & Message::Mode);
393
394   QMenu *hideEventsMenu = menu.addMenu(tr("Hide Events"));
395   hideEventsMenu->addAction(&_hideJoinAction);
396   hideEventsMenu->addAction(&_hidePartAction);
397   hideEventsMenu->addAction(&_hideQuitAction);
398   hideEventsMenu->addAction(&_hideModeAction);
399   return hideEventsMenu;
400 }
401
402 void BufferView::contextMenuEvent(QContextMenuEvent *event) {
403   QModelIndex index = indexAt(event->pos());
404   if(!index.isValid())
405     index = rootIndex();
406   if(!index.isValid())
407     return;
408
409   const Network *network = Client::network(index.data(NetworkModel::NetworkIdRole).value<NetworkId>());
410   Q_CHECK_PTR(network);
411
412   QPixmap connectionStateIcon;
413   if(network) {
414     if(network->connectionState() == Network::Initialized) {
415       connectionStateIcon = SmallIcon("network-connect");
416     } else if(network->connectionState() == Network::Disconnected) {
417       connectionStateIcon = SmallIcon("network-disconnect");
418     } else {
419       connectionStateIcon = SmallIcon("network-wired");  // FIXME network-connecting
420     }
421   }
422
423   QMenu contextMenu(this);
424   NetworkModel::itemType itemType = static_cast<NetworkModel::itemType>(index.data(NetworkModel::ItemTypeRole).toInt());
425
426   switch(itemType) {
427   case NetworkModel::NetworkItemType:
428     showChannelList.setData(index.data(NetworkModel::NetworkIdRole));
429     _disconnectNetAction.setIcon(connectionStateIcon);
430     _connectNetAction.setIcon(connectionStateIcon);
431     addItemToMenu(showChannelList, contextMenu, index, ActiveState);
432     addItemToMenu(_disconnectNetAction, contextMenu, network->connectionState() != Network::Disconnected);
433     addItemToMenu(_connectNetAction, contextMenu, network->connectionState() == Network::Disconnected);
434     addSeparatorToMenu(contextMenu, index, ActiveState);
435     addItemToMenu(_joinChannelAction, contextMenu, index, ActiveState);
436     break;
437   case NetworkModel::BufferItemType:
438     {
439       BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
440       switch(bufferInfo.type()) {
441       case BufferInfo::ChannelBuffer:
442         addItemToMenu(_joinBufferAction, contextMenu, index, InactiveState);
443         addItemToMenu(_partBufferAction, contextMenu, index, ActiveState);
444         addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
445         addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
446         addItemToMenu(_removeBufferAction, contextMenu, index, InactiveState);
447         createHideEventsSubMenu(contextMenu, bufferInfo.bufferId());
448         addItemToMenu(_ignoreListAction, contextMenu);
449         break;
450       case BufferInfo::QueryBuffer:
451         addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
452         addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
453         addItemToMenu(_removeBufferAction, contextMenu);
454         createHideEventsSubMenu(contextMenu, bufferInfo.bufferId());
455         break;
456       default:
457         addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
458         addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
459         break;
460       }
461     }
462     break;
463   default:
464     return;
465   }
466
467   if(contextMenu.actions().isEmpty())
468     return;
469   QAction *result = contextMenu.exec(QCursor::pos());
470
471   // Handle Result
472   if(network && result == &_connectNetAction) {
473     network->requestConnect();
474     return;
475   }
476
477   if(network && result == &_disconnectNetAction) {
478     network->requestDisconnect();
479     return;
480   }
481
482   if(result == &_joinChannelAction) {
483     // FIXME no QInputDialog in Qtopia
484 #ifndef Q_WS_QWS
485     bool ok;
486     QString channelName = QInputDialog::getText(this, tr("Join Channel"), tr("Input channel name:"), QLineEdit::Normal, QString(), &ok);
487     if(ok && !channelName.isEmpty()) {
488       Client::instance()->userInput(BufferInfo::fakeStatusBuffer(index.data(NetworkModel::NetworkIdRole).value<NetworkId>()), QString("/J %1").arg(channelName));
489     }
490 #endif
491     return;
492   }
493
494   if(result == &_joinBufferAction) {
495     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
496     Client::instance()->userInput(bufferInfo, QString("/JOIN %1").arg(bufferInfo.bufferName()));
497     return;
498   }
499
500   if(result == &_partBufferAction) {
501     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
502     Client::instance()->userInput(bufferInfo, QString("/PART"));
503     return;
504   }
505
506   if(result == &_hideBufferTemporarilyAction) {
507     removeSelectedBuffers();
508     return;
509   }
510
511   if(result == &_hideBufferPermanentlyAction) {
512     removeSelectedBuffers(true);
513     return;
514   }
515
516   if(result == &_removeBufferAction) {
517     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
518     int res = QMessageBox::question(this, tr("Remove buffer permanently?"),
519                                     tr("Do you want to delete the buffer \"%1\" permanently? This will delete all related data, including all backlog "
520                                        "data, from the core's database!").arg(bufferInfo.bufferName()),
521                                         QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
522     if(res == QMessageBox::Yes) {
523       Client::removeBuffer(bufferInfo.bufferId());
524     }
525     return;
526   }
527
528   if(result == & _hideJoinAction) {
529     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
530     BufferSettings(bufferId).filterMessage(Message::Join, _hideJoinAction.isChecked());
531     return;
532   }
533   if(result == &_hidePartAction) {
534     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
535     BufferSettings(bufferId).filterMessage(Message::Part, _hidePartAction.isChecked());
536     return;
537   }
538   if(result == &_hideQuitAction) {
539     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
540     BufferSettings(bufferId).filterMessage(Message::Quit, _hideQuitAction.isChecked());
541     return;
542   }
543   if(result == &_hideModeAction) {
544     BufferId bufferId = index.data(NetworkModel::BufferIdRole).value<BufferId>();
545     BufferSettings(bufferId).filterMessage(Message::Mode, _hideModeAction.isChecked());
546     return;
547   }
548
549 }
550
551 void BufferView::wheelEvent(QWheelEvent* event) {
552   if(UiSettings().value("MouseWheelChangesBuffers", QVariant(true)).toBool() == (bool)(event->modifiers() & Qt::AltModifier))
553     return QTreeView::wheelEvent(event);
554
555   int rowDelta = ( event->delta() > 0 ) ? -1 : 1;
556   QModelIndex currentIndex = selectionModel()->currentIndex();
557   QModelIndex resultingIndex;
558   if( model()->hasIndex(  currentIndex.row() + rowDelta, currentIndex.column(), currentIndex.parent() ) )
559     {
560       resultingIndex = currentIndex.sibling( currentIndex.row() + rowDelta, currentIndex.column() );
561     }
562     else //if we scroll into a the parent node...
563       {
564         QModelIndex parent = currentIndex.parent();
565         QModelIndex aunt = parent.sibling( parent.row() + rowDelta, parent.column() );
566         if( rowDelta == -1 )
567           resultingIndex = aunt.child( model()->rowCount( aunt ) - 1, 0 );
568         else
569           resultingIndex = aunt.child( 0, 0 );
570         if( !resultingIndex.isValid() )
571           return;
572       }
573   selectionModel()->setCurrentIndex( resultingIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows );
574   selectionModel()->select( resultingIndex, QItemSelectionModel::ClearAndSelect );
575
576 }
577
578
579 QSize BufferView::sizeHint() const {
580   return QTreeView::sizeHint();
581
582   if(!model())
583     return QTreeView::sizeHint();
584
585   if(model()->rowCount() == 0)
586     return QSize(120, 50);
587
588   int columnSize = 0;
589   for(int i = 0; i < model()->columnCount(); i++) {
590     if(!isColumnHidden(i))
591       columnSize += sizeHintForColumn(i);
592   }
593   return QSize(columnSize, 50);
594 }
595
596 // ==============================
597 //  BufferView Dock
598 // ==============================
599 BufferViewDock::BufferViewDock(BufferViewConfig *config, QWidget *parent)
600   : QDockWidget(config->bufferViewName(), parent)
601 {
602   setObjectName("BufferViewDock-" + QString::number(config->bufferViewId()));
603   toggleViewAction()->setData(config->bufferViewId());
604   setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
605   connect(config, SIGNAL(bufferViewNameSet(const QString &)), this, SLOT(bufferViewRenamed(const QString &)));
606 }
607
608 BufferViewDock::BufferViewDock(QWidget *parent)
609   : QDockWidget(tr("All Buffers"), parent)
610 {
611   setObjectName("BufferViewDock--1");
612   toggleViewAction()->setData((int)-1);
613   setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
614 }
615
616 void BufferViewDock::bufferViewRenamed(const QString &newName) {
617   setWindowTitle(newName);
618   toggleViewAction()->setText(newName);
619 }