mirror of
https://github.com/altlinux/admc.git
synced 2025-03-22 14:50:36 +03:00
Added copy action to list of attributes
This commit is contained in:
parent
3ef907bf1e
commit
4e86cb6f4d
@ -34,6 +34,8 @@
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMouseEvent>
|
||||
#include <QClipboard>
|
||||
|
||||
QString attribute_type_display_string(const AttributeType type);
|
||||
|
||||
@ -98,6 +100,8 @@ AttributesTabEdit::AttributesTabEdit(QTreeView *view_arg, QPushButton *filter_bu
|
||||
this, &AttributesTabEdit::update_edit_and_view_buttons);
|
||||
update_edit_and_view_buttons();
|
||||
|
||||
view->installEventFilter(this);
|
||||
|
||||
connect(
|
||||
view, &QAbstractItemView::doubleClicked,
|
||||
this, &AttributesTabEdit::on_double_click);
|
||||
@ -147,7 +151,6 @@ QList<QStandardItem *> AttributesTabEdit::get_selected_row() const {
|
||||
|
||||
void AttributesTabEdit::update_edit_and_view_buttons() {
|
||||
const QList<QStandardItem *> selected_row = get_selected_row();
|
||||
|
||||
const bool no_selection = selected_row.isEmpty();
|
||||
if (no_selection) {
|
||||
edit_button->setVisible(true);
|
||||
@ -175,6 +178,24 @@ void AttributesTabEdit::update_edit_and_view_buttons() {
|
||||
}
|
||||
}
|
||||
|
||||
void AttributesTabEdit::copy_action(){
|
||||
const QList<QStandardItem *> selected_row = get_selected_row();
|
||||
QApplication::clipboard()->setText(selected_row[AttributesColumn_Value]->text());
|
||||
}
|
||||
|
||||
bool AttributesTabEdit::eventFilter(QObject *watched, QEvent *event){
|
||||
if (watched == view && event->type() == 82){
|
||||
QMenu menu;
|
||||
QAction* saveAction = menu.addAction("Копировать");
|
||||
connect(
|
||||
saveAction, &QAction::triggered,
|
||||
this, &AttributesTabEdit::copy_action);
|
||||
menu.exec(QCursor::pos());
|
||||
return true;
|
||||
}
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void AttributesTabEdit::on_double_click() {
|
||||
const QList<QStandardItem *> selected_row = get_selected_row();
|
||||
const QString attribute = selected_row[AttributesColumn_Name]->text();
|
||||
|
@ -90,6 +90,8 @@ private:
|
||||
void edit_attribute();
|
||||
void view_attribute();
|
||||
void on_load_optional();
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void copy_action();
|
||||
void load_optional_attribute_values(AdInterface &ad);
|
||||
void load_row(const QList<QStandardItem *> &row, const QString &attribute, const QList<QByteArray> &values);
|
||||
QList<QStandardItem *> get_selected_row() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user