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

« back to all changes in this revision

Viewing changes to src/uisupport/nickview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2009-02-06 08:15:36 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090206081536-w43riu692dxjjpl2
Tags: 0.4.0~git090206-0ubuntu1
* New upstream git snapshot
  - Added toolbar to u/i (initial drop - still more work to do)
  - Add more post KDE 4.2 oxygen icons
  - Redesigned web preview to hog fewer resources
  - Continued bug fixing
* Add new icons to debian/quassel-data.install
* Remove scalable Oxygen icons from the binary (not used and saves space)
* Build with full debugging enabled
* Explicitly set -DEMBED_DATA=off instead of just unsetting it (clearer)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include "buffermodel.h"
29
29
#include "client.h"
 
30
#include "contextmenuactionprovider.h"
 
31
#include "graphicalui.h"
 
32
#include "nickview.h"
30
33
#include "nickviewfilter.h"
31
34
#include "networkmodel.h"
32
 
#include "quasselui.h"
33
35
#include "types.h"
 
36
#include "uisettings.h"
34
37
 
35
38
class ExpandAllEvent : public QEvent {
36
39
public:
45
48
  setItemDelegate(newDelegate);
46
49
  delete oldDelegate;
47
50
 
48
 
  
49
51
  setIndentation(10);
50
52
  setAnimated(true);
51
53
  header()->hide();
72
74
 
73
75
  for(int i = 1; i < model()->columnCount(); i++)
74
76
    setColumnHidden(i, true);
 
77
 
 
78
  connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SIGNAL(selectionUpdated()));
 
79
  connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SIGNAL(selectionUpdated()));
75
80
}
76
81
 
77
 
void NickView::setModel(QAbstractItemModel *model) {
78
 
  QTreeView::setModel(model);
 
82
void NickView::setModel(QAbstractItemModel *model_) {
 
83
  if(model())
 
84
    disconnect(model(), 0, this, 0);
 
85
 
 
86
  QTreeView::setModel(model_);
79
87
  init();
80
88
}
81
89
 
92
100
    QCoreApplication::postEvent(this, new ExpandAllEvent);
93
101
}
94
102
 
95
 
void NickView::showContextMenu(const QPoint & pos ) {
96
 
  QModelIndex index = indexAt(pos);
97
 
  if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::IrcUserItemType)
98
 
    return;
 
103
QModelIndexList NickView::selectedIndexes() const {
 
104
  QModelIndexList indexList = QTreeView::selectedIndexes();
99
105
 
100
 
  QModelIndexList indexList = selectedIndexes();
101
106
  // make sure the item we clicked on is first
102
 
  indexList.removeAll(index);
103
 
  indexList.prepend(index);
 
107
  if(indexList.contains(currentIndex())) {
 
108
    indexList.removeAll(currentIndex());
 
109
    indexList.prepend(currentIndex());
 
110
  }
 
111
 
 
112
  return indexList;
 
113
}
 
114
 
 
115
void NickView::showContextMenu(const QPoint &pos ) {
 
116
  Q_UNUSED(pos);
104
117
 
105
118
  QMenu contextMenu(this);
106
 
  Client::mainUi()->actionProvider()->addActions(&contextMenu, indexList);
 
119
  GraphicalUi::contextMenuActionProvider()->addActions(&contextMenu, selectedIndexes());
107
120
  contextMenu.exec(QCursor::pos());
108
121
}
109
122
 
158
171
NickViewDelegate::NickViewDelegate(QObject *parent)
159
172
  : QStyledItemDelegate(parent)
160
173
{
 
174
  UiSettings s("QtUiStyle/Colors");
 
175
  _FgOnlineStatus = s.value("onlineStatusFG", QVariant(QColor(Qt::black))).value<QColor>();
 
176
  _FgAwayStatus = s.value("awayStatusFG", QVariant(QColor(Qt::gray))).value<QColor>();
161
177
}
162
178
 
163
179
void NickViewDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const {
164
180
  QStyledItemDelegate::initStyleOption(option, index);
165
181
 
 
182
  if(!index.isValid())
 
183
    return;
 
184
 
 
185
  QColor fgColor = _FgOnlineStatus;
166
186
  if(!index.data(NetworkModel::ItemActiveRole).toBool())
167
 
    option->palette.setColor(QPalette::Text, option->palette.color(QPalette::Dark));
 
187
    fgColor = _FgAwayStatus;
 
188
 
 
189
  option->palette.setColor(QPalette::Text, fgColor);
168
190
}