Logo Search packages:      
Sourcecode: kbib version File versions  Download package

void KBibEditEntryDlg::updateDlg ( QString  entryTypeName  ) 

No descriptions

Definition at line 345 of file kbibeditentrydlg.cpp.

References KBibDoc::getEntryList(), BibEntry::getField(), KBibDoc::getValueList(), GUI::FieldWidget::labelWidth(), GUI::LineFieldWidget::setAutoCompletion(), GUI::MultipleValueFieldWidget::setAutoCompletion(), and GUI::ParagraphFieldWidget::setAutoCompletion().

Referenced by slotEntryTypeChange().

{

      KBibApp* win = ( KBibApp* ) this->parent();
      KBibDoc* doc = win->getDocument();

      QStringList macroKeys = ( doc->getEntryList() )->getStringMacroKeys();


      if ( !rqFields.isEmpty() )
            rqFields.clear();
      if ( !optFields.isEmpty() )
            optFields.clear();

      if ( rqLayout )
            delete rqLayout;

      if ( optLayout )
            delete optLayout;

      abstractLabel->show();
      abstractEdit->hide();

      noteLabel->show();
      noteEdit->hide();


      rqLayout = new QVBoxLayout ( rqBox, 0, KDialog::spacingHint(), "reqBoxLayout" );
      rqLayout->setMargin ( 10 );

      optLayout = new QVBoxLayout ( optBox, 0, KDialog::spacingHint(), "optBoxLayout" );
      optLayout->setMargin ( 10 );


      if ( QString ( m_entry->getField ( QString::fromLatin1 ( "lockkey" ) ) ) =="Y" )
      {
            //lockKeyBttn->setText("Unlock Key");
            //QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("unlock"), KIcon::Small);
            //lockKeyBttn->setPixmap(pix);
            lockKeyBttn->setIconSet ( QIconSet ( SmallIcon ( "unlock" ) ) );
            lockKeyBttn->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum );
            QToolTip::add ( lockKeyBttn, QString ( i18n ( "Unlock the citation key" ) ) );
            createKeyBttn->setEnabled ( false );
            keyField->setEnabled ( false );

      }
      else
      {
            //lockKeyBttn->setText("Lock Key");
            //QPixmap pix = KGlobal::iconLoader()->loadIcon(QString::fromLatin1("lock"), KIcon::Small);
            //lockKeyBttn->setPixmap(pix);
            lockKeyBttn->setIconSet ( QIconSet ( SmallIcon ( "lock" ) ) );
            lockKeyBttn->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum );
            QToolTip::add ( lockKeyBttn, QString ( i18n ( "Lock the citation key" ) ) );
            createKeyBttn->setEnabled ( true );
            keyField->setEnabled ( true );
      }

      BibEntryDef *entryType = BibEntryDefTable::self()->getBibEntryDef ( entryTypeName );
      int nrq = entryType->numRequired();
      int maxLabelWidth = 0;
      int numEditField = 0;

      for ( int i = 0; i< nrq; i++ )
      {
            QString fn = entryType->getRequired ( i );
            if ( fn != QString::fromLatin1 ( "lockkey" ) )
            {
                  if ( fn == QString::fromLatin1 ( "abstract" ) )
                  {
                        abstractLabel->hide();
                        abstractEdit->show();
                  }
                  else if ( fn == QString::fromLatin1 ( "comment" ) )
                  {
                        noteLabel->hide();
                        noteEdit->show();
                  }
                  else
                  {
                        GUI::FieldWidget *fieldEdit;
                        RefField *field = BibEntryDefTable::self()->getRefField ( fn );
                        int type;
                        if ( field )
                              type = field->type;
                        else
                              type = TEXT;
                        switch ( type )
                        {
                              case PARAGRAPH:
                              {
                                    GUI::ParagraphFieldWidget *paraFieldWg = new  GUI::ParagraphFieldWidget ( fn, field, macroKeys, rqBox );
                                    if ( ( win->kbibConfigState ).autocompletion && field )
                                          paraFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = paraFieldWg;
                                    break;
                              }
                              case MULTIPLE:
                              {
                                    GUI::MultipleValueFieldWidget *multiValueFieldWg = new  GUI::MultipleValueFieldWidget ( fn, field, macroKeys, rqBox );
                                    if ( ( win->kbibConfigState ).autocompletion && field )
                                          multiValueFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = multiValueFieldWg;
                                    break;
                              }
                              case NUMBER:
                              {
                                    GUI::NumberFieldWidget *numberFieldWg = new  GUI::NumberFieldWidget ( fn, field, rqBox );
                                    fieldEdit = numberFieldWg;
                                    break;
                              }
                              case URL:
                              {
                                    GUI::UrlFieldWidget *urlFieldWg = new  GUI::UrlFieldWidget ( fn, field, macroKeys, rqBox );
                                    fieldEdit = urlFieldWg;
                                    break;
                              }
                              case MONTH:
                              {
                                    GUI::MonthFieldWidget *monthFieldWg = new  GUI::MonthFieldWidget ( fn, field, rqBox );
                                    fieldEdit = monthFieldWg;
                                    break;
                              }
                              
                              default:
                              {
                                    GUI::LineFieldWidget *lineFieldWg = new  GUI::LineFieldWidget ( fn, field, macroKeys, rqBox );
                                    if ( ( win->kbibConfigState ).autocompletion && field )
                                          lineFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = lineFieldWg;
                                    break;
                              }

                        }

                        fieldEdit->show();
                        rqFields.append ( fieldEdit );
                        rqLayout->addWidget ( fieldEdit );

                        int w = fieldEdit->labelWidth();
                        if ( w > maxLabelWidth )
                              maxLabelWidth = w;
                        numEditField++;

                  }
            }
      }

      //Resize labels
      for ( GUI::FieldWidget *field = rqFields.first(); field; field = rqFields.next() )
      {
            field->setLabelWidth ( maxLabelWidth );
      }

      rqLayout->addStretch ( 1 );

      if ( numEditField )
            reqTab->show();
      else
            reqTab->hide();

      int nopt = entryType->numOptional();
      numEditField = 0;
      maxLabelWidth = 0;
      for ( int i = 0; i< nopt; i++ )
      {
            QString fn = ( entryType->getOptional ( i ) ).lower();

            if ( fn != QString::fromLatin1 ( "lockkey" ) )
            {
                  if ( fn == QString::fromLatin1 ( "abstract" ) )
                  {
                        abstractLabel->hide();
                        abstractEdit->show();
                  }
                  else if ( fn == QString::fromLatin1 ( "comment" ) )
                  {
                        noteLabel->hide();
                        noteEdit->show();
                  }
                  else
                  {

                        GUI::FieldWidget *fieldEdit;
                        RefField *field = BibEntryDefTable::self()->getRefField ( fn );
                        int type;
                        if ( field )
                              type = field->type;
                        else
                              type = TEXT;
                        switch ( type )
                        {
                              case PARAGRAPH:
                              {
                                    GUI::ParagraphFieldWidget *paraFieldWg = new  GUI::ParagraphFieldWidget ( fn, field, macroKeys, optBox );
                                    if ( ( win->kbibConfigState ).autocompletion )
                                          paraFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = paraFieldWg;
                                    break;
                              }
                              case MULTIPLE:
                              {
                                    GUI::MultipleValueFieldWidget *multiValueFieldWg = new  GUI::MultipleValueFieldWidget ( fn, field, macroKeys, optBox );
                                    if ( ( win->kbibConfigState ).autocompletion )
                                          multiValueFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = multiValueFieldWg;
                                    break;
                              }
                              case NUMBER:
                              {
                                    GUI::NumberFieldWidget *numberFieldWg = new  GUI::NumberFieldWidget ( fn, field, optBox );
                                    fieldEdit = numberFieldWg;
                                    break;
                              }
                              case URL:
                              {
                                    GUI::UrlFieldWidget *urlFieldWg = new  GUI::UrlFieldWidget ( fn, field, macroKeys, optBox );
                                    fieldEdit = urlFieldWg;
                                    break;
                              }
                              case MONTH:
                              {
                                    GUI::MonthFieldWidget *monthFieldWg = new  GUI::MonthFieldWidget ( fn, field, optBox );
                                    fieldEdit = monthFieldWg;
                                    break;
                              }
                              default:
                              {
                                    GUI::LineFieldWidget *lineFieldWg = new  GUI::LineFieldWidget ( fn, field, macroKeys, optBox );
                                    if ( ( win->kbibConfigState ).autocompletion )
                                          lineFieldWg->setAutoCompletion ( doc->getValueList ( fn ) );
                                    fieldEdit = lineFieldWg;
                                    break;
                              }

                        }

                        int w = fieldEdit->labelWidth();
                        if ( w > maxLabelWidth )
                              maxLabelWidth = w;

                        fieldEdit->show();


                        optFields.append ( fieldEdit );
                        optLayout->addWidget ( fieldEdit );



                        numEditField++;



                  }

            }

      }
      //Resize labels
      for ( GUI::FieldWidget *field = optFields.first(); field; field = optFields.next() )
      {
            field->setLabelWidth ( maxLabelWidth );
      }

      optLayout->addStretch ( 1 );
      if ( numEditField == 0 )
            optTab->hide();
      else
            optTab->show();
}


Generated by  Doxygen 1.6.0   Back to index