#include <QTextLayout>
#include <QMenu>
-
+#include "bufferview.h"
#include "chatitem.h"
#include "chatlinemodel.h"
+#include "iconloader.h"
+#include "mainwin.h"
#include "qtui.h"
#include "qtuistyle.h"
switch(privateData()->currentClickable.type) {
case Clickable::Url:
privateData()->activeClickable = privateData()->currentClickable;
- menu->addAction(tr("Copy Link Address"), &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue<void *>(this));
+ menu->addAction(SmallIcon("edit-copy"), tr("Copy Link Address"),
+ &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue<void *>(this));
break;
default:
break;
}
}
+
+ // Buffer-specific actions
+ // We add these in ChatItem (rather than the scene), because they depend on the current clickable
+ if(chatScene()->isSingleBufferScene()) {
+ QModelIndex index = Client::networkModel()->bufferIndex(chatScene()->singleBufferId());
+ if(index.isValid()) {
+ menu->addSeparator();
+ QtUi::mainWindow()->allBuffersView()->addActionsToMenu(menu, index);
+ }
+ }
+
}
void ContentsChatItem::copyLinkToClipboard() {
_chatView(parent),
_idString(idString),
_model(model),
- _singleBufferScene(false),
+ _singleBufferId(BufferId()),
_sceneRect(0, 0, width, 0),
_firstLineRow(-1),
_viewportHeight(0),
_leftButtonPressed(false)
{
MessageFilter *filter = qobject_cast<MessageFilter*>(model);
- if(filter) {
- _singleBufferScene = filter->isSingleBufferFilter();
+ if(filter && filter->isSingleBufferFilter()) {
+ _singleBufferId = filter->singleBufferId();
}
ChatViewSettings defaultSettings;
ChatView *chatView() const;
ChatItem *chatItemAt(const QPointF &pos) const;
+ inline ChatLine *chatLine(int row) { return (row < _lines.count()) ? _lines[row] : 0; }
- inline bool isSingleBufferScene() const { return _singleBufferScene; }
+ inline bool isSingleBufferScene() const { return _singleBufferId.isValid(); }
+ inline BufferId singleBufferId() const { return _singleBufferId; }
bool containsBuffer(const BufferId &id) const;
- inline ChatLine *chatLine(int row) { return (row < _lines.count()) ? _lines[row] : 0; }
ColumnHandleItem *firstColumnHandle() const;
ColumnHandleItem *secondColumnHandle() const;
QString _idString;
QAbstractItemModel *_model;
QList<ChatLine *> _lines;
- bool _singleBufferScene;
+ BufferId _singleBufferId;
// calls to QChatScene::sceneRect() are very expensive. As we manage the scenerect ourselves
// we store the size in a member variable.
}
void BufferView::contextMenuEvent(QContextMenuEvent *event) {
- _menuIndex = indexAt(event->pos());
- if(!_menuIndex.isValid())
- _menuIndex = rootIndex();
- if(!_menuIndex.isValid())
+ QModelIndex index = indexAt(event->pos());
+ if(!index.isValid())
+ index = rootIndex();
+ if(!index.isValid())
return;
QMenu contextMenu(this);
- addActionsToMenu(&contextMenu, _menuIndex);
+ addActionsToMenu(&contextMenu, index);
if(!contextMenu.actions().isEmpty())
contextMenu.exec(QCursor::pos());
- _menuIndex = QModelIndex();
}
void BufferView::addActionsToMenu(QMenu *contextMenu, const QModelIndex &index) {
+ _menuIndex = index;
const Network *network = Client::network(index.data(NetworkModel::NetworkIdRole).value<NetworkId>());
Q_CHECK_PTR(network);