~ubuntu-branches/ubuntu/jaunty/quassel/jaunty-backports

« back to all changes in this revision

Viewing changes to src/uisupport/bufferviewfilter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2009-02-01 16:13:05 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090201161305-ifle115wg2embbla
Tags: 0.4.0~git090201-0ubuntu1
* New upstream git snapshot
  - Core/client connection reliability improvements
  - Other bug fixing
* Adjust quassel-data.install to include ../oxygen/*/apps/quassel.svgz and
  quassel.png

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "iconloader.h"
32
32
#include "networkmodel.h"
33
33
 
34
 
#include "uisettings.h"
35
 
 
36
34
class CheckRemovalEvent : public QEvent {
37
35
public:
38
36
  CheckRemovalEvent(const QModelIndex &source_index) : QEvent(QEvent::User), index(source_index) {};
57
55
 
58
56
  setDynamicSortFilter(true);
59
57
 
60
 
  loadColors();
61
 
 
62
58
  connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
63
59
          this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
64
60
 
71
67
  bufferSettings.notify("ShowUserStateIcons", this, SLOT(showUserStateIconsChanged()));
72
68
}
73
69
 
74
 
void BufferViewFilter::loadColors() {
75
 
  UiSettings s("QtUiStyle/Colors");
76
 
  _FgColorInactiveActivity = s.value("inactiveActivityFG", QVariant(QColor(Qt::gray))).value<QColor>();
77
 
  _FgColorNoActivity = s.value("noActivityFG", QVariant(QColor(Qt::black))).value<QColor>();
78
 
  _FgColorHighlightActivity = s.value("highlightActivityFG", QVariant(QColor(Qt::magenta))).value<QColor>();
79
 
  _FgColorNewMessageActivity = s.value("newMessageActivityFG", QVariant(QColor(Qt::green))).value<QColor>();
80
 
  _FgColorOtherActivity = s.value("otherActivityFG", QVariant(QColor(Qt::darkGreen))).value<QColor>();
81
 
}
82
 
 
83
70
void BufferViewFilter::showUserStateIconsChanged() {
84
71
  BufferSettings bufferSettings;
85
72
  _showUserStateIcons = bufferSettings.showUserStateIcons();
371
358
  switch(role) {
372
359
  case Qt::DecorationRole:
373
360
    return icon(index);
374
 
  case Qt::ForegroundRole:
375
 
    return foreground(index);
376
361
  case Qt::CheckStateRole:
377
362
    return checkedState(index);
378
363
  default:
401
386
  return QVariant();
402
387
}
403
388
 
404
 
QVariant BufferViewFilter::foreground(const QModelIndex &index) const {
405
 
  if(config() && config()->disableDecoration())
406
 
    return _FgColorNoActivity;
407
 
 
408
 
  BufferInfo::ActivityLevel activity = (BufferInfo::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
409
 
 
410
 
  if(activity & BufferInfo::Highlight)
411
 
    return _FgColorHighlightActivity;
412
 
  if(activity & BufferInfo::NewMessage)
413
 
    return _FgColorNewMessageActivity;
414
 
  if(activity & BufferInfo::OtherActivity)
415
 
    return _FgColorOtherActivity;
416
 
 
417
 
  if(!index.data(NetworkModel::ItemActiveRole).toBool() || index.data(NetworkModel::UserAwayRole).toBool())
418
 
    return _FgColorInactiveActivity;
419
 
 
420
 
  return _FgColorNoActivity;
421
 
}
422
 
 
423
389
QVariant BufferViewFilter::checkedState(const QModelIndex &index) const {
424
390
  if(!_editMode || !config())
425
391
    return QVariant();