00001
00006 #ifndef HSYNTAXHIGHLIGHTERSETTINGSDIALOG_H
00007 #define HSYNTAXHIGHLIGHTERSETTINGSDIALOG_H
00008
00009 #include <QtGui/QDialog>
00010 #include <QtGui/QLineEdit>
00011 #include <QtGui/QRadioButton>
00012 #include <QtGui/QInputDialog>
00013 #include <QtGui/QMessageBox>
00014
00015 #include "ui_HSyntaxHighlighterDialog.h"
00016 #include "HSyntaxHighlighterSettings.h"
00017 #include "HSyntaxHighlighterNewBlock.h"
00018 #include "HighlightBlock.h"
00029 class HSyntaxHighlighterDialog : public QDialog
00030 {
00031 Q_OBJECT
00032 private:
00037 HSyntaxHighlighterDialog(const HSyntaxHighlighterDialog&);
00038
00039 Ui::HSyntaxHighlighterDialogClass userInterface;
00040 HSyntaxHighlighterSettings settings;
00041
00044 void constructBlockList();
00045 private slots:
00051 void editedItemChanged(const QString& _name);
00055 void addNewItem()
00056 {
00057 HSyntaxHighlighterNewBlock dialog(&settings,this);
00058 if (dialog.exec()==QDialog::Accepted)
00059 {
00060 constructBlockList();
00061 QListWidgetItem * tmp= userInterface.HighlightBlocks->findItems(dialog.getName(),Qt::MatchFixedString).at(0);
00062 userInterface.HighlightBlocks->setCurrentItem(tmp);
00063 }
00064 }
00065
00069 void removeCurrentItem()
00070 {
00071 if(userInterface.HighlightBlocks->count() >0)
00072 {
00073 QString name=userInterface.HighlightBlocks->currentItem()->text();
00074 if (QMessageBox::Ok==QMessageBox::question(this,"Deleting block","Are you sure to delete block: "+name+"?",QMessageBox::Ok | QMessageBox::Cancel))
00075 {
00076 settings.removeBlock(name);
00077 constructBlockList();
00078 }
00079 }
00080 }
00081
00085 void renameCurrentItem()
00086 {
00087 if(userInterface.HighlightBlocks->count() >0)
00088 {
00089 QString curr=userInterface.HighlightBlocks->currentItem()->text();
00090 bool ok;
00091 QString text = QInputDialog::getText(this,"Renaming highlight block","Enter a new name for an "+curr+" highlight block"
00092 , QLineEdit::Normal,
00093 curr, &ok);
00094 if (ok && !text.isEmpty())
00095 if(curr!=text)
00096 if(settings.blockExists(text))
00097 {
00098 QMessageBox::warning(this,"Error while renaming","Renaming "+curr+" to "+" "+text+" failed, because name must be unique");
00099 }
00100 else
00101 {
00102 settings.renameBlock(curr,text);
00103 constructBlockList();
00104 }
00105 }
00106 }
00107 public:
00113 HSyntaxHighlighterDialog(QWidget *parent = 0);
00118 ~HSyntaxHighlighterDialog();
00119
00126 HSyntaxHighlighterSettings getSettings();
00127
00134 void setSettings(HSyntaxHighlighterSettings _settings);
00135
00136 };
00137
00138 #endif // HSYNTAXHIGHLIGHTERSETTINGSDIALOG_H