]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/restore/restore.cpp
Read and write settings for the splitter in restore.
[bacula/bacula] / bacula / src / qt-console / restore / restore.cpp
index d4e2dd1a09258132909e86d4731d15e39019ad32..d55ca4dac22d8a9d8fffa1dca0737a3e9706512a 100644 (file)
@@ -45,6 +45,9 @@ restorePage::restorePage()
    setupUi(this);
    m_name = "Restore Select";
    pgInitialize();
+   QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
+   thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png")));
+
    m_console->notify(false);          /* this should already be off */
    m_closeable = true;
 
@@ -58,6 +61,13 @@ restorePage::restorePage()
    connect(unmarkButton, SIGNAL(pressed()), this, SLOT(unmarkButtonPushed()));
    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
+
+   fileWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
+   fileWidget->addAction(actionMark);
+   fileWidget->addAction(actionUnMark);
+   connect(actionMark, SIGNAL(triggered()), this, SLOT(markButtonPushed()));
+   connect(actionUnMark, SIGNAL(triggered()), this, SLOT(unmarkButtonPushed()));
+
    setFont(m_console->get_font());
    m_console->displayToPrompt();
 
@@ -66,12 +76,18 @@ restorePage::restorePage()
 
    get_cwd();
 
+   readSettings();
    fillDirectory();
    dockPage();
    setCurrent();
    this->show();
 }
 
+restorePage::~restorePage()
+{
+   writeSettings();
+}
+
 /*
  * Fill the fileWidget box with the contents of the current directory
  */
@@ -139,9 +155,11 @@ void restorePage::fillDirectory()
       QTreeWidgetItem *ti = new QTreeWidgetItem((QTreeWidget *)0, item);
       ti->setTextAlignment(5, Qt::AlignRight); /* right align size */
       if (strcmp(marked, "*") == 0) {
-         ti->setIcon(0,QIcon(QString::fromUtf8(":images/check.png")));
+         ti->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
+         ti->setData(0, Qt::UserRole, true);
       } else {
-         ti->setIcon(0,QIcon(QString::fromUtf8(":images/unchecked.png")));
+         ti->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
+         ti->setData(0, Qt::UserRole, false);
       }
       treeItemList.append(ti);
    }
@@ -177,6 +195,8 @@ void restorePage::addDirectory(QString &newdirr)
    /* add unix '/' directory first */
    if (m_dirPaths.empty() && (regex.indexIn(fullpath,0) == -1)) {
       QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
+      item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.svg")));
+      
       QString text("/");
       item->setText(0, text.toUtf8().data());
       if (mainWin->m_miscDebug) {
@@ -189,7 +209,7 @@ void restorePage::addDirectory(QString &newdirr)
    if (regex.indexIn(fullpath,0) == 0) {
       /* this is a windows drive */
       if (mainWin->m_miscDebug) {
-         printf("Need to do windows \"letter\":/\n");
+         Pmsg0(000, "Need to do windows \"letter\":/\n");
       }
       fullpath.replace(0,1,"");
       windrive = true;
@@ -202,12 +222,14 @@ void restorePage::addDirectory(QString &newdirr)
          /* this is the base widget */
          item = new QTreeWidgetItem(directoryWidget);
          item->setText(0, fullpath.toUtf8().data());
+         item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.svg")));
       } else {
          QTreeWidgetItem *parent = m_dirPaths.value(m_cwd);
          if (parent) {
             /* new directories to add */
             item = new QTreeWidgetItem(parent);
             item->setText(0, newdir.toUtf8().data());
+            item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.svg")));
             directoryWidget->expandItem(parent);
          } else {
             ok = false;
@@ -270,12 +292,14 @@ void restorePage::fileDoubleClicked(QTreeWidgetItem *item, int column)
 {
    char cmd[1000];
    if (column == 0) {                 /* mark/unmark */
-      if (item->text(0) == "*") {
+      if (item->data(0, Qt::UserRole).toBool()) {
          bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
          item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
+         item->setData(0, Qt::UserRole, false);
       } else {
          bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
          item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
+         item->setData(0, Qt::UserRole, true);
       }
       m_console->write_dir(cmd);
       if (m_console->read() > 0) {
@@ -404,3 +428,25 @@ char *restorePage::get_cwd()
    m_console->discardToPrompt(); 
    return m_cwd.toUtf8().data();
 }
+
+/*
+ * Save user settings associated with this page
+ */
+void restorePage::writeSettings()
+{
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup("RestorePage");
+   settings.setValue("splitterSizes", splitter->saveState());
+   settings.endGroup();
+}
+
+/*
+ * Read and restore user settings associated with this page
+ */
+void restorePage::readSettings()
+{
+   QSettings settings(m_console->m_dir->name(), "bat");
+   settings.beginGroup("RestorePage");
+   splitter->restoreState(settings.value("splitterSizes").toByteArray());
+   settings.endGroup();
+}