当前位置: 首页>>代码示例>>C++>>正文


C++ RepoItem类代码示例

本文整理汇总了C++中RepoItem的典型用法代码示例。如果您正苦于以下问题:C++ RepoItem类的具体用法?C++ RepoItem怎么用?C++ RepoItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RepoItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: invisibleRootItem

void RepoTreeModel::checkGroupRepo(const ServerRepo& repo)
{
    QStandardItem *root = invisibleRootItem();
    RepoCategoryItem *group = NULL;

    int row, n = root->rowCount();

    // First find for create the group
    // Starts from row 2 because the first two rows are "My Libraries" and "Shared Libraries"
    for (row = 2; row < n; row ++) {
        RepoCategoryItem *item = (RepoCategoryItem *)(root->child(row));
        if (item->groupId() == repo.group_id) {
            group = item;
            break;
        }
    }
    if (!group) {
        group = new RepoCategoryItem(repo.group_name, repo.group_id);
        appendRow(group);
    }

    // Find the repo in this group
    n = group->rowCount();
    for (row = 0; row < n; row++) {
        RepoItem *item = (RepoItem *)(group->child(row));
        if (item->repo().id == repo.id) {
            updateRepoItem(item, repo);
            return;
        }
    }

    // Current repo not in this group yet
    RepoItem *item = new RepoItem(repo);
    group->appendRow(item);
}
开发者ID:Greyhatno,项目名称:seafile-client,代码行数:35,代码来源:repo-tree-model.cpp

示例2: forEachRepoItem

void RepoTreeModel::removeReposDeletedOnServer(const std::vector<ServerRepo>& repos)
{
    int i, n;
    DeleteRepoData data;
    n = repos.size();
    for (i = 0; i < n; i++) {
        const ServerRepo& repo = repos[i];
        data.map.insert(repo.id, &repo);
    }

    forEachRepoItem(&RepoTreeModel::collectDeletedRepos, (void *)&data);

    QListIterator<RepoItem*> iter(data.itemsToDelete);
    while(iter.hasNext()) {
        RepoItem *item = iter.next();

        const ServerRepo& repo = item->repo();

        qDebug("remove repo %s(%s) from \"%s\"\n",
               toCStr(repo.name), toCStr(repo.id),
               toCStr(((RepoCategoryItem*)item->parent())->name()));

        item->parent()->removeRow(item->row());
    }
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:25,代码来源:repo-tree-model.cpp

示例3: getRepoItem

void RepoTreeView::onItemDoubleClicked(const QModelIndex& index)
{
    QStandardItem *item = getRepoItem(index);
    if (!item) {
        return;
    }
    if (item->type() == REPO_ITEM_TYPE) {
        RepoItem *it = (RepoItem *)item;
        const LocalRepo& local_repo = it->localRepo();
        if (local_repo.isValid()) {
            // open local folder for downloaded repo
            QDesktopServices::openUrl(QUrl::fromLocalFile(local_repo.worktree));
        } else {
            // open seahub repo page for not downloaded repo
            // if (seafApplet->isPro()) {
            FileBrowserDialog* dialog = new FileBrowserDialog(it->repo(), this);
            const QRect screen = QApplication::desktop()->screenGeometry();
            dialog->setAttribute(Qt::WA_DeleteOnClose, true);
            dialog->show();
            dialog->move(screen.center() - dialog->rect().center());
            dialog->raise();
            // } else {
            //     const Account& account = seafApplet->accountManager()->accounts()[0];
            //     if (account.isValid()) {
            //         QUrl url = account.getAbsoluteUrl("repo/" + it->repo().id);
            //         QDesktopServices::openUrl(url);
            //     }
            // }
        }
    }
}
开发者ID:xudaiqing,项目名称:seafile-client,代码行数:31,代码来源:repo-tree-view.cpp

示例4: getParent

/** Populate the RepoModel with RepoItem entries that reproduce the hierarchical 
 *  organization of ScriptRepository entries. 
 * 
 * It will get the information from ScriptRepository from the listFiles, which means, 
 * that it will reconstruct the hierarchical organization of the files and folders
 * through the list of strings with the relative path of each entry. 
 * 
 * @param root: The RepoItem root 
 */
void RepoModel::setupModelData(RepoItem *root)
{

  QStringList lines;
  // check server for updates to repository
  repo_ptr->check4Update();
  // get the list of entries inside the scriptrepository
  std::vector<std::string> list = repo_ptr->listFiles();
  
  // auxiliary list of pointers to repoitem that are related to folders
  QList<RepoItem*> parents;
  // the first one will always be the root
  parents << root;

  
  QString last_directory = "";
  
  //FOREACH entry in LISTFILES
  for (unsigned int number = 0; number < list.size(); number++) {
    // folder or file inside the repository
    QString lineData = QString::fromStdString(list[number]);

    
    // Read the column data from the rest of the line.      
    QStringList pathStrings = lineData.split("/");
    // separate the folder and the current entry (folder or file)
    QString current_file = pathStrings.last(); 
    QString folder = ""; 
    pathStrings.removeLast(); 
    if (pathStrings.size() > 0)
      folder = pathStrings.join("/"); 
    
    // get parent for this entry
    RepoItem * parent = getParent(folder, parents);    
    // a new folder has started
    if (parent == root){
      // this test is just for the sake of performance, to reduce the numbers of parents
      parents.clear(); 
      parents << root;
    }
    
    // check if the current entry is a directory
    if (repo_ptr->info(lineData.toStdString()).directory){
      // directories will be appended to parents list
      RepoItem * aux = new RepoItem(current_file, lineData, parent); 
      parent->appendChild(aux); 
      parents << aux;                           
    }else{
      // files will just be created and appended to the parent
      parent->appendChild(new RepoItem(current_file, lineData, parent));
      
    }
    
  }
  
}
开发者ID:stothe2,项目名称:mantid,代码行数:65,代码来源:RepoModel.cpp

示例5: fileDescription

/** Return the description of the file for a defined entry
 **/
QString RepoModel::fileDescription(const QModelIndex & index) {
    RepoItem * item = static_cast<RepoItem*>(index.internalPointer());
    if (!item)
        return "";
    QString desc;
    try {
        desc = QString::fromStdString(repo_ptr->description(item->path().toStdString()));
    } catch(...) {
        // just ignore
    }
    return desc;
}
开发者ID:nimgould,项目名称:mantid,代码行数:14,代码来源:RepoModel.cpp

示例6: author

QString RepoModel::author(const QModelIndex & index) {
    RepoItem * item = static_cast<RepoItem*>(index.internalPointer());
    QString author = "Not defined";
    if (!item)
        return author;
    try {
        author = QString::fromStdString(repo_ptr->info(item->path().toStdString()).author);
    } catch(...) {
        // just ignore
    }
    return author;
}
开发者ID:nimgould,项目名称:mantid,代码行数:12,代码来源:RepoModel.cpp

示例7: filePath

/** Return the operative system file path if it exists.
    otherwise it returns an empty string
    @param index: to find the entry
    @return The operative system path or empty string
*/
QString RepoModel::filePath(const QModelIndex & index) {
    RepoItem * item = static_cast<RepoItem*>(index.internalPointer());
    //   qDebug() << "Get file path from : " <<  item->path()<< endl;
    Mantid::API::SCRIPTSTATUS state = repo_ptr->fileStatus(item->path().toStdString());

    if (state == Mantid::API::REMOTE_ONLY)
        return "";
    Mantid::API::ScriptInfo info = repo_ptr->fileInfo(item->path().toStdString());
    if (info.directory)
        return "";
    QString path = repo_path + "/" + item->path();
    return path;
}
开发者ID:nimgould,项目名称:mantid,代码行数:18,代码来源:RepoModel.cpp

示例8: rowCount

/** Count how many file/folders are direct children of the given folder,
 * through the abstraction of QModelIndex.
 *
 * @param parent: the index to the folder.
 * @return the number of children of the given folder.
 */
int RepoModel::rowCount(const QModelIndex &parent) const
{
    RepoItem *parentItem;

    if (parent.column() > 0)
        return 0; // there are rows defined only of the column 0

    if (!parent.isValid())
        parentItem = rootItem;
    else
        parentItem = static_cast<RepoItem*>(parent.internalPointer());
    // return the number of children
    return parentItem->childCount();
}
开发者ID:nimgould,项目名称:mantid,代码行数:20,代码来源:RepoModel.cpp

示例9: QModelIndex

/** Provide the parent of a given entry, through the QModelIndex abstraction.
 *
 * @param index: The QModelIndex that identifies one entry.
 * @return A QModelIndex that indentifies the parent of the given index.
 */
QModelIndex RepoModel::parent(const QModelIndex &index) const
{
    if (!index.isValid())
        return QModelIndex();
    // the child is the RepoItem pointed by the index.
    RepoItem *childItem = static_cast<RepoItem*>(index.internalPointer());
    // the parent is the parent of the RepoItem.
    RepoItem *parentItem = childItem->parent();
    // the root item does not have a parent
    if (parentItem == rootItem)
        return QModelIndex();
    // create the index and return
    return createIndex(parentItem->row(), 0, parentItem);
}
开发者ID:nimgould,项目名称:mantid,代码行数:19,代码来源:RepoModel.cpp

示例10: parent

/**Auxiliary method to help setupModelData to populate all the
   entries of RepoModel.

   For any entry of ScriptRepository should have a parent (by definition, all the entries
   are children of the root entry). Besides, given an entry, if the path contains a '/' this
   means that the entry is child of one folder. And all the folders are parents by definition.

   So, the idea of this getParent is that given a folder name, it must be related to a RepoItem
   that is a parent. If it does not exists, it should be created.

   @param folder: relative path inside the repository for the folder.
   @param parents Reference to the list of parents
   @return Pointer to the RepoItem related to the given folder.

**/
RepoModel::RepoItem * RepoModel::getParent(const QString & folder, QList<RepoItem*>&parents) {
    // in order to speed the algorithm, check if the
    // folder is the same of the last folder.
    if (parents.last()->path() == folder)
        return parents.last();

    // try to find this
    if (folder.isEmpty())
        return parents.first(); // the parents first will always contain the root

    // it will iterate through all the parents of the given folder, in order to
    // create any folder that has not been created.
    QStringList folder_parts = folder.split("/");
    QString aux_folder;
    RepoItem * father = parents.first();
    // there is no reason to try to find entry A/B/C if the entry A/B was not found
    bool try_to_find = true;

    for(int i = 0; i< folder_parts.size(); i++) {
        if (i ==0)
            aux_folder = folder_parts[i];
        else
            aux_folder += "/" + folder_parts[i];

        bool found = false;

        if (try_to_find) {
            // this means that the previous folders were found
            foreach(RepoItem* the_parent, parents) {
                if (the_parent->path() == aux_folder)
                {
                    found = true;
                    father = the_parent;
                    break;
                }
            }
        }
        // there is not RepoItem related to the current folder,
        // create it
        if (!found)
        {
            RepoItem * m = new RepoItem(folder_parts[i], aux_folder, father);
            father->appendChild(m);
            parents.append(m);
            father = m;
            try_to_find = false;
        }
    }
    return father;
}
开发者ID:nimgould,项目名称:mantid,代码行数:65,代码来源:RepoModel.cpp

示例11: getRepoItem

void RepoTreeView::onItemDoubleClicked(const QModelIndex& index)
{
    QStandardItem *item = getRepoItem(index);
    if (!item) {
        return;
    }
    if (item->type() == REPO_ITEM_TYPE) {
        RepoItem *it = (RepoItem *)item;
        const LocalRepo& local_repo = it->localRepo();
        if (local_repo.isValid()) {
            QDesktopServices::openUrl(QUrl::fromLocalFile(local_repo.worktree));
        }
    }
}
开发者ID:FeZoli,项目名称:seafile-client,代码行数:14,代码来源:repo-tree-view.cpp

示例12: updateRepoItem

void RepoTreeModel::checkSyncedRepo(const ServerRepo& repo)
{
    int row, n = synced_repos_category_->rowCount();
    for (row = 0; row < n; row++) {
        RepoItem *item = (RepoItem *)(synced_repos_category_->child(row));
        if (item->repo().id == repo.id) {
            updateRepoItem(item, repo);
            return;
        }
    }

    // The repo is new
    RepoItem *item = new RepoItem(repo);
    synced_repos_category_->appendRow(item);
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:15,代码来源:repo-tree-model.cpp

示例13: insertRow

void RepoTreeModel::checkVirtualRepo(const ServerRepo& repo)
{
    if (item(kIndexOfVirtualReposCategory) != virtual_repos_category_) {
        insertRow(kIndexOfVirtualReposCategory, virtual_repos_category_);
    }

    int row, n = virtual_repos_category_->rowCount();
    for (row = 0; row < n; row++) {
        RepoItem *item = (RepoItem *)(virtual_repos_category_->child(row));
        if (item->repo().id == repo.id) {
            updateRepoItem(item, repo);
            return;
        }
    }

    // The repo is new
    RepoItem *item = new RepoItem(repo);
    virtual_repos_category_->appendRow(item);
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:19,代码来源:repo-tree-model.cpp

示例14: invisibleRootItem

void RepoTreeModel::onFilterTextChanged(const QString& text)
{
    // Recalculate the matched repos count for each category
    QStandardItem *root = invisibleRootItem();
    int row, n;
    n = root->rowCount();
    QRegExp re = makeFilterRegExp(text);
    for (row = 0; row < n; row++) {
        RepoCategoryItem *category = (RepoCategoryItem *)root->child(row);
        int j, total, matched = 0;
        total = category->rowCount();
        for (j = 0; j < total; j++) {
            RepoItem *item = (RepoItem *)category->child(j);
            if (item->repo().name.contains(re)) {
                matched++;
            }
        }
        category->setMatchedReposCount(matched);
    }
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:20,代码来源:repo-tree-model.cpp

示例15: lessThan

bool RepoFilterProxyModel::lessThan(const QModelIndex &left,
                                    const QModelIndex &right) const
{
    RepoTreeModel *tree_model = (RepoTreeModel *)(sourceModel());
    QStandardItem *item_l = tree_model->itemFromIndex(left);
    QStandardItem *item_r = tree_model->itemFromIndex(right);

    /**
     * When we have filter: sort category by matched repos count
     * When we have no filter: sort category by category index order
     *
     */
    if (item_l->type() == REPO_CATEGORY_TYPE) {
        // repo categories
        RepoCategoryItem *cl = (RepoCategoryItem *)item_l;
        RepoCategoryItem *cr = (RepoCategoryItem *)item_r;
        if (has_filter_) {
            // printf ("%s matched: %d, %s matched: %d\n",
            //         cl->name().toUtf8().data(), cl->matchedReposCount(),
            //         cr->name().toUtf8().data(), cr->matchedReposCount());
            return cl->matchedReposCount() > cr->matchedReposCount();
        } else {
            int cat_l = cl->categoryIndex();
            int cat_r = cr->categoryIndex();
            if (cat_l == cat_r) {
                return cl->name() < cr->name();
            } else {
                return cat_l < cat_r;
            }
        }
    } else {
        // repos
        RepoItem *cl = (RepoItem *)item_l;
        RepoItem *cr = (RepoItem *)item_r;
        return cl->repo().mtime > cr->repo().mtime;
    }

    return false;
}
开发者ID:DevCybran,项目名称:seafile-client,代码行数:39,代码来源:repo-tree-model.cpp


注:本文中的RepoItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。