first commit
This commit is contained in:
+114
@@ -0,0 +1,114 @@
|
||||
#ifndef USERWIDGET_H
|
||||
#define USERWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTableWidget>
|
||||
#include <QTimer>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QContextMenuEvent>
|
||||
#include "user_manager.h"
|
||||
|
||||
class UserWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserWidget(UserManager* userManager, QWidget *parent = nullptr);
|
||||
~UserWidget();
|
||||
|
||||
void setUserManager(UserManager* userManager);
|
||||
void refreshData();
|
||||
void updateStatistics();
|
||||
|
||||
signals:
|
||||
void banUserRequested(const QString &userId, const QString &userName);
|
||||
void timeoutUserRequested(const QString &userId, const QString &userName, int minutes);
|
||||
void unbanUserRequested(const QString &userId, const QString &userName);
|
||||
void setModeratorRequested(const QString &userId, const QString &userName);
|
||||
void removeModeratorRequested(const QString &userId, const QString &userName);
|
||||
void setVIPRequested(const QString &userId, const QString &userName);
|
||||
void removeVIPRequested(const QString &userId, const QString &userName);
|
||||
void userInfoRequested(const QString &userId, const QString &userName);
|
||||
|
||||
private slots:
|
||||
void onRefreshTimer();
|
||||
void onUserAdded(const User &user);
|
||||
void onUserUpdated(const User &user);
|
||||
void onUserRemoved(const QString &userId, const QString &displayName);
|
||||
void onUserDoubleClicked(int row, int column);
|
||||
void onFilterChanged(int index);
|
||||
void onSearchTextChanged(const QString &text);
|
||||
void onRefreshButtonClicked();
|
||||
|
||||
// Слоты для контекстного меню
|
||||
void onBanUser();
|
||||
void onTimeoutUser();
|
||||
void onUnbanUser();
|
||||
void onSetModerator();
|
||||
void onRemoveModerator();
|
||||
void onSetVIP();
|
||||
void onRemoveVIP();
|
||||
void onShowUserInfo();
|
||||
|
||||
void showContextMenu(const QPoint &pos);
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
void populateTable();
|
||||
void addUserToTable(const User &user);
|
||||
void updateUserInTable(const User &user);
|
||||
void removeUserFromTable(const QString &displayName);
|
||||
void clearTable();
|
||||
void disconnectSignals();
|
||||
void connectSignals();
|
||||
void setupContextMenu();
|
||||
bool userMatchesFilter(const User* user) const;
|
||||
int findRowByUserId(const QString &userId) const;
|
||||
void removeUserFromTableByUserId(const QString &userId);
|
||||
User* getSelectedUser();
|
||||
|
||||
UserManager* m_userManager;
|
||||
|
||||
// UI элементы
|
||||
QTableWidget* m_tableWidget;
|
||||
QComboBox* m_filterCombo;
|
||||
QLineEdit* m_searchEdit;
|
||||
QLabel* m_statsLabel;
|
||||
|
||||
QTimer* m_refreshTimer;
|
||||
|
||||
// Контекстное меню
|
||||
QMenu* m_contextMenu;
|
||||
QAction* m_banAction;
|
||||
QAction* m_timeoutAction;
|
||||
QAction* m_unbanAction;
|
||||
QAction* m_setModAction;
|
||||
QAction* m_removeModAction;
|
||||
QAction* m_setVIPAction;
|
||||
QAction* m_removeVIPAction;
|
||||
QAction* m_infoAction;
|
||||
|
||||
enum FilterType {
|
||||
FilterAll,
|
||||
FilterModerators,
|
||||
FilterVIPs,
|
||||
FilterSubscribers,
|
||||
FilterActive
|
||||
};
|
||||
|
||||
FilterType m_currentFilter;
|
||||
QString m_searchText;
|
||||
|
||||
// Выбранный пользователь для контекстного меню
|
||||
QString m_selectedUserId;
|
||||
QString m_selectedUserName;
|
||||
};
|
||||
|
||||
#endif // USERWIDGET_H
|
||||
Reference in New Issue
Block a user