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
|
#include "DictionaryOptionsDialog.h"
#include "../dictionary/CardPack.h"
#include "FieldsPage.h"
#include "PacksPage.h"
#include "FieldsListModel.h"
DictionaryOptionsDialog::DictionaryOptionsDialog( Dictionary* aDict, QWidget* aParent ):
QDialog( aParent ), m_origDictPtr( aDict )
{
initData();
createPages();
QDialogButtonBox* okCancelBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal );
connect( okCancelBox, SIGNAL(accepted()), this, SLOT(accept()) );
connect( okCancelBox, SIGNAL(rejected()), this, SLOT(reject()) );
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(createDictPathLabel());
mainLayout->addWidget( m_pages );
mainLayout->addWidget( okCancelBox );
setLayout( mainLayout );
setWindowTitle( tr("Dictionary options") );
}
DictionaryOptionsDialog::~DictionaryOptionsDialog()
{
delete m_emptyField;
}
QSize DictionaryOptionsDialog::sizeHint() const
{
return QSize(700, 400);
}
QLabel* DictionaryOptionsDialog::createDictPathLabel()
{
const int MaxPathLength = 500;
QLabel* dictPathLabel = new QLabel;
QFontMetrics metrics(dictPathLabel->font());
QString dictPath = QDir::toNativeSeparators(m_origDictPtr->getFilePath());
dictPath = metrics.elidedText(dictPath, Qt::ElideMiddle, MaxPathLength);
dictPathLabel->setText("<b>" + tr("File name") + "</b>: " + dictPath);
return dictPathLabel;
}
void DictionaryOptionsDialog::initData()
{
m_dict.setDictConfig( m_origDictPtr );
m_emptyField = new Field();
m_fieldsListModel = new FieldsListModel( this );
}
void DictionaryOptionsDialog::createPages()
{
m_pages = new QTabWidget;
m_pages->addTab( new FieldsPage( this ), QIcon(":/images/fields.png"), tr("Fields") );
m_pages->addTab( new PacksPage( this ), QIcon(":/images/word-drill.png"), tr("Card packs") );
}
|