23 #include "katemodeconfigpage.moc" 
   33 #include "ui_filetypeconfigwidget.h" 
   36 #include <kmimetype.h> 
   37 #include <kmimetypechooser.h> 
   40 #include <knuminput.h> 
   44 #include <QtCore/QRegExp> 
   45 #include <QtGui/QCheckBox> 
   46 #include <QtGui/QComboBox> 
   47 #include <QtGui/QGroupBox> 
   49 #include <QtGui/QLabel> 
   50 #include <QtGui/QLayout> 
   51 #include <QtGui/QPushButton> 
   52 #include <QtGui/QToolButton> 
   55 #define KATE_FT_HOWMANY 1024 
   68   ui = 
new Ui::FileTypeConfigWidget();
 
   69   ui->setupUi( newWidget );
 
   81   indentationModes << 
i18n (
"Use Default");
 
   83   ui->cmbIndenter->addItems (indentationModes);
 
   85   connect( ui->cmbFiletypes, SIGNAL(activated(
int)), 
this, SLOT(typeChanged(
int)) );
 
   86   connect( ui->btnNew, SIGNAL(clicked()), 
this, SLOT(newType()) );
 
   87   connect( ui->btnDelete, SIGNAL(clicked()), 
this, SLOT(deleteType()) );
 
   88   ui->btnMimeTypes->setIcon(KIcon(
"tools-wizard"));
 
   89   connect(ui->btnMimeTypes, SIGNAL(clicked()), 
this, SLOT(showMTDlg()));
 
   90   connect( ui->btnDownload, SIGNAL(clicked()), 
this, SLOT(hlDownload()) );
 
   97   connect( ui->edtFileExtensions, SIGNAL(textChanged(
QString)), 
this, SLOT(
slotChanged()) );
 
   99   connect( ui->sbPriority, SIGNAL(valueChanged(
int)), 
this, SLOT(
slotChanged()) );
 
  100   connect( ui->cmbHl, SIGNAL(activated(
int)), 
this, SLOT(
slotChanged()) );
 
  101   connect( ui->cmbIndenter, SIGNAL(activated(
int)), 
this, SLOT(
slotChanged()) );
 
  109   qDeleteAll (m_types);
 
  125   qDeleteAll (m_types);
 
  149 void ModeConfigPage::update ()
 
  153   ui->cmbFiletypes->clear ();
 
  163   int currentIndex = 0;
 
  169       for (
int i = 0; i < m_types.
size(); ++i) {
 
  170         if (filetypeName == m_types[i]->name) {
 
  177   ui->cmbFiletypes->setCurrentIndex (currentIndex);
 
  178   typeChanged (currentIndex);
 
  180   ui->cmbFiletypes->setEnabled (ui->cmbFiletypes->count() > 0);
 
  183 void ModeConfigPage::deleteType ()
 
  185   int type = ui->cmbFiletypes->currentIndex ();
 
  187   if (type > -1 && type < m_types.
count())
 
  189     delete m_types[type];
 
  195 void ModeConfigPage::newType ()
 
  199   for (
int i = 0; i < m_types.
count(); ++i) {
 
  201     if (type->
name == newN)
 
  203       ui->cmbFiletypes->setCurrentIndex (i);
 
  219 void ModeConfigPage::save ()
 
  221   if (m_lastType != -1)
 
  223     if (!m_types[m_lastType]->hlGenerated) {
 
  224       m_types[m_lastType]->name = ui->edtName->text ();
 
  225       m_types[m_lastType]->section = ui->edtSection->text ();
 
  227     m_types[m_lastType]->varLine = ui->edtVariables->text ();
 
  228     m_types[m_lastType]->wildcards = ui->edtFileExtensions->text().split (
';', QString::SkipEmptyParts);
 
  229     m_types[m_lastType]->mimetypes = ui->edtMimeTypes->text().split (
';', QString::SkipEmptyParts);
 
  230     m_types[m_lastType]->priority = ui->sbPriority->value();
 
  231     m_types[m_lastType]->hl = ui->cmbHl->itemData(ui->cmbHl->currentIndex()).
toString();
 
  233     if (ui->cmbIndenter->currentIndex() > 0)
 
  236       m_types[m_lastType]->indenter = 
"";
 
  240 void ModeConfigPage::typeChanged (
int type)
 
  244   ui->cmbHl->setEnabled (
true);
 
  245   ui->btnDelete->setEnabled (
true);
 
  246   ui->edtName->setEnabled (
true);
 
  247   ui->edtSection->setEnabled (
true);
 
  249   if (type > -1 && type < m_types.
count())
 
  253     ui->gbProperties->setTitle (
i18n(
"Properties of %1",  ui->cmbFiletypes->currentText()));
 
  255     ui->gbProperties->setEnabled (
true);
 
  256     ui->btnDelete->setEnabled (
true);
 
  260     ui->edtVariables->setText(t->
varLine);
 
  263     ui->sbPriority->setValue(t->
priority);
 
  271     for (
int i = 0; i < ui->cmbHl->count(); ++i)
 
  272       if (ui->cmbHl->itemData (i).toString() == t->
hl)
 
  273         ui->cmbHl->setCurrentIndex (i);
 
  276     int indenterIndex = 0;
 
  279     ui->cmbIndenter->setCurrentIndex (indenterIndex);
 
  283     ui->gbProperties->setTitle (
i18n(
"Properties"));
 
  285     ui->gbProperties->setEnabled (
false);
 
  286     ui->btnDelete->setEnabled (
false);
 
  288     ui->edtName->clear();
 
  289     ui->edtSection->clear();
 
  290     ui->edtVariables->clear();
 
  291     ui->edtFileExtensions->clear();
 
  292     ui->edtMimeTypes->clear();
 
  293     ui->sbPriority->setValue(0);
 
  294     ui->cmbHl->setCurrentIndex (0);
 
  295     ui->cmbIndenter->setCurrentIndex (0);
 
  301 void ModeConfigPage::showMTDlg()
 
  303   QString text = 
i18n(
"Select the MimeTypes you want for this file type.\nPlease note that this will automatically edit the associated file extensions as well.");
 
  304   QStringList list = ui->edtMimeTypes->text().split( 
QRegExp(
"\\s*;\\s*"), QString::SkipEmptyParts );
 
  305   KMimeTypeChooserDialog d( 
i18n(
"Select Mime Types"), text, list, 
"text", 
this );
 
  306   if ( d.exec() == KDialog::Accepted ) {
 
  309     ui->edtFileExtensions->setText( d.chooser()->patterns().join(
";") );
 
  310     ui->edtMimeTypes->setText( d.chooser()->mimeTypes().join(
";") );
 
  314 void ModeConfigPage::hlDownload()
 
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional]) 
KateModeManager * modeManager()
global mode manager used to manage the modes centrally 
QObject * container()
Get the currently associated Container object. 
const T & at(int i) const
void save(const QList< KateFileType * > &v)
QString nameTranslated() const 
static KateGlobal * self()
Kate Part Internal stuff ;) 
QString join(const QString &separator) const
QString hlNameTranslated(int n)
ModeConfigPage(QWidget *parent)
int count(const T &value) const
void append(const T &value)
static uint modeNumber(const QString &name)
Maps name -> index. 
QString sectionTranslated() const 
char * toString(const T &value)
const QString & modeName() const 
mode name 
void prepend(const T &value)
KateDocument * doc()
accessor to katedocument pointer 
static KateHlManager * self()
static QStringList listModes()
List all possible modes by name, i.e.