1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 * kmail: KDE mail client
5 #include "configuredialoglistview.h"
7 #include <KLocalizedString>
10 ListView::ListView(QWidget
*parent
)
13 setAllColumnsShowFocus(true);
14 setAlternatingRowColors(true);
15 setSelectionMode(QAbstractItemView::SingleSelection
);
16 setRootIsDecorated(false);
17 setContextMenuPolicy(Qt::CustomContextMenu
);
18 connect(this, &ListView::customContextMenuRequested
, this, &ListView::slotContextMenu
);
21 void ListView::resizeEvent(QResizeEvent
*e
)
23 QTreeWidget::resizeEvent(e
);
27 void ListView::showEvent(QShowEvent
*e
)
29 QTreeWidget::showEvent(e
);
33 void ListView::resizeColums()
35 const int c
= columnCount();
40 const int w1
= viewport()->width();
41 const int w2
= w1
/ c
;
42 const int w3
= w1
- (c
- 1) * w2
;
44 for (int i
= 0; i
< c
- 1; ++i
) {
45 setColumnWidth(i
, w2
);
47 setColumnWidth(c
- 1, w3
);
50 void ListView::slotContextMenu(const QPoint
&pos
)
52 QMenu
*menu
= new QMenu(this);
53 menu
->addAction(i18n("Add"), this, SIGNAL(addHeader()));
55 menu
->addAction(i18n("Remove"), this, SIGNAL(removeHeader()));
57 menu
->exec(viewport()->mapToGlobal(pos
));