void InputStrList::browseFiles()
{
  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
  QStringList fileNames = QFileDialog::getOpenFileNames();	

  if (!fileNames.isEmpty()) 
  {
    QStringList::Iterator it;
    for ( it= fileNames.begin(); it != fileNames.end(); ++it )
    {
      QString fileName;
      QDir dir(path);
      if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
      {
        fileName = dir.relativeFilePath(*it);
      }
      if (fileName.isEmpty())
      {
        fileName = *it;
      }
      m_lb->addItem(fileName);
      m_strList.append(fileName);
      m_value = m_strList;
      updateDefault();
      emit changed();
    }
    m_le->setText(m_strList[0]);
  }
}
Beispiel #2
0
void InputBool::setEnabled(bool b)
{ 
  m_enabled = b;
  m_cb->setEnabled(b); 
  m_lab->setEnabled(b); 
  updateDefault();
  updateDependencies();
}
Beispiel #3
0
void InputBool::update()
{
  QString v = m_value.toString().toLower();
  m_state = (v==QString::fromLatin1("yes")  ||
             v==QString::fromLatin1("true") ||
             v==QString::fromLatin1("1"));
  m_cb->setChecked( m_state );
  updateDefault();
  updateDependencies();
}
void InputStrList::setValue(const QStringList &sl)
{
  m_le->clear();
  m_lb->clear();
  m_strList = sl;
  for (int i=0;i<m_strList.size();i++)
  {
    m_lb->addItem(m_strList[i].trimmed());
  }
  updateDefault();
}
void InputStrList::addString()
{
  if (!m_le->text().isEmpty())
  {
    m_lb->addItem(m_le->text());
    m_strList.append(m_le->text());
    m_value = m_strList;
    updateDefault();
    emit changed();
    m_le->clear();
  }
}
void InputStrList::updateString()
{
  if (m_lb->currentRow()!=-1 && !m_le->text().isEmpty())
  {
    m_lb->currentItem()->setText(m_le->text());
    m_strList.insert(m_lb->currentRow(),m_le->text());
    m_strList.removeAt(m_lb->currentRow()+1);
    m_value = m_strList;
    updateDefault();
    emit changed();
  }
}
void InputStrList::delString()
{
  if (m_lb->currentRow()!=-1)
  {
    int itemIndex = m_lb->currentRow();
    delete m_lb->currentItem();
    m_strList.removeAt(itemIndex);
    m_value = m_strList;
    updateDefault();
    emit changed();
  }
}
Beispiel #8
0
void InputBool::setValue( bool s )
{
  if (m_state!=s) 
  {
    m_state=s;
    updateDefault();
    updateDependencies();
    m_cb->setChecked( s );
    m_value = m_state;
    emit changed();
  }
}
Beispiel #9
0
void InputInt::setValue(int val)
{
  val = qMax(m_minVal,val);
  val = qMin(m_maxVal,val);
  if (val!=m_val) 
  {
    m_val = val;
    m_sp->setValue(val);
    m_value = m_val;
    updateDefault();
  }
}
Beispiel #10
0
void InputStrList::setEnabled(bool state)
{
  m_lab->setEnabled(state);
  m_le->setEnabled(state);
  m_add->setEnabled(state);
  m_del->setEnabled(state);
  m_upd->setEnabled(state);
  m_lb->setEnabled(state);
  if (m_brFile) m_brFile->setEnabled(state);
  if (m_brDir)  m_brDir->setEnabled(state);
  updateDefault();
}
void InputStrList::browseDir()
{	
  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
  QString dirName = QFileDialog::getExistingDirectory();	

  if (!dirName.isNull()) 
  {
    QDir dir(path);
    if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
    {
      dirName = dir.relativeFilePath(dirName);
    }
    if (dirName.isEmpty())
    {
      dirName=QString::fromAscii(".");
    }
    m_lb->addItem(dirName);
    m_strList.append(dirName);
    m_value = m_strList;
    updateDefault();
    emit changed();
    m_le->setText(dirName);
  }
}
void WordUpdateStyles(WordConverter *converter, CSSSheet *styleSheet)
{
    CSSStyle *paraDefault = CSSSheetDefaultStyleForFamily(styleSheet,StyleFamilyParagraph);
    if (CSSGet(CSSStyleRule(paraDefault),"margin-top") == NULL)
        CSSPut(CSSStyleRule(paraDefault),"margin-top","-word-auto");

    if (CSSGet(CSSStyleRule(paraDefault),"margin-bottom") == NULL)
        CSSPut(CSSStyleRule(paraDefault),"margin-bottom","-word-auto");

    if (converter->package->styles == NULL) // FIXME: create this document
        return;;
    DFNode *root = converter->package->styles->root;
    if ((root == NULL) || (root->tag != WORD_STYLES))
        return;;

    DFHashTable *remainingSelectors = DFHashTableNew(NULL,NULL); // Used as a set
    const char **allSelectors = CSSSheetCopySelectors(styleSheet);
    for (int i = 0; allSelectors[i]; i++) {
        const char *selector = allSelectors[i];
        DFHashTableAdd(remainingSelectors,selector,"");
    }
    free(allSelectors);

    WordSheet *sheet = converter->styles;
    DFHashTable *oldConcreteNumIds = WordSheetFindUsedConcreteNumIds(sheet);
    updateNumbering(converter,styleSheet);

    // Update or remove existing styles
    const char **allIdents = WordSheetCopyIdents(sheet);
    for (int i = 0; allIdents[i]; i++) {
        WordStyle *wordStyle = WordSheetStyleForIdent(sheet,allIdents[i]);
        DFNode *element = wordStyle->element;

        if (WordStyleIsProtected(wordStyle)) {
            DFHashTableRemove(remainingSelectors,wordStyle->selector);
            continue;
        }

        if (!DFStringEquals(wordStyle->type,"paragraph") &&
            !DFStringEquals(wordStyle->type,"character") &&
            !DFStringEquals(wordStyle->type,"table"))
            continue;

        CSSStyle *cssStyle = CSSSheetLookupSelector(styleSheet,wordStyle->selector,0,0);
        if (cssStyle == NULL) {
            // Remove style
            WordSheetRemoveStyle(sheet,wordStyle);
            continue;
        }

        // Update style
        WordPutStyle(element,cssStyle,converter);
        updateDefault(cssStyle,element,styleSheet,converter);
        DFHashTableRemove(remainingSelectors,wordStyle->selector);
    }
    free(allIdents);

    // Sort the list of new styles, so that test output is deterministic
    const char **sortedSelectors = DFHashTableCopyKeys(remainingSelectors);
    DFSortStringsCaseInsensitive(sortedSelectors);

    // Add new styles. We do this in two stages - first creating the styles, and then setting their properties.
    // This is because the second stage depends on referenced styles (e.g. based on and next) to be already
    // present.
    for (int selIndex = 0; sortedSelectors[selIndex]; selIndex++) {
        const char *selector = sortedSelectors[selIndex];
        CSSStyle *style = CSSSheetLookupSelector(styleSheet,selector,0,0);
        const char *familyStr = NULL;

        StyleFamily family = WordStyleFamilyForSelector(selector);
        if (family == StyleFamilyParagraph)
            familyStr = "paragraph";
        else if (family == StyleFamilyCharacter)
            familyStr = "character";
        else if (family == StyleFamilyTable)
            familyStr = "table";
        else
            continue;

        char *styleId = WordStyleIdForStyle(style);
        char *name = WordStyleNameForStyle(style);
        if (name == NULL)
            name = xstrdup(styleId);;
        WordStyle *wordStyle = WordSheetAddStyle(sheet,familyStr,styleId,name,selector);
        DFCreateChildElement(wordStyle->element,WORD_QFORMAT);
        free(styleId);
        free(name);
    }

    for (int selIndex = 0; sortedSelectors[selIndex]; selIndex++) {
        const char *selector = sortedSelectors[selIndex];
        StyleFamily family = WordStyleFamilyForSelector(selector);
        if ((family != StyleFamilyParagraph) &&
            (family != StyleFamilyCharacter) &&
            (family != StyleFamilyTable))
            continue;

        CSSStyle *style = CSSSheetLookupSelector(styleSheet,selector,0,0);
        WordStyle *wordStyle = WordSheetStyleForSelector(converter->styles,selector);
        assert(wordStyle != NULL);

        CSSStyleAddDefaultHTMLProperties(style);
        // FIXME: language
        // FIXME: not covered by tests
        if ((style->headingLevel >= 1) && (style->headingLevel <= 6))
            CSSStyleSetNext(style,"p.Normal");

        WordPutStyle(wordStyle->element,style,converter);
        updateDefault(style,wordStyle->element,styleSheet,converter);
    }
    free(sortedSelectors);

    // Update body style (document defaults)
    updateDefaults(converter,styleSheet);

    updateBody(converter,styleSheet);

    DFHashTable *newConcreteNumIds = WordSheetFindUsedConcreteNumIds(sheet);
    const char **oldKeys = DFHashTableCopyKeys(oldConcreteNumIds);
    for (int oldIndex = 0; oldKeys[oldIndex]; oldIndex++) {
        const char *numId = oldKeys[oldIndex];
        if (DFHashTableLookup(newConcreteNumIds,numId) == NULL) {
            WordConcreteNum *concreteNum = WordNumberingConcreteWithId(converter->numbering,numId);
            if (concreteNum != NULL)
                WordNumberingRemoveConcrete(converter->numbering,concreteNum);
        }
    }
    free(oldKeys);
    DFHashTableRelease(remainingSelectors);
    DFHashTableRelease(oldConcreteNumIds);
    DFHashTableRelease(newConcreteNumIds);
}
Beispiel #13
0
void InputInt::setEnabled(bool state)
{
  m_lab->setEnabled(state);
  m_sp->setEnabled(state);
  updateDefault();
}