Ejemplo n.º 1
0
StandardCategory::StandardCategory(const QSqlRecord &record) : Category(nullptr) {
  setId(record.value(CAT_DB_ID_INDEX).toInt());
  setCustomId(id());
  setTitle(record.value(CAT_DB_TITLE_INDEX).toString());
  setDescription(record.value(CAT_DB_DESCRIPTION_INDEX).toString());
  setCreationDate(TextFactory::parseDateTime(record.value(CAT_DB_DCREATED_INDEX).value<qint64>()).toLocalTime());
  setIcon(qApp->icons()->fromByteArray(record.value(CAT_DB_ICON_INDEX).toByteArray()));
}
Ejemplo n.º 2
0
StandardCategory::StandardCategory(const StandardCategory &other)
  : Category(nullptr) {
  setId(other.id());
  setCustomId(other.customId());
  setTitle(other.title());
  setDescription(other.description());
  setIcon(other.icon());
  setCreationDate(other.creationDate());
  setChildItems(other.childItems());
  setParent(other.parent());
}
Ejemplo n.º 3
0
bool StandardCategory::addItself(RootItem *parent) {
  // Now, add category to persistent storage.
  QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
  int new_id = DatabaseQueries::addCategory(database, parent->id(), parent->getParentServiceRoot()->accountId(),
                                            title(), description(), creationDate(), icon());

  if (new_id <= 0) {
    return false;
  }
  else {
    setId(new_id);
    setCustomId(new_id);
    return true;
  }
}
Ejemplo n.º 4
0
bool StandardFeed::addItself(RootItem* parent) {
  // Now, add feed to persistent storage.
  QSqlDatabase database = qApp->database()->connection(metaObject()->className());
  bool ok;
  int new_id = DatabaseQueries::addFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(),
                                        description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
                                        username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);

  if (!ok) {
    // Query failed.
    return false;
  }
  else {
    // New feed was added, fetch is primary id from the database.
    setId(new_id);
    setCustomId(QString::number(new_id));
    return true;
  }
}