From 73cd3efc212a44e4b398abb75bc29b096021841d Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Tue, 29 May 2007 15:34:57 +0000 Subject: [PATCH] Add icon to label class in page selector. Turn media edit into a inheritor of the page class to put it on the stack. Added status tips for buttons in main.ui via designer Added truly fancy method of editing retention and use duration in media edit. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4930 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/COMMANDS | 22 +- bacula/src/qt-console/PAGES | 2 +- bacula/src/qt-console/label/label.cpp | 2 + bacula/src/qt-console/main.ui | 40 +- bacula/src/qt-console/mediaedit/mediaedit.cpp | 214 +++++++- bacula/src/qt-console/mediaedit/mediaedit.h | 22 +- bacula/src/qt-console/mediaedit/mediaedit.ui | 488 ++++++++++++------ bacula/src/qt-console/medialist/medialist.cpp | 2 +- 8 files changed, 577 insertions(+), 215 deletions(-) diff --git a/bacula/src/qt-console/COMMANDS b/bacula/src/qt-console/COMMANDS index f70f2e1408..43b86bb33a 100644 --- a/bacula/src/qt-console/COMMANDS +++ b/bacula/src/qt-console/COMMANDS @@ -18,23 +18,12 @@ list list nextvol job= list nextvol job= days=nnn -prune files|jobs|volume client= volume= -could add as a dialog box from both client and medialist - release storage= Would need to explain what this does in bat with a dialog -run -done - setdebug I'd say we could choose not to implement this in bat -status -done, want to implement graphically - -unmount storage= [ drive=\lt{}num\gt{} ] -done unmount [ jobid= | job= ] Mmmmm @@ -115,12 +104,19 @@ help label Done by kern before I started +prune files|jobs|volume client= volume= +could add as a dialog box from both client and medialist + purge files jobid=|job=|client= purge volume|volume= (of all jobs) purge jobs client= (of all jobs) relabel -done + +run reload -could be done in console or on director's page selector widget + +status + +unmount storage= [ drive=\lt{}num\gt{} ] diff --git a/bacula/src/qt-console/PAGES b/bacula/src/qt-console/PAGES index 68f3f8d994..ec01963782 100644 --- a/bacula/src/qt-console/PAGES +++ b/bacula/src/qt-console/PAGES @@ -38,7 +38,7 @@ setCurrent() for making the page and tree widget item of an object selected and in the front of the stack. Closing -Use the function closeDockPage() to close from within the class. Otherwise, if +Use the function closeStackPage() to close from within the class. Otherwise, if there are pointers which need to be deleted, use a destructor. The m_closeable page member will determine whether the option to close will appear in context menu of page selector. diff --git a/bacula/src/qt-console/label/label.cpp b/bacula/src/qt-console/label/label.cpp index 3f4384c7e7..19b7272dba 100644 --- a/bacula/src/qt-console/label/label.cpp +++ b/bacula/src/qt-console/label/label.cpp @@ -63,6 +63,8 @@ void labelPage::showPage(QString &defString) pgInitialize(); setupUi(this); m_console->notify(false); + QTreeWidgetItem* thisitem = mainWin->getFromHash(this); + thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/label.png"))); storageCombo->addItems(m_console->storage_list); int index = storageCombo->findText(defString, Qt::MatchExactly); diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index 098d74ac83..9feaab51b5 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -82,14 +82,6 @@ - - - &File - - - - - Settings @@ -104,6 +96,14 @@ + + + &File + + + + + @@ -456,13 +456,19 @@ :/images/status.png - StatusDir + Status Dir + + + Status Dir - status dir + Query status of director - Status of Director + Query status of director + + + true @@ -477,6 +483,9 @@ Undock Window + + Undock Current Window + @@ -485,6 +494,12 @@ ToggleDock + + Toggle Dock Status + + + Toggle Dock Status + @@ -507,6 +522,9 @@ Display any messages queued at the director + + false + diff --git a/bacula/src/qt-console/mediaedit/mediaedit.cpp b/bacula/src/qt-console/mediaedit/mediaedit.cpp index d846463f5a..e1afbed814 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.cpp +++ b/bacula/src/qt-console/mediaedit/mediaedit.cpp @@ -36,25 +36,39 @@ #include #include "bat.h" #include "mediaedit.h" +#include /* * A constructor */ -MediaEdit::MediaEdit(Console *console, QString &mediaId) +MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId) { - m_console = console; - m_console->notify(false); + setupUi(this); + m_name = "Media Edit"; + pgInitialize(parentWidget); + QTreeWidgetItem* thisitem = mainWin->getFromHash(this); + thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.svg"))); + m_closeable = true; + dockPage(); + setCurrent(); + + connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed())); + connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed())); + connectSpins(); + connect(retentionSpin, SIGNAL(valueChanged(int)), this, SLOT(retentionChanged())); + connect(useDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(useDurationChanged())); + connect(retentionRadio, SIGNAL(pressed()), this, SLOT(retentionRadioPressed())); + connect(useDurationRadio, SIGNAL(pressed()), this, SLOT(useDurationRadioPressed())); + m_pool = ""; m_status = ""; m_slot = 0; - setupUi(this); - if (!m_console->preventInUseConnect()) - return; + return; /* The media's pool */ - poolCombo->addItems(console->pool_list); + poolCombo->addItems(m_console->pool_list); /* The media's Status */ QStringList statusList = (QStringList() << "Full" << "Used" << "Append" << "Error" << "Purged" << "Recycled"); @@ -62,9 +76,11 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) /* Set up the query for the default values */ QStringList FieldList = (QStringList() - << "Media.VolumeName" << "Pool.Name" << "Media.VolStatus" << "Media.Slot" ); + << "Media.VolumeName" << "Pool.Name" << "Media.VolStatus" << "Media.Slot" + << "Media.VolRetention" << "Media.VolUseDuration"); QStringList AsList = (QStringList() - << "VolumeName" << "PoolName" << "Status" << "Slot" ); + << "VolumeName" << "PoolName" << "Status" << "Slot" + << "Retention" << "UseDuration"); int i = 0; QString query("SELECT "); foreach (QString field, FieldList) { @@ -94,6 +110,7 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) /* Iterate through fields in the record */ foreach (field, fieldlist) { field = field.trimmed(); /* strip leading & trailing spaces */ + bool ok; if (i == 0) { m_mediaName = field; volumeLabel->setText(QString("Volume : %1").arg(m_mediaName)); @@ -102,9 +119,14 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) } else if (i == 2) { m_status = field; } else if (i == 3) { - bool ok; m_slot = field.toInt(&ok, 10); if (!ok){ m_slot = 0; } + } else if (i == 4) { + m_retention = field.toLong(&ok, 10); + if (!ok){ m_retention = 0; } + } else if (i == 5) { + m_useDuration = field.toLong(&ok, 10); + if (!ok){ m_useDuration = 0; } } i++; } /* foreach field */ @@ -125,6 +147,8 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) statusCombo->setCurrentIndex(index); } slotSpin->setValue(m_slot); + retentionSpin->setValue(m_retention); + useDurationSpin->setValue(m_useDuration); this->show(); } else { @@ -132,14 +156,16 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) QMessageBox::Ok, QMessageBox::Ok); return; } - } /* - * Function to handle updating the record + * Function to handle updating the record then closing the page */ -void MediaEdit::accept() +void MediaEdit::okButtonPushed() { +//update volume=xxx slots MaxVolJobs=nnn MaxVolBytes=nnn Recycle=yes|no +// enabled=n recyclepool=zzz +// done pool=yyy volstatus=xxx slot=nnn VolUse=ddd VolRetention=ddd QString scmd; this->hide(); bool docmd = false; @@ -157,22 +183,162 @@ void MediaEdit::accept() scmd += " slot=" + QString().setNum(slotSpin->value()); docmd = true; } + if (m_retention != retentionSpin->value()) { + scmd += " VolRetention=" + QString().setNum(retentionSpin->value()); + docmd = true; + } + if (m_useDuration != useDurationSpin->value()) { + scmd += " VolUse=" + QString().setNum(useDurationSpin->value()); + docmd = true; + } if (docmd) { if (mainWin->m_commandDebug) { Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data()); } - m_console->write_dir(scmd.toUtf8().data()); - m_console->displayToPrompt(); - m_console->notify(true); - } - delete this; - mainWin->resetFocus(); + consoleCommand(scmd); + } + closeStackPage(); } -void MediaEdit::reject() +/* close if cancel */ +void MediaEdit::cancelButtonPushed() { - this->hide(); - m_console->notify(true); - delete this; - mainWin->resetFocus(); + closeStackPage(); +} + +/* + * Slot for user changed retention + */ +void MediaEdit::retentionChanged() +{ + retentionRadio->setChecked(true); + setSpins(retentionSpin->value()); +} + +/* + * Slot for user changed the use duration + */ +void MediaEdit::useDurationChanged() +{ + useDurationRadio->setChecked(true); + setSpins(useDurationSpin->value()); +} + +/* + * Set the 5 duration spins from a known duration value + */ +void MediaEdit::setSpins(int value) +{ + int years, days, hours, minutes, seconds, left; + + years = abs(value / 31536000); + left = value - years * 31536000; + days = abs(left / 86400); + left = left - days * 86400; + hours = abs(left / 3600); + left = left - hours * 3600; + minutes = abs(left / 60); + seconds = left - minutes * 60; + disconnectSpins(); + yearsSpin->setValue(years); + daysSpin->setValue(days); + hoursSpin->setValue(hours); + minutesSpin->setValue(minutes); + secondsSpin->setValue(seconds); + connectSpins(); +} + +/* + * This slot is called any time any one of the 5 duration spins a changed. + */ +void MediaEdit::durationChanged() +{ + disconnectSpins(); + if (secondsSpin->value() == -1) { + secondsSpin->setValue(59); + minutesSpin->setValue(minutesSpin->value()-1); + } + if (minutesSpin->value() == -1) { + minutesSpin->setValue(59); + hoursSpin->setValue(hoursSpin->value()-1); + } + if (hoursSpin->value() == -1) { + hoursSpin->setValue(23); + daysSpin->setValue(daysSpin->value()-1); + } + if (daysSpin->value() == -1) { + daysSpin->setValue(364); + yearsSpin->setValue(yearsSpin->value()-1); + } + if (yearsSpin->value() == -1) { + yearsSpin->setValue(0); + } + + if (secondsSpin->value() == 60) { + secondsSpin->setValue(0); + minutesSpin->setValue(minutesSpin->value()+1); + } + if (minutesSpin->value() == 60) { + minutesSpin->setValue(0); + hoursSpin->setValue(hoursSpin->value()+1); + } + if (hoursSpin->value() == 24) { + hoursSpin->setValue(0); + daysSpin->setValue(daysSpin->value()+1); + } + if (daysSpin->value() == 365) { + daysSpin->setValue(0); + yearsSpin->setValue(yearsSpin->value()+1); + } + connectSpins(); + if (retentionRadio->isChecked()) { + int retention; + retention = secondsSpin->value() + minutesSpin->value() * 60 + + hoursSpin->value() * 3600 + daysSpin->value() * 86400 + + yearsSpin->value() * 31536000; + disconnect(retentionSpin, SIGNAL(valueChanged(int)), this, SLOT(retentionChanged())); + retentionSpin->setValue(retention); + connect(retentionSpin, SIGNAL(valueChanged(int)), this, SLOT(retentionChanged())); + } + if (useDurationRadio->isChecked()) { + int useDuration; + useDuration = secondsSpin->value() + minutesSpin->value() * 60 + + hoursSpin->value() * 3600 + daysSpin->value() * 86400 + + yearsSpin->value() * 31536000; + disconnect(useDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(useDurationChanged())); + useDurationSpin->setValue(useDuration); + connect(useDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(useDurationChanged())); + } +} + +/* Connect the spins */ +void MediaEdit::connectSpins() +{ + connect(secondsSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + connect(minutesSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + connect(hoursSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + connect(daysSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + connect(yearsSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); +} + +/* disconnect spins so that we can set the value of other spin from changed duration spin */ +void MediaEdit::disconnectSpins() +{ + disconnect(secondsSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + disconnect(minutesSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + disconnect(hoursSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + disconnect(daysSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); + disconnect(yearsSpin, SIGNAL(valueChanged(int)), this, SLOT(durationChanged())); +} + +/* slot for setting spins when retention radio checked */ +void MediaEdit::retentionRadioPressed() +{ + setSpins(retentionSpin->value()); +} + +/* slot for setting spins when duration radio checked */ +void MediaEdit::useDurationRadioPressed() +{ + setSpins(useDurationSpin->value()); } diff --git a/bacula/src/qt-console/mediaedit/mediaedit.h b/bacula/src/qt-console/mediaedit/mediaedit.h index eb11ebfadb..74fc207f2a 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.h +++ b/bacula/src/qt-console/mediaedit/mediaedit.h @@ -36,24 +36,34 @@ #include #include "ui_mediaedit.h" #include "console.h" +#include "pages.h" -class MediaEdit : public QDialog, public Ui::mediaeditForm +class MediaEdit : public Pages, public Ui::mediaEditForm { Q_OBJECT public: - MediaEdit(Console *console, QString &mediaId); + MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId); -public slots: - void accept(); - void reject(); +private slots: + void okButtonPushed(); + void cancelButtonPushed(); + void retentionChanged(); + void durationChanged(); + void useDurationChanged(); + void setSpins(int value); + void retentionRadioPressed(); + void useDurationRadioPressed(); private: - Console *m_console; + void connectSpins(); + void disconnectSpins(); QString m_mediaName; QString m_pool; QString m_status; int m_slot; + int m_retention; + int m_useDuration; }; #endif /* _MEDIAEDIT_H_ */ diff --git a/bacula/src/qt-console/mediaedit/mediaedit.ui b/bacula/src/qt-console/mediaedit/mediaedit.ui index f9b6e59331..ae8973f936 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.ui +++ b/bacula/src/qt-console/mediaedit/mediaedit.ui @@ -1,19 +1,16 @@ - mediaeditForm - - - Qt::WindowModal - + mediaEditForm + 0 0 - 416 - 230 + 515 + 334 - Label + Form @@ -22,195 +19,401 @@ 6 - - + + 0 6 - - - - Qt::Horizontal + + + + Minutes - - - 40 - 20 - + + + + + + 24 - + + -1 + + + 0 + + - - - - - 16777215 - 48 - + + + + 365 - - Volume : + + -1 - + + + + 0 + + + 6 + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 16777215 + 48 + + + + Volume : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 71 + 21 + + + + + + + + + 16777215 + 30 + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Edit a Volume</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 81 + 20 + + + + + + + + + + Slot: + + + slotSpin + + + + + + + Use Duration: + + + slotSpin + + + + + + + Retension: + + + slotSpin + + + + + + + 2147483647 + + + + + + + Volume Status: + + + + + + + 10000 + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + Pool: + + + poolCombo + + + + + + + + + + 2147483647 + + + + + + - Qt::Horizontal + Qt::Vertical - 40 - 20 + 97 + 16 - - - - - - 0 - - - 6 - - - + + - Volume Status: + Years - - + + + + Hours + + - - + + + + Use Duration + + - - + + - 10000 + 999 + + + -1 - - + + - Pool: - - - poolCombo + Days - - + + - Slot: - - - slotSpin + Seconds - - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 71 - 21 - + + + + Retention - + - - - - - 16777215 - 30 - + + + + 60 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Edit a Volume</span></p></body></html> + + -1 - - - - Qt::Horizontal + + + + 60 - - - 81 - 20 - + + -1 - + - + Qt::Vertical - - QSizePolicy::Maximum + + + 20 + 40 + + + + + + + + Qt::Vertical - 21 - 16 + 20 + 40 - - + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + 40 + 20 + - + - + - Qt::Vertical - - - QSizePolicy::Maximum + Qt::Horizontal - 398 - 16 + 40 + 20 @@ -218,38 +421,5 @@ p, li { white-space: pre-wrap; } - - - buttonBox - accepted() - mediaeditForm - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - mediaeditForm - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 6cad0dbb57..41bb944707 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -164,7 +164,7 @@ void MediaList::setStatusColor(QTreeWidgetItem *item, QString &field, int &index */ void MediaList::editVolume() { - MediaEdit* edit = new MediaEdit(m_console, m_currentVolumeId); + MediaEdit* edit = new MediaEdit(mainWin->getFromHash(this), m_currentVolumeId); connect(edit, SIGNAL(destroyed()), this, SLOT(populateTree())); } -- 2.39.5