1
0
mirror of https://github.com/altlinux/admc.git synced 2024-10-27 01:55:37 +03:00

rename main widgets to x_widget

rename ad_filter tp ad_proxy_model
This commit is contained in:
Dmitry Degtyarev 2020-05-27 15:29:29 +04:00
parent af9e14bc93
commit 18d62ad596
13 changed files with 98 additions and 104 deletions

View File

@ -42,13 +42,13 @@ set(ADTOOL_HEADER_DIRS
set(ADTOOL_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/active_directory.c
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_filter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_proxy_model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ad_model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_list.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/attributes_model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/containers_tree.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/contents_list.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/containers_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/contents_widget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/create_entry_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/entry_widget.cpp

View File

@ -1,24 +1,24 @@
#include "ad_filter.h"
#include "ad_proxy_model.h"
#include "ad_model.h"
#include "ad_interface.h"
#include <QAction>
AdFilter::AdFilter(AdModel *model, QAction *advanced_view_toggle) {
AdProxyModel::AdProxyModel(AdModel *model, QAction *advanced_view_toggle) {
this->setSourceModel(model);
connect(advanced_view_toggle, &QAction::toggled,
this, &AdFilter::on_advanced_view_toggled);
this, &AdProxyModel::on_advanced_view_toggled);
}
void AdFilter::on_advanced_view_toggled(bool checked) {
void AdProxyModel::on_advanced_view_toggled(bool checked) {
// On advanced view toggle, copy advanced view flag and invalidate filter
advanced_view = checked;
this->invalidateFilter();
}
bool AdFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
bool AdProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
const QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
// Hide advanced view only entries if advanced view is OFF

View File

@ -1,6 +1,6 @@
#ifndef AD_FILTER_H
#define AD_FILTER_H
#ifndef AD_PROXY_MODEL_H
#define AD_PROXY_MODEL_H
#include <QSortFilterProxyModel>
@ -11,9 +11,9 @@ class AdModel;
// TODO: only allow AdModel source models
// Filter out advanced entries when advanced view is off
// Connected to advanced view toggle in menubar
class AdFilter : public QSortFilterProxyModel {
class AdProxyModel : public QSortFilterProxyModel {
public:
explicit AdFilter(AdModel *model, QAction *advanced_view_toggle);
explicit AdProxyModel(AdModel *model, QAction *advanced_view_toggle);
bool only_show_containers = false;
@ -27,4 +27,4 @@ private:
};
#endif /* AD_FILTER_H */
#endif /* AD_PROXY_MODEL_H */

View File

@ -1,5 +1,5 @@
#include "attributes_list.h"
#include "attributes_widget.h"
#include "attributes_model.h"
#include "ad_interface.h"
@ -8,7 +8,7 @@
#include <QLabel>
#include <QVBoxLayout>
AttributesList::AttributesList()
AttributesWidget::AttributesWidget()
: QWidget()
{
model = new AttributesModel(this);
@ -28,7 +28,7 @@ AttributesList::AttributesList()
layout()->addWidget(view);
};
void AttributesList::set_target_dn(const QString &new_target_dn) {
void AttributesWidget::set_target_dn(const QString &new_target_dn) {
this->target_dn = new_target_dn;
// Clear model of previous root

View File

@ -1,6 +1,6 @@
#ifndef ATTRIBUTES_VIEW_H
#define ATTRIBUTES_VIEW_H
#ifndef ATTRIBUTES_WIDGET_H
#define ATTRIBUTES_WIDGET_H
#include <QWidget>
@ -9,11 +9,11 @@ class QString;
class AttributesModel;
// Shows names and values of attributes of the entry selected in contents view
class AttributesList : public QWidget {
class AttributesWidget : public QWidget {
Q_OBJECT
public:
AttributesList();
AttributesWidget();
public slots:
@ -31,4 +31,4 @@ private:
QString target_dn;
};
#endif /* ATTRIBUTES_VIEW_H */
#endif /* ATTRIBUTES_WIDGET_H */

View File

@ -1,12 +1,12 @@
#include "containers_tree.h"
#include "containers_widget.h"
#include "ad_model.h"
#include "ad_filter.h"
#include "ad_proxy_model.h"
#include <QTreeView>
#include <QLabel>
ContainersTree::ContainersTree(AdModel *model, QAction *advanced_view_toggle)
ContainersWidget::ContainersWidget(AdModel *model, QAction *advanced_view_toggle)
: EntryWidget(model, advanced_view_toggle)
{
view->setAcceptDrops(true);
@ -27,10 +27,10 @@ ContainersTree::ContainersTree(AdModel *model, QAction *advanced_view_toggle)
connect(
view->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &ContainersTree::on_selection_changed);
this, &ContainersWidget::on_selection_changed);
};
void ContainersTree::on_selection_changed(const QItemSelection &selected, const QItemSelection &) {
void ContainersWidget::on_selection_changed(const QItemSelection &selected, const QItemSelection &) {
// Transform selected index into source index and pass it on
// to selected_container_changed() signal
const QList<QModelIndex> indexes = selected.indexes();

View File

@ -1,17 +1,17 @@
#ifndef CONTAINERS_VIEW_H
#define CONTAINERS_VIEW_H
#ifndef CONTAINERS_WIDGET_H
#define CONTAINERS_WIDGET_H
#include "entry_widget.h"
class QItemSelection;
// Shows names of AdModel as a tree
class ContainersTree : public EntryWidget {
class ContainersWidget : public EntryWidget {
Q_OBJECT
public:
ContainersTree(AdModel *model, QAction *advanced_view_toggle);
ContainersWidget(AdModel *model, QAction *advanced_view_toggle);
signals:
void selected_container_changed(const QModelIndex &selected);
@ -23,4 +23,4 @@ private:
};
#endif /* CONTAINERS_VIEW_H */
#endif /* CONTAINERS_WIDGET_H */

View File

@ -1,8 +1,8 @@
#include "contents_list.h"
#include "contents_widget.h"
#include "ad_interface.h"
#include "ad_model.h"
#include "ad_filter.h"
#include "ad_proxy_model.h"
#include <QApplication>
#include <QItemSelection>
@ -13,7 +13,7 @@
#include <QTreeView>
#include <QLabel>
ContentsList::ContentsList(AdModel* model, QAction *advanced_view_toggle)
ContentsWidget::ContentsWidget(AdModel* model, QAction *advanced_view_toggle)
: EntryWidget(model, advanced_view_toggle)
{
view->setAcceptDrops(true);
@ -32,7 +32,7 @@ ContentsList::ContentsList(AdModel* model, QAction *advanced_view_toggle)
// Both contents and containers share the same source model, but have different proxy's to it
// So need to map from containers proxy to source then back to proxy of contents
void ContentsList::on_selected_container_changed(const QModelIndex &source_index) {
void ContentsWidget::on_selected_container_changed(const QModelIndex &source_index) {
QModelIndex index = proxy->mapFromSource(source_index);
view->setRootIndex(index);

View File

@ -1,15 +1,15 @@
#ifndef CONTENTS_VIEW_H
#define CONTENTS_VIEW_H
#ifndef CONTENTS_WIDGET_H
#define CONTENTS_WIDGET_H
#include "entry_widget.h"
// Shows name, category and description of children of entry selected in containers view
class ContentsList : public EntryWidget {
class ContentsWidget : public EntryWidget {
Q_OBJECT
public:
ContentsList(AdModel *model, QAction *advanced_view);
ContentsWidget(AdModel *model, QAction *advanced_view);
public slots:
void on_selected_container_changed(const QModelIndex &source_index);
@ -18,4 +18,4 @@ private:
};
#endif /* CONTENTS_VIEW_H */
#endif /* CONTENTS_WIDGET_H */

View File

@ -2,7 +2,7 @@
#include "entry_widget.h"
#include "ad_interface.h"
#include "ad_model.h"
#include "ad_filter.h"
#include "ad_proxy_model.h"
#include <QApplication>
#include <QItemSelection>
@ -18,7 +18,7 @@
EntryWidget::EntryWidget(AdModel* model, QAction *advanced_view_toggle)
: QWidget()
{
proxy = new AdFilter(model, advanced_view_toggle);
proxy = new AdProxyModel(model, advanced_view_toggle);
view = new QTreeView();
view->setContextMenuPolicy(Qt::CustomContextMenu);

View File

@ -11,7 +11,7 @@ class QTreeView;
class QAction;
class QLabel;
class AdModel;
class AdFilter;
class AdProxyModel;
// Shows names of AdModel as a tree
class EntryWidget : public QWidget {
@ -30,7 +30,7 @@ public slots:
protected:
QTreeView *view = nullptr;
AdFilter *proxy = nullptr;
AdProxyModel *proxy = nullptr;
QLabel *label = nullptr;
QMap<AdModel::Column, bool> column_hidden;

View File

@ -1,9 +1,9 @@
#include "main_window.h"
#include "containers_tree.h"
#include "contents_list.h"
#include "attributes_list.h"
#include "ad_filter.h"
#include "containers_widget.h"
#include "contents_widget.h"
#include "attributes_widget.h"
#include "ad_proxy_model.h"
#include "ad_model.h"
#include "attributes_model.h"
#include "create_entry_dialog.h"
@ -20,17 +20,44 @@
#include <QHeaderView>
MainWindow::MainWindow(): QMainWindow() {
setupUi();
this->resize(1307, 795);
action_advanced_view = new QAction(this);
action_advanced_view->setCheckable(true);
centralwidget = new QWidget(this);
splitter = new QSplitter(centralwidget);
splitter->setGeometry(QRect(0, 0, 1301, 591));
splitter->setOrientation(Qt::Horizontal);
this->setCentralWidget(centralwidget);
menubar = new QMenuBar(this);
menubar->setGeometry(QRect(0, 0, 1307, 27));
menubar_new = new QMenu(menubar);
menuEdit = new QMenu(menubar);
menuView = new QMenu(menubar);
this->setMenuBar(menubar);
statusbar = new QStatusBar(this);
this->setStatusBar(statusbar);
menubar->addAction(menubar_new->menuAction());
menubar->addAction(menuEdit->menuAction());
menubar->addAction(menuView->menuAction());
menuView->addAction(action_advanced_view);
setWindowTitle(tr("MainWindow"));
action_advanced_view->setText(tr("Advanced view"));
menubar_new->setTitle(tr("New"));
menuEdit->setTitle(tr("Edit"));
menuView->setTitle(tr("View"));
ad_model = new AdModel();
containers_tree = new ContainersTree(ad_model, action_advanced_view);
contents_list = new ContentsList(ad_model, action_advanced_view);
attributes_list = new AttributesList();
containers_widget = new ContainersWidget(ad_model, action_advanced_view);
contents_widget = new ContentsWidget(ad_model, action_advanced_view);
attributes_widget = new AttributesWidget();
splitter->addWidget(containers_tree);
splitter->addWidget(contents_list);
splitter->addWidget(attributes_list);
splitter->addWidget(containers_widget);
splitter->addWidget(contents_widget);
splitter->addWidget(attributes_widget);
// Setup actions
action_attributes = new QAction("Attributes");
@ -61,23 +88,23 @@ MainWindow::MainWindow(): QMainWindow() {
menuView->addAction(action_toggle_dn);
QObject::connect(
action_toggle_dn, &QAction::triggered,
containers_tree, &EntryWidget::on_action_toggle_dn);
containers_widget, &EntryWidget::on_action_toggle_dn);
QObject::connect(
action_toggle_dn, &QAction::triggered,
contents_list, &EntryWidget::on_action_toggle_dn);
contents_widget, &EntryWidget::on_action_toggle_dn);
QObject::connect(
containers_tree, &EntryWidget::context_menu_requested,
containers_widget, &EntryWidget::context_menu_requested,
this, &MainWindow::popup_entry_context_menu);
QObject::connect(
contents_list, &EntryWidget::context_menu_requested,
contents_widget, &EntryWidget::context_menu_requested,
this, &MainWindow::popup_entry_context_menu);
// Set root index of contents view to selection of containers view
QObject::connect(
containers_tree, &ContainersTree::selected_container_changed,
contents_list, &ContentsList::on_selected_container_changed);
containers_widget, &ContainersWidget::selected_container_changed,
contents_widget, &ContentsWidget::on_selected_container_changed);
// Add menubar actions
for (auto a : new_entry_actions) {
@ -85,40 +112,9 @@ MainWindow::MainWindow(): QMainWindow() {
}
}
void MainWindow::setupUi() {
this->resize(1307, 795);
action_advanced_view = new QAction(this);
action_advanced_view->setCheckable(true);
centralwidget = new QWidget(this);
splitter = new QSplitter(centralwidget);
splitter->setGeometry(QRect(0, 0, 1301, 591));
splitter->setOrientation(Qt::Horizontal);
this->setCentralWidget(centralwidget);
menubar = new QMenuBar(this);
menubar->setGeometry(QRect(0, 0, 1307, 27));
menubar_new = new QMenu(menubar);
menuEdit = new QMenu(menubar);
menuView = new QMenu(menubar);
this->setMenuBar(menubar);
statusbar = new QStatusBar(this);
this->setStatusBar(statusbar);
menubar->addAction(menubar_new->menuAction());
menubar->addAction(menuEdit->menuAction());
menubar->addAction(menuView->menuAction());
menuView->addAction(action_advanced_view);
setWindowTitle(tr("MainWindow"));
action_advanced_view->setText(tr("Advanced view"));
menubar_new->setTitle(tr("New"));
menuEdit->setTitle(tr("Edit"));
menuView->setTitle(tr("View"));
}
QString MainWindow::get_selected_dn() const {
QString containers_dn = containers_tree->get_selected_dn();
QString contents_dn = contents_list->get_selected_dn();
QString containers_dn = containers_widget->get_selected_dn();
QString contents_dn = contents_widget->get_selected_dn();
if (containers_dn != "") {
return containers_dn;
@ -131,7 +127,7 @@ QString MainWindow::get_selected_dn() const {
void MainWindow::on_action_attributes() {
auto dn = get_selected_dn();
attributes_list->set_target_dn(dn);
attributes_widget->set_target_dn(dn);
}
void MainWindow::on_action_delete_entry() {

View File

@ -10,9 +10,9 @@
class QString;
class AdModel;
class ContainersTree;
class ContentsList;
class AttributesList;
class ContainersWidget;
class ContentsWidget;
class AttributesWidget;
class QAction;
class QWidget;
class QSplitter;
@ -27,8 +27,6 @@ public:
MainWindow();
private:
void setupUi();
QString get_selected_dn() const;
void on_action_attributes();
void on_action_delete_entry();
@ -37,9 +35,9 @@ private:
void on_action_toggle_dn(bool checked);
AdModel *ad_model;
ContainersTree *containers_tree;
ContentsList *contents_list;
AttributesList *attributes_list;
ContainersWidget *containers_widget;
ContentsWidget *contents_widget;
AttributesWidget *attributes_widget;
QAction *action_toggle_dn;
QAction *action_attributes;