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


C++ QDirModel::fileInfo方法代码示例

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


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

示例1: on_pushButtonDelete_clicked

void Widget::on_pushButtonDelete_clicked()
{

    ui->treeView->setSelectionMode(QTreeView::ExtendedSelection);
    ui->treeView->setSelectionBehavior(QTreeView::SelectRows);
    QModelIndexList list = ui->treeView->selectionModel()->selectedIndexes();
    QDirModel* model = (QDirModel*)ui->treeView->model();
    QModelIndex index = list[0];
    QFileInfo fileInfo = model->fileInfo(index);
    QString selectedfilepath = fileInfo.absoluteFilePath();
    qDebug() << selectedfilepath << '\n';

    QSqlQuery query;
    //query.exec("INSERT INTO test VALUES('','sss','sss')");
    //query.exec("SELECT * FROM test");
    QString selectedfromdb = "SELECT absdirectory FROM test WHERE symlinkdirectory = '" + selectedfilepath + "'";
    query.exec(selectedfromdb);
    query.next();
    QString selectedasbd = query.value(0).toString();
    qDebug() << selectedasbd << "\n";

    QByteArray ba1 = selectedasbd.toAscii();//将所得文件名转换为字符//yfx0527
    const char *dirnow1 = ba1.data();
    remove(dirnow1);
    QByteArray ba2 = selectedfilepath.toAscii();//将所得文件名转换为字符//yfx0527
    const char *dirnow2 = ba2.data();
    remove(dirnow2);
}
开发者ID:234205367,项目名称:A-HIT-filesystem-on-Linux,代码行数:28,代码来源:widget.cpp

示例2: activateItem

void ItemLibraryTreeView::activateItem( const QModelIndex & /*index*/)
{
    QMimeData *mimeData = model()->mimeData(selectedIndexes());
    if (!mimeData)
        return;

    QString name;
    QDirModel *dirModel = qobject_cast<QDirModel*>(model());
    Q_ASSERT(dirModel);
    QFileInfo fileInfo = dirModel->fileInfo(selectedIndexes().front());
    QPixmap pixmap(fileInfo.absoluteFilePath());
    if (!pixmap.isNull()) {
        name = "image^" + fileInfo.absoluteFilePath();
        emit itemActivated(name);
    }
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:16,代码来源:itemlibrarywidgets.cpp

示例3: qDebug

void Widget::on_pushButtonGetIDV3_clicked()
{
    ui->treeView->setSelectionMode(QTreeView::ExtendedSelection);
    ui->treeView->setSelectionBehavior(QTreeView::SelectRows);
    QModelIndexList list = ui->treeView->selectionModel()->selectedIndexes();
    QDirModel* model = (QDirModel*)ui->treeView->model();
    QModelIndex index = list[0];
    QFileInfo fileInfo = model->fileInfo(index);
    QString selectedfilepath = fileInfo.absoluteFilePath();
    qDebug() << selectedfilepath << '\n';

    QSqlQuery query;
    //query.exec("INSERT INTO test VALUES('','sss','sss')");
    //query.exec("SELECT * FROM test");
    QString selectedfromdb = "SELECT absdirectory FROM test WHERE symlinkdirectory = '" + selectedfilepath + "'";
    query.exec(selectedfromdb);
    query.next();
    QString selectedasbd = query.value(0).toString();
    qDebug() << selectedasbd << "\n";

    FILE *pFile; //文件指针
    Mp3Info song;
    QByteArray ba = selectedasbd.toAscii();//将所得文件名转换为字符//yfx0527
    const char *dirnow = ba.data();
    //printf("%s\n",dirnow);
    pFile = fopen(dirnow, "r");
    fseek(pFile, -128, SEEK_END);
    fread(&song, 1, sizeof (Mp3Info), pFile); //读取MP3文件ID3V标签
    //printf("%s\n",song.album);
    QString title = QString::fromLocal8Bit(song.title,30);
    QString artist = QString::fromLocal8Bit(song.artist,30);
    QString album = QString::fromLocal8Bit(song.album,30);
    QString year = QString::fromLocal8Bit(song.year,4);
    QString comment = QString::fromLocal8Bit(song.comment,28);
    ui->lineEditTitle->setText(title);
    ui->lineEditArtist->setText(artist);
    ui->lineEditAlbum->setText(album);
    ui->lineEditYear->setText(year);
    ui->lineEditComment->setText(comment);
    fclose(pFile);
}
开发者ID:234205367,项目名称:A-HIT-filesystem-on-Linux,代码行数:41,代码来源:widget.cpp

示例4: contextMenuEvent

/**
 * Przechwytuje zdarzenie wywołania menu kontekstowego.
 *
 * Wyświetla menu kontekstowe z akcjami widoku. Jeśli bieżący element jest
 * katalogiem, pierwsza z akcji menu służy do zwinięcia/rozwinięcia gałęzi
 * drzewa. Jeśli bieżący element jest plikiem, pierwsza akcja wczytuje
 * plik z przestrzeni roboczej.
 *
 * @param event obiekt informacji o zdarzeniu
 */
void WorkspaceTreeView::contextMenuEvent(QContextMenuEvent* event)
{
    QMenu menu(this);

    QDirModel* dirModel = static_cast<QDirModel*>(model());
    if (dirModel->fileInfo(currentIndex()).isDir())
    {
        bool exp = isExpanded(currentIndex());
        actionExpandOrCollapse->setText(exp ? tr("Collapse") : tr("Expand"));
        menu.addAction(actionExpandOrCollapse);
    }
    else
    {
        menu.addAction(actionLoad);
    }

    menu.addAction(actionRemove);
    menu.addSeparator();
    menu.addAction(actionRefresh);
    menu.exec(event->globalPos());
}
开发者ID:akhmadzaki,项目名称:SimpleBird,代码行数:31,代码来源:WorkspaceTreeView.cpp


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