-void BufferView::setupMenuActions() {
- _menuActions.addAction("ConnectNet", new Action(SmallIcon("network-connect"), tr("Connect"), this));
- _menuActions.addAction("DisconnectNet", new Action(SmallIcon("network-disconnect"), tr("Disconnect"), this));
- _menuActions.addAction("JoinChannel", new Action(tr("Join Channel"), this));
- _menuActions.addAction("JoinBuffer", new Action(tr("Join"), this));
- _menuActions.addAction("PartBuffer", new Action(tr("Part"), this));
- _menuActions.addAction("HideBuffersTemporarily", new Action(tr("Hide Buffers"), this));
- _menuActions.addAction("HideBuffersPermanently", new Action(tr("Hide Buffers Permanently"), this));
- _menuActions.addAction("RemoveBuffer", new Action(tr("Delete Buffer"), this));
- _menuActions.addAction("IgnoreList", new Action(tr("Ignore List"), this));
- _menuActions.addAction("HideJoin", new Action(tr("Joins"), this))->setCheckable(true);
- _menuActions.addAction("HidePart", new Action(tr("Parts"), this))->setCheckable(true);
- _menuActions.addAction("HideQuit", new Action(tr("Quits"), this))->setCheckable(true);
- _menuActions.addAction("HideNick", new Action(tr("Nick Changes"), this))->setCheckable(true);
- _menuActions.addAction("HideMode", new Action(tr("Mode Changes"), this))->setCheckable(true);
- _menuActions.addAction("HideDayChange", new Action(tr("Day Change"), this))->setCheckable(true);
-
- connect(&_menuActions, SIGNAL(actionTriggered(QAction *)), SLOT(actionTriggered(QAction *)));
-}
-
-void BufferView::setModel(QAbstractItemModel *model) {
- delete selectionModel();
-
- QTreeView::setModel(model);
- init();
- // remove old Actions
- QList<QAction *> oldactions = header()->actions();
- foreach(QAction *action, oldactions) {
- header()->removeAction(action);
- action->deleteLater();
- }
-
- if(!model)
- return;
-
- QString sectionName;
- QAction *showSection;
- for(int i = 1; i < model->columnCount(); i++) {
- sectionName = (model->headerData(i, Qt::Horizontal, Qt::DisplayRole)).toString();
- showSection = new QAction(sectionName, header());
- showSection->setCheckable(true);
- showSection->setChecked(!isColumnHidden(i));
- showSection->setProperty("column", i);
- connect(showSection, SIGNAL(toggled(bool)), this, SLOT(toggleHeader(bool)));
- header()->addAction(showSection);
- }
-
-}
-
-void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config) {
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
- if(filter) {
- filter->setConfig(config);
- setConfig(config);
- return;
- }
-
- if(model()) {
- disconnect(this, 0, model(), 0);
- disconnect(model(), 0, this, 0);
- }
-
- if(!model_) {
- setModel(model_);
- } else {
- BufferViewFilter *filter = new BufferViewFilter(model_, config);
- setModel(filter);
- connect(filter, SIGNAL(configChanged()), this, SLOT(on_configChanged()));
- }
- setConfig(config);
-}
-
-void BufferView::setSelectionModel(QItemSelectionModel *selectionModel) {
- if(QTreeView::selectionModel())
- disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
-
- QTreeView::setSelectionModel(selectionModel);
- BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
- if(filter) {
- connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
- }
-}
-
-void BufferView::setConfig(BufferViewConfig *config) {
- if(_config == config)
- return;
-
- if(_config) {
- disconnect(_config, 0, this, 0);
- }
-
- _config = config;
- if(config) {
- connect(config, SIGNAL(networkIdSet(const NetworkId &)), this, SLOT(setRootIndexForNetworkId(const NetworkId &)));
- setRootIndexForNetworkId(config->networkId());
- } else {
- setRootIndex(QModelIndex());
- }
-}
-
-void BufferView::setRootIndexForNetworkId(const NetworkId &networkId) {
- if(!networkId.isValid() || !model()) {
- setRootIndex(QModelIndex());
- } else {
- int networkCount = model()->rowCount();
- QModelIndex child;
- for(int i = 0; i < networkCount; i++) {
- child = model()->index(i, 0);
- if(networkId == model()->data(child, NetworkModel::NetworkIdRole).value<NetworkId>())
- setRootIndex(child);