// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void BookmarksItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
  BookmarksModel* bModel = qobject_cast<BookmarksModel*>(model);

  QLineEdit* line = static_cast<QLineEdit*>(editor);
  QString value = line->text();

  if (value.isEmpty() == false)
  {
    QModelIndex bIndex = bModel->index(index.row(), BookmarksItem::Name, index.parent());
    bModel->setData(bIndex, value, Qt::DisplayRole);
  }
}
예제 #2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void SIMPLView_UI::checkFirstRun()
{
  // Launch v6.0 dialog box if this is the first run of v6.0
  SIMPLViewSettings prefs;
  bool firstRun = prefs.value("First Run", true).toBool();
  if (firstRun == true)
  {
    // This is the first run of SIMPLView v6.0, so we need to show the v6.0 wizard
    SIMPLViewv6Wizard* wizard = new SIMPLViewv6Wizard(this, Qt::WindowTitleHint);
    wizard->exec();

    bool value = wizard->isBookmarkBtnChecked();
    if (value == true)
    {
      BookmarksModel* model = BookmarksModel::Instance();

      model->insertRow(0, QModelIndex());
      QModelIndex nameIndex = model->index(0, BookmarksItem::Name, QModelIndex());
      model->setData(nameIndex, "SIMPLView v4 Favorites", Qt::DisplayRole);
      model->setData(nameIndex, QIcon(":/folder_blue.png"), Qt::DecorationRole);

      QDir favoritesDir = getBookmarksToolboxWidget()->findV4FavoritesDirectory();
      QString favoritesPath = favoritesDir.path();
      QFileInfo fi(favoritesPath);

      if (fi.exists() && favoritesPath.isEmpty() == false)
      {
        QDirIterator iter(favoritesPath, QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
        while (iter.hasNext())
        {
          QString path = iter.next();
          model->addFileToTree(path, nameIndex);
        }
      }
    }
  }
}