-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathFileTypeSettingsPage.cpp
68 lines (57 loc) · 2.59 KB
/
FileTypeSettingsPage.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
//-----------------------------------------------------------------------------
// File: FileTypeSettingsPage.cpp
//-----------------------------------------------------------------------------
// Project: Kactus 2
// Author: Joni-Matti Maatta
// Date: 13.6.2011
//
// Description:
// General settings property page.
//-----------------------------------------------------------------------------
#include "FileTypeSettingsPage.h"
#include "FileTypesDelegate.h"
#include <QFormLayout>
#include <QGroupBox>
#include <QLabel>
#include <QSizePolicy>
#include <QVBoxLayout>
//-----------------------------------------------------------------------------
// Function: FileTypeSettingsPage::FileTypeSettingsPage()
//-----------------------------------------------------------------------------
FileTypeSettingsPage::FileTypeSettingsPage(QSettings& settings):
SettingsPage(settings),
model_(settings, this),
proxyModel_(this),
view_(this),
ignoredExtensionsEdit_(this)
{
proxyModel_.setSourceModel(&model_);
view_.setItemDelegate(new FileTypesDelegate(this));
view_.setModel(&proxyModel_);
view_.setSortingEnabled(true);
view_.sortByColumn(0, Qt::AscendingOrder);
ignoredExtensionsEdit_.setText(settings.value("FileTypes/IgnoredExtensions").toString());
ignoredExtensionsEdit_.setToolTip(
tr("Specify all file extensions that should be ignored in file dependency analysis. "
"Multiple values can be given separated by a semi-colon e.g. \"jpg;png\"."));
QGroupBox* typesBox = new QGroupBox(tr("File types"), this);
QVBoxLayout* typeLayout = new QVBoxLayout(typesBox);
typeLayout->addWidget(&view_, 1);
QFormLayout* ignoreTypeLayout = new QFormLayout();
ignoreTypeLayout->addRow(tr("Ignored extensions:"), &ignoredExtensionsEdit_);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->addWidget(typesBox);
topLayout->addLayout(ignoreTypeLayout);
connect(&view_, SIGNAL(addItem(const QModelIndex&)),
&model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);
connect(&view_, SIGNAL(removeItem(const QModelIndex&)),
&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);
}
//-----------------------------------------------------------------------------
// Function: FileTypeSettingsPage::apply()
//-----------------------------------------------------------------------------
void FileTypeSettingsPage::apply()
{
model_.apply(settings());
settings().setValue("FileTypes/IgnoredExtensions", ignoredExtensionsEdit_.text());
}