mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Switch between Tree / list on column - click.
This patch adds support for switching Tree / List while clicking on a column header. This triggers a sad-painting bug on the list - I guess I'll have to fix it too. I'd apreciate some help on it, tougth. next: keep the selection. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
c6f84de37c
commit
4019fdaa24
2 changed files with 15 additions and 3 deletions
|
@ -24,16 +24,26 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
setModel(model);
|
setModel(model);
|
||||||
setSortingEnabled(false);
|
setSortingEnabled(false);
|
||||||
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
connect(header(), SIGNAL(sectionClicked(int)), this, SLOT(headerClicked(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::reload()
|
void DiveListView::headerClicked(int i )
|
||||||
|
{
|
||||||
|
if (i == (int) TreeItemDT::NR){
|
||||||
|
reload(DiveTripModel::TREE);
|
||||||
|
}else{
|
||||||
|
reload(DiveTripModel::LIST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveListView::reload(DiveTripModel::Layout layout)
|
||||||
{
|
{
|
||||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||||
QAbstractItemModel *oldModel = m->sourceModel();
|
QAbstractItemModel *oldModel = m->sourceModel();
|
||||||
if (oldModel)
|
if (oldModel)
|
||||||
oldModel->deleteLater();
|
oldModel->deleteLater();
|
||||||
DiveTripModel *tripModel = new DiveTripModel(this);
|
DiveTripModel *tripModel = new DiveTripModel(this);
|
||||||
tripModel->setLayout(DiveTripModel::LIST);
|
tripModel->setLayout(layout);
|
||||||
|
|
||||||
m->setSourceModel(tripModel);
|
m->setSourceModel(tripModel);
|
||||||
sortByColumn(0, Qt::DescendingOrder);
|
sortByColumn(0, Qt::DescendingOrder);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
#include "models.h"
|
||||||
|
|
||||||
class DiveListView : public QTreeView
|
class DiveListView : public QTreeView
|
||||||
{
|
{
|
||||||
|
@ -28,11 +29,12 @@ public:
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void keyReleaseEvent(QKeyEvent*);
|
void keyReleaseEvent(QKeyEvent*);
|
||||||
void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
|
void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
|
||||||
void reload();
|
void reload(DiveTripModel::Layout layout = DiveTripModel::TREE);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleColumnVisibilityByIndex();
|
void toggleColumnVisibilityByIndex();
|
||||||
void reloadHeaderActions();
|
void reloadHeaderActions();
|
||||||
|
void headerClicked(int);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void currentDiveChanged(int divenr);
|
void currentDiveChanged(int divenr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue