-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwordsview.cpp
31 lines (28 loc) · 928 Bytes
/
wordsview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ******************************************************
// * copyright (C) 2017 by Reinhardt Behm/rbehm@hushmail.com
// * All Rights reserved
// * created 1/25/2017 by behm
// ******************************************************
#include "wordsview.h"
#include "wordsmodel.h"
WordsView::WordsView(WordsModel *model, QWidget *parent)
: QTableView(parent)
, m_model(model)
{
setModel(model);
QHeaderView *header = horizontalHeader();
for (int i = 0; i < header->count(); ++i)
{
header->setSectionResizeMode(i, QHeaderView::ResizeToContents);
}
header->setStretchLastSection(true);
QAction *sort = new QAction("Sort", this);
sort->setShortcut(QKeySequence("Alt+S"));
addAction(sort);
connect(sort, &QAction::triggered, m_model, &WordsModel::sort);
setContextMenuPolicy(Qt::ActionsContextMenu);
}
void WordsView::currentChanged(const QModelIndex ¤t, const QModelIndex &)
{
emit currentMoved(current);
}