Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/robomongo/core/domain/Notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ namespace Robomongo
_copyTimestampAction = new QAction("Copy Timestamp from ObjectId", wid);
VERIFY(connect(_copyTimestampAction, SIGNAL(triggered()), SLOT(onCopyTimestamp())));

_copyIdentifierAction = new QAction("Copy Identifier from ObjectId", wid);
VERIFY(connect(_copyIdentifierAction, SIGNAL(triggered()), SLOT(onCopyIdentifier())));

_copyJsonAction = new QAction("Copy JSON", wid);
VERIFY(connect(_copyJsonAction, SIGNAL(triggered()), SLOT(onCopyJson())));
}
Expand Down Expand Up @@ -168,6 +171,7 @@ namespace Robomongo
menu->addAction(_copyValuePathAction);

if (onItem && isObjectId) menu->addAction(_copyTimestampAction);
if (onItem && isObjectId) menu->addAction(_copyIdentifierAction);
if (onItem && isDocument) menu->addAction(_copyJsonAction);
if (onItem && isEditable) menu->addSeparator();
if (onItem && isEditable) menu->addAction(_deleteDocumentAction);
Expand Down Expand Up @@ -476,6 +480,25 @@ namespace Robomongo
}
}

void Notifier::onCopyIdentifier()
{
QModelIndex selectedInd = _observer->selectedIndex();
if (!selectedInd.isValid())
return;

BsonTreeItem *documentItem = QtUtils::item<BsonTreeItem*>(selectedInd);
if (!documentItem)
return;

if (!detail::isObjectIdType(documentItem))
return;

QString identifier = documentItem->value().mid(10, 24);

QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(identifier);
}

void Notifier::onCopyJson()
{
QModelIndex selectedInd = _observer->selectedIndex();
Expand Down
1 change: 1 addition & 0 deletions src/robomongo/core/domain/Notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace Robomongo
void onInsertDocument();
void onCopyDocument();
void onCopyTimestamp();
void onCopyIdentifier();
void onCopyJson();
void handle(InsertDocumentResponse *event);
void handle(RemoveDocumentResponse *event);
Expand Down