From: Eric Bollengier Date: Tue, 4 Aug 2009 10:27:43 +0000 (+0200) Subject: bat fill mediainfo fields X-Git-Tag: Release-5.0.0~338^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2ceaf7e77964d9ae83751b866679715b390aaf7c;p=bacula%2Fbacula bat fill mediainfo fields --- diff --git a/bacula/src/qt-console/job/job.cpp b/bacula/src/qt-console/job/job.cpp index f95ae5b613..d9ef451ead 100644 --- a/bacula/src/qt-console/job/job.cpp +++ b/bacula/src/qt-console/job/job.cpp @@ -198,7 +198,7 @@ void Job::populateText() } // Need to use the fmtwidgetitem helper instead -QString convertBytesSI(qint64 qfld) +static QString convertBytesSI(qint64 qfld) { static const qint64 KB = Q_INT64_C(1000); static const qint64 MB = (KB * KB); diff --git a/bacula/src/qt-console/mediainfo/mediainfo.cpp b/bacula/src/qt-console/mediainfo/mediainfo.cpp index be37689fe8..ce2be03a15 100644 --- a/bacula/src/qt-console/mediainfo/mediainfo.cpp +++ b/bacula/src/qt-console/mediainfo/mediainfo.cpp @@ -35,13 +35,120 @@ /* * 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; +// + } + } } diff --git a/bacula/src/qt-console/mediainfo/mediainfo.h b/bacula/src/qt-console/mediainfo/mediainfo.h index 6311e86970..fc9ed754c0 100644 --- a/bacula/src/qt-console/mediainfo/mediainfo.h +++ b/bacula/src/qt-console/mediainfo/mediainfo.h @@ -47,6 +47,7 @@ public: private slots: private: + void populateForm(); QString m_mediaName; }; diff --git a/bacula/src/qt-console/mediainfo/mediainfo.ui b/bacula/src/qt-console/mediainfo/mediainfo.ui index 257533e204..2a04b68d94 100644 --- a/bacula/src/qt-console/mediainfo/mediainfo.ui +++ b/bacula/src/qt-console/mediainfo/mediainfo.ui @@ -143,31 +143,41 @@ Information - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - QFormLayout::AllNonFixedFieldsGrow - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + Pool: - + + + + Default + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + Online: - - + + @@ -176,73 +186,68 @@ - + Enabled: - - + + yes - + Location: - - + + Vault + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + - + Status: - - + + Append + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + - + Media Type: - - + + File - - - - - - Expire: - - - - - - - 2010-08-03 23:10:03 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -254,36 +259,33 @@ - + Scratch + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Name: + - + - Default + Vol0001 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - label - label_2 - label_3 - label_4 - label_5 - label_7 - label_17 - label_18 - label_19 - label_20 - label_22 - label_33 - label_34 - label_35 - label_36 - label_16 @@ -310,15 +312,15 @@ Statistics - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - QFormLayout::AllNonFixedFieldsGrow + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + @@ -326,6 +328,16 @@ + + + + 19.8 MB + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + @@ -334,10 +346,13 @@ - + 10 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -348,10 +363,13 @@ - + 5 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -362,10 +380,13 @@ - + 10 mins + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -376,10 +397,13 @@ - + 20 mins + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -390,10 +414,13 @@ - + 0 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -404,34 +431,33 @@ - + 2009-07-05 12:23:00 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + - - + + - 19.8 MB + First Writtern: + + + + + + + 2009-06-05 10:00:00 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - label_14 - label_15 - label_11 - label_12 - label_13 - label_26 - label_27 - label_28 - label_29 - label_30 - label_6 - label_31 - label_32 - label_21 @@ -458,24 +484,27 @@ Limits - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + - Max use duration: + Use duration: - + 0 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -486,10 +515,13 @@ - + 0 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -500,10 +532,13 @@ - + 0 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -514,10 +549,13 @@ - + 0 + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + @@ -528,7 +566,10 @@ - + + + false + @@ -542,10 +583,30 @@ - + 365 days + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Expire: + + + + + + + 2010-08-03 23:10:03 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse +