-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilcolumndialog.cpp
109 lines (92 loc) · 3.48 KB
/
utilcolumndialog.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/***************************************************************************//**
* @file
* Util Column Dialog
*
* @version @n 1.0
* @date @n 6/10/2014
*
* @author @n Kwabena W. Agyeman
* @copyright @n (c) 2014 Kwabena W. Agyeman
* @n All rights reserved - Please see the end of the file for the terms of use
*
* @par Update History:
* @n v1.0 - Original release - 6/10/2014
*******************************************************************************/
// NOTE: Bug https://bugreports.qt-project.org/browse/QTBUG-2329 makes
// QColumnView unusable so QTreeView is used instead...
#include "utilcolumndialog.h"
#include "ui_utilcolumndialog.h"
UtilColumnDialog::UtilColumnDialog(const QString &title,
QWidget *parent) : QDialog(parent), m_ui(new Ui::UtilColumnDialog)
{
m_ui->setupUi(this); setWindowTitle(title); setObjectName(title);
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint |
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::Dialog);
}
UtilColumnDialog::~UtilColumnDialog()
{
delete m_ui;
}
void UtilColumnDialog::setModel(QAbstractItemModel *model)
{
m_ui->columnView->setModel(model);
}
QAbstractItemModel *UtilColumnDialog::getModel() const
{
return m_ui->columnView->model();
}
void UtilColumnDialog::setCurrentIndex(const QModelIndex &index)
{
m_ui->columnView->setCurrentIndex(index);
}
QModelIndex UtilColumnDialog::getCurrentIndex() const
{
return m_ui->columnView->currentIndex();
}
void UtilColumnDialog::setText(const QString &text)
{
m_ui->descriptionLabel->setText(text);
}
QString UtilColumnDialog::getText() const
{
return m_ui->descriptionLabel->text();
}
void UtilColumnDialog::selectionChanged()
{
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(
getCurrentIndex().flags() & Qt::ItemIsSelectable);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
getCurrentIndex().flags() & Qt::ItemIsSelectable);
}
void UtilColumnDialog::showEvent(QShowEvent *event)
{
if(m_ui->columnView->selectionModel())
{
connect(m_ui->columnView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged()));
}
m_ui->columnView->setFocus();
QDialog::showEvent(event);
}
/***************************************************************************//**
* @file
* @par MIT License - TERMS OF USE:
* @n Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitati on the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* @n
* @n The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* @n
* @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*******************************************************************************/