Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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