Back to index

lightdm  1.3.2
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
QLightDM::UsersModelPrivate Class Reference

List of all members.

Public Member Functions

 UsersModelPrivate (UsersModel *parent)
virtual ~UsersModelPrivate ()

Public Attributes

QList< UserItemusers

Protected Member Functions

void loadUsers ()

Static Protected Member Functions

static void cb_userAdded (LightDMUserList *user_list, LightDMUser *user, gpointer data)
static void cb_userChanged (LightDMUserList *user_list, LightDMUser *user, gpointer data)
static void cb_userRemoved (LightDMUserList *user_list, LightDMUser *user, gpointer data)

Protected Attributes

UsersModel *const q_ptr

Detailed Description

Definition at line 46 of file usersmodel.cpp.


Constructor & Destructor Documentation

UsersModelPrivate::UsersModelPrivate ( UsersModel *  parent)

Definition at line 65 of file usersmodel.cpp.

                                                       :
    q_ptr(parent)
{
    g_type_init();
}

Definition at line 71 of file usersmodel.cpp.

{
    g_signal_handlers_disconnect_by_func(lightdm_user_list_get_instance(), NULL, this);
}

Here is the call graph for this function:


Member Function Documentation

void UsersModelPrivate::cb_userAdded ( LightDMUserList user_list,
LightDMUser user,
gpointer  data 
) [static, protected]

Definition at line 113 of file usersmodel.cpp.

{
    Q_UNUSED(user_list)
    UsersModelPrivate *that = static_cast<UsersModelPrivate*>(data);

    that->q_func()->beginInsertRows(QModelIndex(), that->users.size(), that->users.size());

    UserItem user;
    user.name = QString::fromUtf8(lightdm_user_get_name(ldmUser));
    user.homeDirectory = QString::fromUtf8(lightdm_user_get_home_directory(ldmUser));
    user.realName = QString::fromUtf8(lightdm_user_get_real_name(ldmUser));
    user.image = QString::fromUtf8(lightdm_user_get_image(ldmUser));
    user.background = QString::fromUtf8(lightdm_user_get_background(ldmUser));
    user.isLoggedIn = lightdm_user_get_logged_in(ldmUser);
    user.hasMessages = lightdm_user_get_has_messages(ldmUser);
    that->users.append(user);

    that->q_func()->endInsertRows();

}

Here is the call graph for this function:

Here is the caller graph for this function:

void UsersModelPrivate::cb_userChanged ( LightDMUserList user_list,
LightDMUser user,
gpointer  data 
) [static, protected]

Definition at line 134 of file usersmodel.cpp.

{
    Q_UNUSED(user_list)
    UsersModelPrivate *that = static_cast<UsersModelPrivate*>(data);

    QString userToChange = QString::fromUtf8(lightdm_user_get_name(ldmUser));

    for (int i=0;i<that->users.size();i++) {
        if (that->users[i].name == userToChange) {

            that->users[i].homeDirectory = QString::fromUtf8(lightdm_user_get_home_directory(ldmUser));
            that->users[i].realName = QString::fromUtf8(lightdm_user_get_real_name(ldmUser));
            that->users[i].image = QString::fromUtf8(lightdm_user_get_image(ldmUser));
            that->users[i].background = QString::fromUtf8(lightdm_user_get_background(ldmUser));
            that->users[i].isLoggedIn = lightdm_user_get_logged_in(ldmUser);
            that->users[i].hasMessages = lightdm_user_get_has_messages(ldmUser);

            QModelIndex index = that->q_ptr->createIndex(i, 0);
            that->q_ptr->dataChanged(index, index);
            break;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void UsersModelPrivate::cb_userRemoved ( LightDMUserList user_list,
LightDMUser user,
gpointer  data 
) [static, protected]

Definition at line 159 of file usersmodel.cpp.

{
    Q_UNUSED(user_list)

    UsersModelPrivate *that = static_cast<UsersModelPrivate*>(data);
    QString userToRemove = QString::fromUtf8(lightdm_user_get_name(ldmUser));

    for (int i=0;i<that->users.size();i++) {
        if (that->users[i].name == userToRemove) {
            that->q_ptr->beginRemoveRows(QModelIndex(), i, i);
            that->users.removeAt(i);
            that->q_ptr->endRemoveRows();
            break;
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void UsersModelPrivate::loadUsers ( ) [protected]

Definition at line 76 of file usersmodel.cpp.

{
    Q_Q(UsersModel);

    int rowCount = lightdm_user_list_get_length(lightdm_user_list_get_instance());

    if (rowCount == 0) {
        return;
    } else {
        q->beginInsertRows(QModelIndex(), 0, rowCount-1);

        const GList *items, *item;
        items = lightdm_user_list_get_users(lightdm_user_list_get_instance());
        for (item = items; item; item = item->next) {
            LightDMUser *ldmUser = static_cast<LightDMUser*>(item->data);

            UserItem user;
            user.name = QString::fromUtf8(lightdm_user_get_name(ldmUser));
            user.homeDirectory = QString::fromUtf8(lightdm_user_get_home_directory(ldmUser));
            user.realName = QString::fromUtf8(lightdm_user_get_real_name(ldmUser));
            user.image = QString::fromUtf8(lightdm_user_get_image(ldmUser));
            user.background = QString::fromUtf8(lightdm_user_get_background(ldmUser));
            user.session = QString::fromUtf8(lightdm_user_get_session(ldmUser));
            user.isLoggedIn = lightdm_user_get_logged_in(ldmUser);
            user.hasMessages = lightdm_user_get_has_messages(ldmUser);
            users.append(user);
        }

        q->endInsertRows();
    }
    g_signal_connect(lightdm_user_list_get_instance(), "user-added", G_CALLBACK (cb_userAdded), this);
    g_signal_connect(lightdm_user_list_get_instance(), "user-changed", G_CALLBACK (cb_userChanged), this);
    g_signal_connect(lightdm_user_list_get_instance(), "user-removed", G_CALLBACK (cb_userRemoved), this);
}

Here is the call graph for this function:


Member Data Documentation

UsersModel* const QLightDM::UsersModelPrivate::q_ptr [protected]

Definition at line 53 of file usersmodel.cpp.

Definition at line 50 of file usersmodel.cpp.


The documentation for this class was generated from the following file: