Skip to content

Commit

Permalink
Restored scrolling to alerting contacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblsha committed Mar 30, 2010
1 parent 16e9bcd commit bdd56c6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/contactlistdragview.cpp
Expand Up @@ -656,10 +656,10 @@ bool ContactListDragView::extendedSelectionAllowed() const
bool ContactListDragView::activateItemsOnSingleClick() const
{
// #ifndef YAPSI
// return style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this);
// return PsiOptions::instance()->getOption("options.ui.contactlist.use-single-click").toBool();
// #endif
return false;
// return style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this);
}

void ContactListDragView::updateKeyboardModifiers(const QEvent* e)
Expand Down
9 changes: 9 additions & 0 deletions src/contactlistmodel.cpp
Expand Up @@ -61,6 +61,7 @@ ContactListModel::ContactListModel(PsiContactList* contactList)
connect(groupState_, SIGNAL(orderChanged()), SLOT(orderChanged()));
connect(updater_, SIGNAL(addedContact(PsiContact*)), SLOT(addContact(PsiContact*)));
connect(updater_, SIGNAL(removedContact(PsiContact*)), SLOT(removeContact(PsiContact*)));
connect(updater_, SIGNAL(contactAlert(PsiContact*)), SLOT(contactAlert(PsiContact*)));
connect(updater_, SIGNAL(contactUpdated(PsiContact*)), SLOT(contactUpdated(PsiContact*)));
connect(updater_, SIGNAL(contactGroupsChanged(PsiContact*)), SLOT(contactGroupsChanged(PsiContact*)));
connect(updater_, SIGNAL(beginBulkContactUpdate()), SLOT(beginBulkUpdate()));
Expand Down Expand Up @@ -294,6 +295,14 @@ QModelIndexList ContactListModel::indexesFor(PsiContact* contact) const
return result;
}

void ContactListModel::contactAlert(PsiContact* contact)
{
QModelIndexList indexes = indexesFor(contact);
if (!indexes.isEmpty()) {
emit contactAlert(indexes.first());
}
}

void ContactListModel::contactUpdated(PsiContact* contact)
{
Q_ASSERT(rootGroup_);
Expand Down
3 changes: 3 additions & 0 deletions src/contactlistmodel.h
Expand Up @@ -173,6 +173,8 @@ class ContactListModel : public QAbstractItemModel
void showTransportsChanged();
void inPlaceRename();

void contactAlert(const QModelIndex&);

public slots:
void expanded(const QModelIndex&);
void collapsed(const QModelIndex&);
Expand All @@ -181,6 +183,7 @@ protected slots:
void addContact(PsiContact*);
void removeContact(PsiContact*);

void contactAlert(PsiContact*);
void contactUpdated(PsiContact*);
void contactGroupsChanged(PsiContact*);

Expand Down
7 changes: 7 additions & 0 deletions src/contactlistmodelupdater.cpp
Expand Up @@ -108,6 +108,7 @@ void ContactListModelUpdater::addContact(PsiContact* contact)
connect(contact, SIGNAL(destroyed(PsiContact*)), SLOT(removeContact(PsiContact*)));
connect(contact, SIGNAL(updated()), SLOT(contactUpdated()));
connect(contact, SIGNAL(groupsChanged()), SLOT(contactGroupsChanged()));
connect(contact, SIGNAL(alert()), SLOT(contactAlert()));
}

/*!
Expand All @@ -126,6 +127,12 @@ void ContactListModelUpdater::removeContact(PsiContact* contact)
operationQueue_.remove(contact);
}

void ContactListModelUpdater::contactAlert()
{
PsiContact* contact = static_cast<PsiContact*>(sender());
emit contactAlert(contact);
}

void ContactListModelUpdater::contactUpdated()
{
PsiContact* contact = static_cast<PsiContact*>(sender());
Expand Down
2 changes: 2 additions & 0 deletions src/contactlistmodelupdater.h
Expand Up @@ -47,6 +47,7 @@ public slots:
signals:
void addedContact(PsiContact*);
void removedContact(PsiContact*);
void contactAlert(PsiContact*);
void contactUpdated(PsiContact*);
void contactGroupsChanged(PsiContact*);

Expand All @@ -59,6 +60,7 @@ public slots:
private slots:
void removeContact(PsiContact*);

void contactAlert();
void contactUpdated();
void contactGroupsChanged();

Expand Down
5 changes: 5 additions & 0 deletions src/contactlistview.cpp
Expand Up @@ -537,3 +537,8 @@ void ContactListView::commitData(QWidget* editor)
setFocus();
updateContextMenu();
}

void ContactListView::ensureVisible(const QModelIndex& index)
{
scrollTo(index, QAbstractItemView::EnsureVisible);
}
1 change: 1 addition & 0 deletions src/contactlistview.h
Expand Up @@ -48,6 +48,7 @@ class ContactListView : public HoverableTreeView

void activate(const QModelIndex& index);
void toggleExpandedState(const QModelIndex& index);
void ensureVisible(const QModelIndex& index);

// reimplemented
void setModel(QAbstractItemModel* model);
Expand Down
3 changes: 3 additions & 0 deletions src/psicontact.cpp
Expand Up @@ -496,6 +496,9 @@ void PsiContact::setAlert(const PsiIcon* icon)
d->setAlert(icon);
// updateParent();
#endif
if (icon) {
emit alert();
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/psicontact.h
Expand Up @@ -164,6 +164,7 @@ private slots:
void blockContactConfirmationHelper(bool block);

signals:
void alert();
void updated();
void groupsChanged();
#ifdef YAPSI
Expand Down
18 changes: 18 additions & 0 deletions src/psicontactlistview.cpp
Expand Up @@ -24,6 +24,8 @@

#include "psicontactlistviewdelegate.h"
#include "psitooltip.h"
#include "psioptions.h"
#include "contactlistmodel.h"

PsiContactListView::PsiContactListView(QWidget* parent)
: ContactListDragView(parent)
Expand All @@ -38,3 +40,19 @@ void PsiContactListView::showToolTip(const QModelIndex& index, const QPoint& glo
QString text = index.data(Qt::ToolTipRole).toString();
PsiToolTip::showText(globalPos, text, this);
}

void PsiContactListView::setModel(QAbstractItemModel* model)
{
ContactListDragView::setModel(model);
QAbstractItemModel* connectToModel = realModel();
if (dynamic_cast<ContactListModel*>(connectToModel)) {
connect(connectToModel, SIGNAL(contactAlert(const QModelIndex&)), SLOT(contactAlert(const QModelIndex&)));
}
}

void PsiContactListView::contactAlert(const QModelIndex& realIndex)
{
if (PsiOptions::instance()->getOption("options.ui.contactlist.ensure-contact-visible-on-event").toBool()) {
ensureVisible(proxyIndex(realIndex));
}
}
6 changes: 6 additions & 0 deletions src/psicontactlistview.h
Expand Up @@ -32,6 +32,12 @@ class PsiContactListView : public ContactListDragView
public:
PsiContactListView(QWidget* parent);

// reimplemented
void setModel(QAbstractItemModel* model);

protected slots:
void contactAlert(const QModelIndex&);

protected:
// reimplemented
virtual void showToolTip(const QModelIndex& index, const QPoint& globalPos) const;
Expand Down

0 comments on commit bdd56c6

Please sign in to comment.