1 // Copyright 2005-2019 The Mumble Developers. All rights reserved. 2 // Use of this source code is governed by a BSD-style license 3 // that can be found in the LICENSE file at the root of the 4 // Mumble source tree or at <https://www.mumble.info/LICENSE>. 5 6 #ifndef MUMBLE_MUMBLE_USEREDIT_H_ 7 #define MUMBLE_MUMBLE_USEREDIT_H_ 8 9 #include "Message.h" 10 #include "User.h" 11 #include "ui_UserEdit.h" 12 13 #include <QSortFilterProxyModel> 14 15 class UserListModel; 16 class UserListFilterProxyModel; 17 18 namespace MumbleProto { 19 class UserList; 20 class UserList_User; 21 } 22 23 /// 24 /// Dialog used for server-side registered user list editing. 25 /// 26 class UserEdit : public QDialog, public Ui::UserEdit { 27 Q_OBJECT 28 Q_DISABLE_COPY(UserEdit) 29 public: 30 /// Constructs a dialog for editing the given userList. 31 UserEdit(const MumbleProto::UserList &userList, QWidget *p = NULL); 32 33 public slots: 34 void accept() Q_DECL_OVERRIDE; 35 36 void on_qlSearch_textChanged(QString); 37 void on_qpbRemove_clicked(); 38 void on_qpbRename_clicked(); 39 void on_qtvUserList_customContextMenuRequested(const QPoint&); 40 void onSelectionChanged(const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/); 41 void onCurrentRowChanged(const QModelIndex & current, const QModelIndex &/*previous*/); 42 void on_qsbInactive_valueChanged(int); 43 void on_qcbInactive_currentIndexChanged(int); 44 45 private: 46 enum TimespanUnits { TU_DAYS, TU_WEEKS, TU_MONTHS, TU_YEARS, COUNT_TU }; 47 48 /// Polls the inactive-filter controls for their current value and updates the model filter. 49 void updateInactiveDaysFilter(); 50 51 UserListModel *m_model; 52 UserListFilterProxyModel *m_filter; 53 }; 54 55 /// 56 /// Provides filtering and sorting capabilities for UserListModel instances to UserEdit. 57 /// @see UserEdit 58 /// @see UserListModel 59 /// 60 class UserListFilterProxyModel : public QSortFilterProxyModel { 61 Q_OBJECT 62 public: 63 explicit UserListFilterProxyModel(QObject *parent = NULL); 64 65 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const Q_DECL_OVERRIDE; 66 67 public slots: 68 /// Sets the amount of inactive days below which rows will get filterd by the proxy 69 void setFilterMinimumInactiveDays(int minimumInactiveDays); 70 /// Helper function for removing all rows involved in a given selection (must include COL_NICK). 71 void removeRowsInSelection(const QItemSelection& selection); 72 73 private: 74 /// Every row with less inactive days will be filtered. 75 int m_minimumInactiveDays; 76 }; 77 78 79 #endif // MUMBLE_MUMBLE_USEREDIT_H_ 80