示例#1
0
QStringList Misc::get_ROdevicesInfo()
{

    QStringList deviceInfo;
    QDir dirs;

    foreach (const QFileInfo drivesList, dirs.drives()){
        qDebug() << drivesList.absolutePath();
    }



    foreach (const QStorageInfo &deviceList, QStorageInfo::mountedVolumes()){
           if (deviceList.isValid() /*&& deviceList.isReady()*/) {
               if (deviceList.isReadOnly()) {
               QString item, itemDisplayNameFix;
               item.append("Device: " + deviceList.device() + "\n");
               deviceName << deviceList.device();
               itemDisplayNameFix = deviceList.displayName();
               itemDisplayNameFix.replace("\\x20", " ");
               item.append("Label: " + itemDisplayNameFix + "\n");
               item.append("Size: " + QString::number(deviceList.bytesTotal()/1024/1024) + " MB" + "\n"); // Convert to MB
               item.append("State: Ready\n");
                deviceInfo << item;
              }
          }
     }

     return deviceInfo;
}
示例#2
0
/*
 * Method to detect whether the device has mass memory available
 * Returns the drive and base folder to be used in file name generation
 * In practive it is either of the following:
 *   * c:\Data
 *   * e:\
 */
QString S60FileNameGenerator::detectDestinationDrive(const QDir currentDirectory)
{
    QFileInfoList driveList = currentDirectory.drives();
    bool isMassMemoryAvailable = false;
    foreach (QFileInfo info, driveList) {
        if (info.path() == QLatin1String("E:/") && info.isWritable())
            isMassMemoryAvailable = true;
    }

    if (isMassMemoryAvailable) {
        return QLatin1String("e:/");
    } else {
        return QLatin1String("c:/Data/");
    }
}
示例#3
0
hardDisk *Misc::get_HardDrivesInfo()
{

    QStringList deviceInfo;
    QDir dirs;
    QString item;

    foreach (const QFileInfo drivesList, dirs.drives()){
        qDebug() << "Drive List: " << drivesList.absolutePath();
    }

    int i=0;

    foreach (const QStorageInfo &deviceList, QStorageInfo::mountedVolumes()){
           if (deviceList.isValid() && deviceList.isReady()) {
               if (!deviceList.isReadOnly()) {
                   i++;
               }
           }
    }
     hddListCounter = i;
     hardDisk* hardDiskStruc = new hardDisk[i];

    i=0;
    foreach (const QStorageInfo &deviceList, QStorageInfo::mountedVolumes()){
           if (deviceList.isValid() && deviceList.isReady()) {
               if (!deviceList.isReadOnly()) {

                   QString itemDisplayNameFix;
                   // deviceName << deviceList.device();
                   itemDisplayNameFix = deviceList.displayName();
                   itemDisplayNameFix.replace("\\x20", " ");
                   item.append("Label: " + itemDisplayNameFix + "\n");
                   item.append("Device: " + deviceList.device() + "\n");

                   qint64 total_diskSize = deviceList.bytesTotal();
                   qint64 total_diskSize_temp = 0;

                   while (total_diskSize >= 1024) {
                       total_diskSize_temp = total_diskSize/1024;
                       total_diskSize = total_diskSize_temp;
                   }

                   item.append("Total: " + QString::number(total_diskSize) + " Gb" + "\n"); // Convert to Gb

                   qint64 free_diskSize = deviceList.bytesFree();
                   qint64 free_diskSize_temp = 0;

                   while (free_diskSize >= 1024) {
                       free_diskSize_temp = free_diskSize/1024;
                       free_diskSize = free_diskSize_temp;
                   }

                   item.append("Free: " + QString::number(free_diskSize) + " Gb" + "\n"); // Convert to Gb
                   item.append("State: Ready\n\n");
                   deviceInfo << item;

                   hardDiskStruc[i].label = itemDisplayNameFix;
                   hardDiskStruc[i].device = deviceList.device();
                   hardDiskStruc[i].totalBytes = QString::number(total_diskSize);
                   hardDiskStruc[i].freeBytes = QString::number(free_diskSize);
                   hardDiskStruc[i].state = "Ready";
                   ++i;
             }
          }
     }

    for (int var = 0; var < i; var++) {
        qDebug() << "Label -" << hardDiskStruc[var].label;
        qDebug() << "Device -" << hardDiskStruc[var].device;
        qDebug() << "Total -" << hardDiskStruc[var].totalBytes << "Gb";
        qDebug() << "Free -" << hardDiskStruc[var].freeBytes << "Gb";
        qDebug() << "State -" << hardDiskStruc[var].state;
        qDebug() << "------ empty line ------";

    }

    return hardDiskStruc;
}