[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: klfadvancedconfigeditor.cpp 866 2013-11-24 13:56:22Z phfaist $ */
23 
24 #include <QStandardItemModel>
25 #include <QStyledItemDelegate>
26 #include <QItemEditorFactory>
27 #include <QStandardItemEditorCreator>
28 #include <QMessageBox>
29 #include <QLineEdit>
30 
33 #include "klfadvancedconfigeditor_p.h"
34 
35 
36 
37 // --------------
38 
39 
40 #define REGISTER_EDITOR(factory, type, editorclass) \
41  { QItemEditorCreatorBase *anEditor = new QStandardItemEditorCreator<editorclass>(); \
42  factory->registerEditor(type, anEditor); }
43 
44 
45 
47  : QDialog(parent)
48 {
50 
51  d->pConfigBase = c;
52 
53  u = new Ui::KLFAdvancedConfigEditor;
54  u->setupUi(this);
55 
56  QItemEditorFactory *factory = new QItemEditorFactory;
57 
58  REGISTER_EDITOR(factory, QVariant::Color, KLFColorDialog);
59  REGISTER_EDITOR(factory, QVariant::Font, KLFFontDialog);
60 
61  d->pConfModel = new QStandardItemModel(this);
62  d->pConfModel->setColumnCount(3);
63  d->pConfModel->setHorizontalHeaderLabels(QStringList() << tr("Config Entry")
64  << tr("Current Value") << tr("Encoded Value Entry"));
65  u->configView->setModel(d->pConfModel);
66  KLFAdvancedConfigItemDelegate *delegate = new KLFAdvancedConfigItemDelegate(this);
67  delegate->setItemEditorFactory(factory);
68  u->configView->setItemDelegate(delegate);
69  u->configView->setColumnWidth(0, 200);
70  u->configView->setColumnWidth(1, 200);
71  u->configView->setColumnWidth(2, 200);
72 
73  KLFItemViewSearchTarget *searchtarget = new KLFItemViewSearchTarget(u->configView, this);
74  u->searchBar->setSearchTarget(searchtarget);
75  u->searchBar->registerShortcuts(this);
76 
77  connect(d->pConfModel, SIGNAL(itemChanged(QStandardItem *)),
78  d, SLOT(configEntryEdited(QStandardItem *)));
79 
80  // add "reset default value" action
81  QAction *resetDefault = new QAction(tr("Reset Default Value"), this);
82  connect(resetDefault, SIGNAL(triggered()),
83  d, SLOT(resetDefault()));
84  u->configView->addAction(resetDefault);
85  u->configView->setContextMenuPolicy(Qt::ActionsContextMenu);
86 }
87 
89 {
91 
92  delete u;
93 }
94 
96 {
97  if (visible) {
98  d->updateConfigView();
99  } else {
100  // unloadConfigView();
101  }
102  QDialog::setVisible(visible);
103 }
104 
105 
107 {
108  d->_are_resetting_config = true;
109  d->updateConfigView();
110  d->_are_resetting_config = false;
111 }
112 
113 
114 
virtual void setVisible(bool visible)
#define KLF_DELETE_PRIVATE
Definition: klfdefs.h:96
A dialog to let the user select a color.
KLFAdvancedConfigEditor(QWidget *parent, KLFConfigBase *c)
A search target (for KLFSearchBar) for standard item views.
#define REGISTER_EDITOR(factory, type, editorclass)
#define KLF_INIT_PRIVATE(ClassName)
Definition: klfdefs.h:94

Generated by doxygen 1.8.14