Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshsoundtextcolumn.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshsoundtextlevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshleveltypes.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshSoundTextColumn::TXshSoundTextColumn() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshSoundTextColumn::~TXshSoundTextColumn() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshColumn::ColumnType TXshSoundTextColumn::getColumnType() const {
Shinya Kitaoka 120a6e
  return eSoundTextType;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextColumn::createSoundTextLevel(int row,
Shinya Kitaoka 120a6e
                                               QList<qstring> textList) {</qstring>
Shinya Kitaoka 120a6e
  TXshSoundTextLevel *level = new TXshSoundTextLevel();
Shinya Kitaoka 120a6e
  level->setType(SND_TXT_XSHLEVEL);
Shinya Kitaoka 120a6e
  TXshCell cell;
Shinya Kitaoka 120a6e
  for (int i = 0; i < textList.size(); i++, row++) {
Shinya Kitaoka 120a6e
    QString str     = textList.at(i);
Shinya Kitaoka 120a6e
    QString precStr = (i > 0) ? level->getFrameText(i - 1) : QString();
Shinya Kitaoka 120a6e
    if (str == QString("<none>")) {</none>
Shinya Kitaoka 120a6e
      if (i > 0) {
Shinya Kitaoka 120a6e
        setCell(row, cell);
Shinya Kitaoka 120a6e
        continue;
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        str = QString();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    level->setFrameText(i, str);
Shinya Kitaoka 120a6e
    TFrameId fid(i + 1);
Shinya Kitaoka 120a6e
    cell = TXshCell(level, fid);
Shinya Kitaoka 120a6e
    setCell(row, cell);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool TXshSoundTextColumn::canSetCell(const TXshCell &cell) const {
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshColumn *TXshSoundTextColumn::clone() const {
Shinya Kitaoka 120a6e
  TXshSoundTextColumn *column = new TXshSoundTextColumn();
Shinya Kitaoka 120a6e
  column->setXsheet(getXsheet());
Shinya Kitaoka 120a6e
  column->setStatusWord(getStatusWord());
Shinya Kitaoka 120a6e
  column->m_cells = m_cells;
Shinya Kitaoka 120a6e
  column->m_first = m_first;
Shinya Kitaoka 120a6e
  return column;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextColumn::loadData(TIStream &is) {
Shinya Kitaoka 120a6e
  std::string tagName;
Shinya Kitaoka 120a6e
  while (is.openChild(tagName)) {
Shinya Kitaoka 120a6e
    if (tagName == "cells") {
Shinya Kitaoka 120a6e
      while (is.openChild(tagName)) {
Shinya Kitaoka 120a6e
        if (tagName == "cell") {
Shinya Kitaoka 120a6e
          TPersist *p   = 0;
Shinya Kitaoka 120a6e
          int row       = 1;
Shinya Kitaoka 120a6e
          int fidNumber = 1;
Shinya Kitaoka 120a6e
          TFilePath path;
Shinya Kitaoka 120a6e
          is >> row >> fidNumber >> p;
Shinya Kitaoka 120a6e
          TXshLevel *xshLevel = dynamic_cast<txshlevel *="">(p);</txshlevel>
Shinya Kitaoka 120a6e
          TXshCell cell(xshLevel, TFrameId(fidNumber));
Shinya Kitaoka 120a6e
          setCell(row, cell);
Shinya Kitaoka 120a6e
        } else
Shinya Kitaoka 120a6e
          throw TException("TXshLevelColumn, unknown tag(2): " + tagName);
Shinya Kitaoka 120a6e
        is.closeChild();
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      throw TException("TXshLevelColumn, unknown tag: " + tagName);
Shinya Kitaoka 120a6e
    is.closeChild();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshSoundTextColumn::saveData(TOStream &os) {
Shinya Kitaoka 120a6e
  int r0, r1;
Shinya Kitaoka 120a6e
  if (getRange(r0, r1)) {
Shinya Kitaoka 120a6e
    os.openChild("cells");
Shinya Kitaoka 120a6e
    for (int r = r0; r <= r1; r++) {
Shinya Kitaoka 120a6e
      TXshCell cell = getCell(r);
Shinya Kitaoka 120a6e
      if (cell.isEmpty()) continue;
Shinya Kitaoka 120a6e
      TFrameId fid = cell.m_frameId;
Shinya Kitaoka 120a6e
      os.child("cell") << r << fid.getNumber() << cell.m_level.getPointer();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    os.closeChild();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TXshSoundTextColumn, "soundTextColumn")