/*
* A constructor
*/
-MediaInfo::MediaInfo(QTreeWidgetItem *parentWidget, QString &mediaId)
+MediaInfo::MediaInfo(QTreeWidgetItem *parentWidget, QString &mediaName)
{
setupUi(this);
pgInitialize(tr("Media Info"), parentWidget);
QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.png")));
+ m_mediaName = mediaName;
m_closeable = true;
dockPage();
setCurrent();
+ populateForm();
+}
+
+// Need to use the fmtwidgetitem helper instead
+static QString convertBytesSI(qint64 qfld)
+{
+ static const qint64 KB = Q_INT64_C(1000);
+ static const qint64 MB = (KB * KB);
+ static const qint64 GB = (MB * KB);
+ static const qint64 TB = (GB * KB);
+ static const qint64 PB = (TB * KB);
+ static const qint64 EB = (PB * KB);
+
+ /* note: division is integer, so to have some decimals we divide for a
+ smaller unit (e.g. GB for a TB number and so on) */
+ char suffix;
+ if (qfld >= EB) {
+ qfld /= PB;
+ suffix = 'E';
+ }
+ else if (qfld >= PB) {
+ qfld /= TB;
+ suffix = 'P';
+ }
+ else if (qfld >= TB) {
+ qfld /= GB;
+ suffix = 'T';
+ }
+ else if (qfld >= GB) {
+ qfld /= MB;
+ suffix = 'G';
+ }
+ else if (qfld >= MB) {
+ qfld /= KB;
+ suffix = 'M';
+ }
+ else if (qfld >= KB) {
+ suffix = 'k'; /* SI uses lowercase k */
+ }
+ else {
+ /* plain bytes, no need to reformat */
+ return QString("%1 B").arg(qfld);
+ }
+
+ /* having divided for a smaller unit, now we can safely convert to double and
+ use the extra room for decimals */
+ return QString("%1 %2B").arg(qfld / 1000.0, 0, 'f', 2).arg(suffix);
+}
+
+/*
+ * Populate the text in the window
+ */
+void MediaInfo::populateForm()
+{
+ QString stat;
+ char buf[256];
+ QString query =
+ "SELECT VolumeName, Pool.Name, MediaType, FirstWritten,"
+ "LastWritten, VolMounts, VolBytes, Media.Enabled,"
+ "Location.Location, VolStatus, RecyclePool.Name, Media.Recycle, "
+ "VolReadTime, VolWriteTime, Media.VolUseDuration, Media.MaxVolJobs, "
+ "Media.MaxVolFiles, Media.MaxVolBytes, Media.VolRetention,Slot,InChanger "
+ "FROM Media JOIN Pool USING (PoolId) LEFT JOIN Pool AS RecyclePool "
+ "ON (Media.RecyclePoolId = RecyclePool.PoolId) "
+ "LEFT JOIN Location USING (LocationId) "
+ "WHERE Media.VolumeName = '" + m_mediaName + "'";
+
+ QStringList results;
+ if (m_console->sql_cmd(query, results)) {
+ QString resultline;
+ QStringList fieldlist;
+
+ foreach (resultline, results) { // should have only one result
+ fieldlist = resultline.split("\t");
+ QStringListIterator fld(fieldlist);
+ label_VolumeName->setText(fld.next());
+ label_Pool->setText(fld.next());
+ label_MediaType->setText(fld.next());
+ label_FirstWritten->setText(fld.next());
+ label_LastWritten->setText(fld.next());
+// label_VolFiles->setText(fld.next());
+ label_VolMounts->setText(fld.next());
+ label_VolBytes->setText(convertBytesSI(fld.next().toULongLong()));
+ label_Enabled->setPixmap(QPixmap(":/images/inflag" + fld.next() + ".png"));
+ label_Location->setText(fld.next());
+ label_VolStatus->setText(fld.next());
+ label_RecyclePool->setText(fld.next());
+ chkbox_Recycle->setCheckState(fld.next().toInt()?Qt::Checked:Qt::Unchecked);
+ label_VolReadTime->setText(fld.next());
+ label_VolWriteTime->setText(fld.next());
+ label_VolUseDuration->setText(fld.next());
+ label_MaxVolJobs->setText(fld.next());
+ label_MaxVolFiles->setText(fld.next());
+ label_MaxVolBytes->setText(fld.next());
+ label_VolRetention->setText(fld.next());
+
+// label_VolFiles->setText(fld.next());
+// label_VolErrors->setText(fld.next());
+
+// stat=fld.next();
+// label_Online->setPixmap(QPixmap(":/images/inflag" + stat + ".png"));
+// jobstatus_to_ascii_gui(stat[0].toAscii(), buf, sizeof(buf));
+// stat = buf;
+//
+ }
+ }
}
<string>Information</string>
</property>
<layout class="QFormLayout" name="formLayout_3" >
- <property name="labelAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="formAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
- <item row="0" column="0" >
+ <property name="labelAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="formAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Pool:</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
+ <item row="1" column="1" >
+ <widget class="QLabel" name="label_Pool" >
+ <property name="text" >
+ <string>Default</string>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Online:</string>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="QLabel" name="label_17" >
+ <item row="2" column="1" >
+ <widget class="QLabel" name="label_Online" >
<property name="text" >
<string/>
</property>
</property>
</widget>
</item>
- <item row="2" column="0" >
+ <item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Enabled:</string>
</property>
</widget>
</item>
- <item row="2" column="1" >
- <widget class="QLabel" name="label_18" >
+ <item row="3" column="1" >
+ <widget class="QLabel" name="label_Enabled" >
<property name="text" >
<string>yes</string>
</property>
</widget>
</item>
- <item row="3" column="0" >
+ <item row="4" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Location:</string>
</property>
</widget>
</item>
- <item row="3" column="1" >
- <widget class="QLabel" name="label_19" >
+ <item row="4" column="1" >
+ <widget class="QLabel" name="label_Location" >
<property name="text" >
<string>Vault</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item row="4" column="0" >
+ <item row="5" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Status:</string>
</property>
</widget>
</item>
- <item row="4" column="1" >
- <widget class="QLabel" name="label_20" >
+ <item row="5" column="1" >
+ <widget class="QLabel" name="label_VolStatus" >
<property name="text" >
<string>Append</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item row="5" column="0" >
+ <item row="6" column="0" >
<widget class="QLabel" name="label_33" >
<property name="text" >
<string>Media Type:</string>
</property>
</widget>
</item>
- <item row="5" column="1" >
- <widget class="QLabel" name="label_34" >
+ <item row="6" column="1" >
+ <widget class="QLabel" name="label_MediaType" >
<property name="text" >
<string>File</string>
</property>
- </widget>
- </item>
- <item row="6" column="0" >
- <widget class="QLabel" name="label_7" >
- <property name="text" >
- <string>Expire:</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1" >
- <widget class="QLabel" name="label_22" >
- <property name="text" >
- <string>2010-08-03 23:10:03</string>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</widget>
</item>
<item row="7" column="1" >
- <widget class="QLabel" name="label_36" >
+ <widget class="QLabel" name="label_RecyclePool" >
<property name="text" >
<string>Scratch</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_17" >
+ <property name="text" >
+ <string>Name:</string>
+ </property>
</widget>
</item>
<item row="0" column="1" >
- <widget class="QLabel" name="label_16" >
+ <widget class="QLabel" name="label_VolumeName" >
<property name="text" >
- <string>Default</string>
+ <string>Vol0001</string>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
- <zorder>label</zorder>
- <zorder>label_2</zorder>
- <zorder>label_3</zorder>
- <zorder>label_4</zorder>
- <zorder>label_5</zorder>
- <zorder>label_7</zorder>
- <zorder>label_17</zorder>
- <zorder>label_18</zorder>
- <zorder>label_19</zorder>
- <zorder>label_20</zorder>
- <zorder>label_22</zorder>
- <zorder>label_33</zorder>
- <zorder>label_34</zorder>
- <zorder>label_35</zorder>
- <zorder>label_36</zorder>
- <zorder>label_16</zorder>
</widget>
</item>
<item>
<string>Statistics</string>
</property>
<layout class="QFormLayout" name="formLayout_2" >
- <property name="labelAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="formAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
+ <property name="labelAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="formAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
<item row="0" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
</property>
</widget>
</item>
+ <item row="0" column="1" >
+ <widget class="QLabel" name="label_VolBytes" >
+ <property name="text" >
+ <string>19.8 MB</string>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0" >
<widget class="QLabel" name="label_11" >
<property name="text" >
</widget>
</item>
<item row="1" column="1" >
- <widget class="QLabel" name="label_26" >
+ <widget class="QLabel" name="label_VolMounts" >
<property name="text" >
<string>10</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="2" column="0" >
</widget>
</item>
<item row="2" column="1" >
- <widget class="QLabel" name="label_27" >
+ <widget class="QLabel" name="label_RecycleCount" >
<property name="text" >
<string>5</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="3" column="0" >
</widget>
</item>
<item row="3" column="1" >
- <widget class="QLabel" name="label_28" >
+ <widget class="QLabel" name="label_VolReadTime" >
<property name="text" >
<string>10 mins</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="4" column="0" >
</widget>
</item>
<item row="4" column="1" >
- <widget class="QLabel" name="label_29" >
+ <widget class="QLabel" name="label_VolWriteTime" >
<property name="text" >
<string>20 mins</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="5" column="0" >
</widget>
</item>
<item row="5" column="1" >
- <widget class="QLabel" name="label_30" >
+ <widget class="QLabel" name="label_VolErrors" >
<property name="text" >
<string>0</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="6" column="0" >
</widget>
</item>
<item row="6" column="1" >
- <widget class="QLabel" name="label_32" >
+ <widget class="QLabel" name="label_LastWritten" >
<property name="text" >
<string>2009-07-05 12:23:00</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
- <item row="0" column="1" >
- <widget class="QLabel" name="label_21" >
+ <item row="7" column="0" >
+ <widget class="QLabel" name="label_16" >
<property name="text" >
- <string>19.8 MB</string>
+ <string>First Writtern:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1" >
+ <widget class="QLabel" name="label_FirstWritten" >
+ <property name="text" >
+ <string>2009-06-05 10:00:00</string>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
- <zorder>label_14</zorder>
- <zorder>label_15</zorder>
- <zorder>label_11</zorder>
- <zorder>label_12</zorder>
- <zorder>label_13</zorder>
- <zorder>label_26</zorder>
- <zorder>label_27</zorder>
- <zorder>label_28</zorder>
- <zorder>label_29</zorder>
- <zorder>label_30</zorder>
- <zorder>label_6</zorder>
- <zorder>label_31</zorder>
- <zorder>label_32</zorder>
- <zorder>label_21</zorder>
</widget>
</item>
<item>
<string>Limits</string>
</property>
<layout class="QFormLayout" name="formLayout" >
- <property name="labelAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="formAlignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
+ <property name="labelAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="formAlignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
<item row="0" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
- <string>Max use duration:</string>
+ <string>Use duration:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
- <widget class="QLabel" name="label_25" >
+ <widget class="QLabel" name="label_VolUseDuration" >
<property name="text" >
<string>0</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="1" column="0" >
</widget>
</item>
<item row="1" column="1" >
- <widget class="QLabel" name="label_24" >
+ <widget class="QLabel" name="label_MaxVolJobs" >
<property name="text" >
<string>0</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="2" column="0" >
</widget>
</item>
<item row="2" column="1" >
- <widget class="QLabel" name="label_39" >
+ <widget class="QLabel" name="label_MaxVolFiles" >
<property name="text" >
<string>0</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="3" column="0" >
</widget>
</item>
<item row="3" column="1" >
- <widget class="QLabel" name="label_40" >
+ <widget class="QLabel" name="label_MaxVolBytes" >
<property name="text" >
<string>0</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
<item row="4" column="0" >
</widget>
</item>
<item row="4" column="1" >
- <widget class="QCheckBox" name="checkBox" >
+ <widget class="QCheckBox" name="chkbox_Recycle" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="5" column="1" >
- <widget class="QLabel" name="label_23" >
+ <widget class="QLabel" name="label_VolRetention" >
<property name="text" >
<string>365 days</string>
</property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" >
+ <widget class="QLabel" name="label_7" >
+ <property name="text" >
+ <string>Expire:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" >
+ <widget class="QLabel" name="label_Expire" >
+ <property name="text" >
+ <string>2010-08-03 23:10:03</string>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+ </property>
</widget>
</item>
</layout>