[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 <QAction>
25 #include <QStandardItemModel>
26 #include <QStyledItemDelegate>
27 #include <QItemEditorFactory>
28 #include <QStandardItemEditorCreator>
29 #include <QMessageBox>
30 #include <QLineEdit>
31 
34 #include "klfadvancedconfigeditor_p.h"
35 
36 
37 
38 // --------------
39 
40 
41 #define REGISTER_EDITOR(factory, type, editorclass) \
42  { QItemEditorCreatorBase *anEditor = new QStandardItemEditorCreator<editorclass>(); \
43  factory->registerEditor(type, anEditor); }
44 
45 
46 
48  : QDialog(parent)
49 {
51 
52  d->pConfigBase = c;
53 
54  u = new Ui::KLFAdvancedConfigEditor;
55  u->setupUi(this);
56 
57  QItemEditorFactory *factory = new QItemEditorFactory;
58 
59  REGISTER_EDITOR(factory, QVariant::Color, KLFColorDialog);
60  REGISTER_EDITOR(factory, QVariant::Font, KLFFontDialog);
61 
62  d->pConfModel = new QStandardItemModel(this);
63  d->pConfModel->setColumnCount(3);
64  d->pConfModel->setHorizontalHeaderLabels(QStringList() << tr("Config Entry")
65  << tr("Current Value") << tr("Encoded Value Entry"));
66  u->configView->setModel(d->pConfModel);
67  KLFAdvancedConfigItemDelegate *delegate = new KLFAdvancedConfigItemDelegate(this);
68  delegate->setItemEditorFactory(factory);
69  u->configView->setItemDelegate(delegate);
70  u->configView->setColumnWidth(0, 200);
71  u->configView->setColumnWidth(1, 200);
72  u->configView->setColumnWidth(2, 200);
73 
74  KLFItemViewSearchTarget *searchtarget = new KLFItemViewSearchTarget(u->configView, this);
75  u->searchBar->setSearchTarget(searchtarget);
76  u->searchBar->registerShortcuts(this);
77 
78  connect(d->pConfModel, SIGNAL(itemChanged(QStandardItem *)),
79  d, SLOT(configEntryEdited(QStandardItem *)));
80 
81  // add "reset default value" action
82  QAction *resetDefault = new QAction(tr("Reset Default Value"), this);
83  connect(resetDefault, SIGNAL(triggered()),
84  d, SLOT(resetDefault()));
85  u->configView->addAction(resetDefault);
86  u->configView->setContextMenuPolicy(Qt::ActionsContextMenu);
87 }
88 
90 {
92 
93  delete u;
94 }
95 
97 {
98  if (visible) {
99  d->updateConfigView();
100  } else {
101  // unloadConfigView();
102  }
103  QDialog::setVisible(visible);
104 }
105 
106 
108 {
109  d->_are_resetting_config = true;
110  d->updateConfigView();
111  d->_are_resetting_config = false;
112 }
113 
114 
115 
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.13