#ifndef BlkDevInfo_h
#define BlkDevInfo_h

#include <QString>
#include <QStringList>
#include <vector>
#include <libudev.h>

class QTableWidget;

// Class that knows how to dig up information on block devices to use to
// populate the table widgets in the GUI.
//
// Consults the udev subsystem (via libudev).
//
// Individual instances of this class represent a single block device
// and/or partition.
//
// Static functions in this class build the entire list of interesting
// devices.
//
class BlkDevInfo {
public:

   BlkDevInfo(QString init_devname);

   ~BlkDevInfo();

   QString devname;
   QString devtype;
   QString devlabel;
   QString devmodel;
   QString devuuid;
   QString devsize;
   QString devmountpoint;
   QString devmountroot;
   QString pvendor;
   QString pmodel;

   unsigned long long size;
   BlkDevInfo * parent;
   bool    ejectable;
   bool    invisible;

   QString
   PVendor();

   QString
   PModel();

   QString
   Description();

      // Call ReadMountInfo() to refresh the "allblkdev" array with the
      // list of all interesting devices.
      //
   static void
   ReadMountInfo();

      // Call PopulateUnmounted() to fill in the rows of the table widget
      // holding information about currently unmounted devices.
      //
   static void
   PopulateUnmounted(QTableWidget * qtw);

      // Call PopulateMounted() to fill in the table widget holding
      // one row for each currently mounted device.
      //
   static void
   PopulateMounted(QTableWidget * qtw);

   static QStringList &
   GetEjectableDevices();

   static QString
   GetDeviceDescription(QString devname);

   static BlkDevInfo *
   FindBlkDevInfo(QString devname);

   static BlkDevInfo *
   SoftFindBlkDevInfo(QString devname);

   static QString
   FormatSize(unsigned long long size_data);

   static void
   FindDiskDevices(QStringList & dlist);

   static bool
   BlkDevGreater(const BlkDevInfo * a, const BlkDevInfo * b);

   static std::vector<BlkDevInfo*> allblkdev;

   static QStringList allejectable;
};

#endif // BlkDevInfo_h
