[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klftools/klfadvancedconfigeditor.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfadvancedconfigeditor.cpp
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2012 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id$ */
00023 
00024 #include <QAction>
00025 #include <QStandardItemModel>
00026 #include <QStyledItemDelegate>
00027 #include <QItemEditorFactory>
00028 #include <QStandardItemEditorCreator>
00029 #include <QMessageBox>
00030 #include <QLineEdit>
00031 
00032 #include <klfitemviewsearchtarget.h>
00033 #include "klfadvancedconfigeditor.h"
00034 #include "klfadvancedconfigeditor_p.h"
00035 
00036 
00037 
00038 // --------------
00039 
00040 
00041 #define REGISTER_EDITOR(factory, type, editorclass)                     \
00042   { QItemEditorCreatorBase *anEditor = new QStandardItemEditorCreator<editorclass>(); \
00043     factory->registerEditor(type, anEditor); }
00044 
00045 
00046 
00047 KLFAdvancedConfigEditor::KLFAdvancedConfigEditor(QWidget *parent, KLFConfigBase *c)
00048   : QDialog(parent)
00049 {
00050   KLF_INIT_PRIVATE(KLFAdvancedConfigEditor) ;
00051 
00052   d->pConfigBase = c;
00053 
00054   u = new Ui::KLFAdvancedConfigEditor;
00055   u->setupUi(this);
00056   
00057   QItemEditorFactory *factory = new QItemEditorFactory;
00058 
00059   REGISTER_EDITOR(factory, QVariant::Color, KLFColorDialog);
00060   REGISTER_EDITOR(factory, QVariant::Font, KLFFontDialog);
00061   
00062   d->pConfModel = new QStandardItemModel(this);
00063   d->pConfModel->setColumnCount(3);
00064   d->pConfModel->setHorizontalHeaderLabels(QStringList() << tr("Config Entry")
00065                                            << tr("Current Value") << tr("Encoded Value Entry"));
00066   u->configView->setModel(d->pConfModel);
00067   KLFAdvancedConfigItemDelegate *delegate = new KLFAdvancedConfigItemDelegate(this);
00068   delegate->setItemEditorFactory(factory);
00069   u->configView->setItemDelegate(delegate);
00070   u->configView->setColumnWidth(0, 200);
00071   u->configView->setColumnWidth(1, 200);
00072   u->configView->setColumnWidth(2, 200);
00073   
00074   KLFItemViewSearchTarget *searchtarget = new KLFItemViewSearchTarget(u->configView, this);
00075   u->searchBar->setSearchTarget(searchtarget);
00076   u->searchBar->registerShortcuts(this);
00077 
00078   connect(d->pConfModel, SIGNAL(itemChanged(QStandardItem *)),
00079           d, SLOT(configEntryEdited(QStandardItem *)));
00080 
00081   // add "reset default value" action
00082   QAction *resetDefault = new QAction(tr("Reset Default Value"), this);
00083   connect(resetDefault, SIGNAL(triggered()),
00084           d, SLOT(resetDefault()));
00085   u->configView->addAction(resetDefault);
00086   u->configView->setContextMenuPolicy(Qt::ActionsContextMenu);
00087 }
00088 
00089 KLFAdvancedConfigEditor::~KLFAdvancedConfigEditor()
00090 {
00091   KLF_DELETE_PRIVATE ;
00092 
00093   delete u;
00094 }
00095 
00096 void KLFAdvancedConfigEditor::setVisible(bool visible)
00097 {
00098   if (visible) {
00099     d->updateConfigView();
00100   } else {
00101     //      unloadConfigView();
00102   }
00103   QDialog::setVisible(visible);
00104 }
00105 
00106 
00107 void KLFAdvancedConfigEditor::updateConfig()
00108 {
00109   d->_are_resetting_config = true;
00110   d->updateConfigView();
00111   d->_are_resetting_config = false;
00112 }
00113 
00114 
00115 

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net