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