[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfadvancedconfigeditor.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * file klfadvancedconfigeditor.cpp
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2012 by Philippe Faist
5 * philippe.faist at bluewin.ch
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22/* $Id$ */
23
24#include <QAction>
25#include <QStandardItemModel>
26#include <QStyledItemDelegate>
27#include <QItemEditorFactory>
28#include <QStandardItemEditorCreator>
29#include <QMessageBox>
30#include <QLineEdit>
31#include <QAction>
32
35#include "klfadvancedconfigeditor_p.h"
36
37
38
39// --------------
40
41
42#define REGISTER_EDITOR(factory, type, editorclass) \
43 { QItemEditorCreatorBase *anEditor = new QStandardItemEditorCreator<editorclass>(); \
44 factory->registerEditor(type, anEditor); }
45
46
47
49 : QDialog(parent)
50{
52
53 d->pConfigBase = c;
54
55 u = new Ui::KLFAdvancedConfigEditor;
56 u->setupUi(this);
57
58 QItemEditorFactory *factory = new QItemEditorFactory;
59
60 REGISTER_EDITOR(factory, QVariant::Color, KLFColorDialog);
61 REGISTER_EDITOR(factory, QVariant::Font, KLFFontDialog);
62
63 d->pConfModel = new QStandardItemModel(this);
64 d->pConfModel->setColumnCount(3);
65 d->pConfModel->setHorizontalHeaderLabels(QStringList() << tr("Config Entry")
66 << tr("Current Value") << tr("Encoded Value Entry"));
67 u->configView->setModel(d->pConfModel);
68 KLFAdvancedConfigItemDelegate *delegate = new KLFAdvancedConfigItemDelegate(this);
69 delegate->setItemEditorFactory(factory);
70 u->configView->setItemDelegate(delegate);
71 u->configView->setColumnWidth(0, 200);
72 u->configView->setColumnWidth(1, 200);
73 u->configView->setColumnWidth(2, 200);
74
75 KLFItemViewSearchTarget *searchtarget = new KLFItemViewSearchTarget(u->configView, this);
76 u->searchBar->setSearchTarget(searchtarget);
77 u->searchBar->registerShortcuts(this);
78
79 connect(d->pConfModel, SIGNAL(itemChanged(QStandardItem *)),
80 d, SLOT(configEntryEdited(QStandardItem *)));
81
82 // add "reset default value" action
83 QAction *resetDefault = new QAction(tr("Reset Default Value"), this);
84 connect(resetDefault, SIGNAL(triggered()),
85 d, SLOT(resetDefault()));
86 u->configView->addAction(resetDefault);
87 u->configView->setContextMenuPolicy(Qt::ActionsContextMenu);
88}
89
96
98{
99 if (visible) {
100 d->updateConfigView();
101 } else {
102 // unloadConfigView();
103 }
104 QDialog::setVisible(visible);
105}
106
107
109{
110 d->_are_resetting_config = true;
111 d->updateConfigView();
112 d->_are_resetting_config = false;
113}
114
115
116
KLFAdvancedConfigEditor(QWidget *parent, KLFConfigBase *c)
virtual void setVisible(bool visible)
A dialog to let the user select a color.
A search target (for KLFSearchBar) for standard item views.
#define REGISTER_EDITOR(factory, type, editorclass)
#define KLF_DELETE_PRIVATE
Definition klfdefs.h:96
#define KLF_INIT_PRIVATE(ClassName)
Definition klfdefs.h:94

Generated by doxygen 1.9.8