]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/restore/restoretree.cpp
ebl Generated 193 translations (186 finished and 7 unfinished)
[bacula/bacula] / bacula / src / qt-console / restore / restoretree.cpp
index e1594a39b9bec92a936fff99a66bf28733108e50..ee9055109ac0addcb366c4e08bd85a929d2dcd94 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -42,7 +42,7 @@
 restoreTree::restoreTree()
 {
    setupUi(this);
-   m_name = "Version Browser";
+   m_name = tr("Version Browser");
    pgInitialize();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0, QIcon(QString::fromUtf8(":images/browse.png")));
@@ -51,9 +51,6 @@ restoreTree::restoreTree()
    m_populated = false;
 
    dockPage();
-   m_winRegExpDrive.setPattern("^[a-zA-Z]:/$");
-   m_winRegExpPath.setPattern("^[a-zA-Z]:/");
-   m_slashregex.setPattern("/");
    m_debugCnt = 0;
    m_debugTrap = true;
 
@@ -118,12 +115,12 @@ void restoreTree::setupPage()
    connect(jobTable, SIGNAL(cellClicked(int, int)),
            this, SLOT(jobTableCellClicked(int, int)));
 
-   QStringList titles = QStringList() << "Directories";
+   QStringList titles = QStringList() << tr("Directories");
    directoryTree->setHeaderLabels(titles);
    clientCombo->addItems(m_console->client_list);
-   fileSetCombo->addItem("Any");
+   fileSetCombo->addItem(tr("Any"));
    fileSetCombo->addItems(m_console->fileset_list);
-   jobCombo->addItem("Any");
+   jobCombo->addItem(tr("Any"));
    jobCombo->addItems(m_console->job_list);
 
    directoryTree->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -142,10 +139,10 @@ void restoreTree::updateRefresh()
    );
    if (m_dropdownChanged) {
       if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is CHANGED\n");
-      refreshLabel->setText("Refresh From Re-Select");
+      refreshLabel->setText(tr("Refresh From Re-Select"));
    } else {
       if (mainWin->m_rtPopDirDebug) Pmsg0(000, "In restoreTree::updateRefresh Is not Changed\n");
-      refreshLabel->setText("Refresh From JobChecks");
+      refreshLabel->setText(tr("Refresh From JobChecks"));
    }
 }
 
@@ -177,11 +174,11 @@ void restoreTree::populateDirectoryTree()
    prBar1->setVisible(true);
    prBar1->setRange(0,taskcount);
    prBar1->setValue(0);
-   prLabel1->setText("Task " + QString("%1").arg(ontask)+ " of " + QString("%1").arg(taskcount));
+   prLabel1->setText(tr("Task ") + QString("%1").arg(ontask)+ " of " + QString("%1").arg(taskcount));
    prLabel1->setVisible(true);
    prBar2->setVisible(true);
    prBar2->setRange(0,0);
-   prLabel2->setText("Querying Database");
+   prLabel2->setText(tr("Querying Database"));
    prLabel2->setVisible(true);
    repaint();
 
@@ -195,17 +192,15 @@ void restoreTree::populateDirectoryTree()
       m_prevDaysCheckState = daysCheckBox->checkState();
       updateRefresh();
       prBar1->setValue(ontask++);
-      prLabel1->setText("Task " + QString("%1").arg(ontask)+ " of " + QString("%1").arg(taskcount));
+      prLabel1->setText(tr("Task ") + QString("%1").arg(ontask)+ " of " + QString("%1").arg(taskcount));
       prBar2->setValue(0);
       prBar2->setRange(0,0);
-      prLabel2->setText("Querying Jobs");
+      prLabel2->setText(tr("Querying Jobs"));
       repaint();
       populateJobTable();
-      setJobsCheckedList();
-   } else {
-      if (mainWin->m_rtPopDirDebug) Pmsg0(000, "Repopulating from checks in Job Table\n");
-      setJobsCheckedList();
    }
+   setJobsCheckedList();
+   if (mainWin->m_rtPopDirDebug) Pmsg0(000, "Repopulating from checks in Job Table\n");
 
    if (m_checkedJobs != "") {
       /* First get the filenameid of where the nae is null.  These will be the directories
@@ -240,10 +235,10 @@ void restoreTree::populateDirectoryTree()
       if (mainWin->m_sqlDebug)
          Pmsg1(000, "Query cmd : %s\n", cmd.toUtf8().data());
       prBar1->setValue(ontask++);
-      prLabel1->setText("Task " + QString("%1").arg(ontask) + " of " + QString("%1").arg(taskcount));
+      prLabel1->setText(tr("Task ") + QString("%1").arg(ontask) + " of " + QString("%1").arg(taskcount));
       prBar2->setValue(0);
       prBar2->setRange(0,0);
-      prLabel2->setText("Querying for Directories");
+      prLabel2->setText(tr("Querying for Directories"));
       repaint();
       QStringList results;
       m_directoryPathIdHash.clear();
@@ -251,7 +246,7 @@ void restoreTree::populateDirectoryTree()
       if (m_console->sql_cmd(cmd, results)) {
          if (!querydone) {
             querydone = true;
-            prLabel2->setText("Processing Directories");
+            prLabel2->setText(tr("Processing Directories"));
             prBar2->setRange(0,results.count());
             repaint();
          }
@@ -259,8 +254,10 @@ void restoreTree::populateDirectoryTree()
             Pmsg1(000, "Done with query %i results\n", results.count());
          QStringList fieldlist;
          foreach(QString resultline, results) {
-            m_debugCnt += 1;
-            prBar2->setValue(m_debugCnt);
+            /* Update progress bar periodically */
+            if ((++m_debugCnt && 0x3FF) == 0) {
+               prBar2->setValue(m_debugCnt);
+            }
             fieldlist = resultline.split("\t");
             int fieldcnt = 0;
             QString field;
@@ -279,7 +276,7 @@ void restoreTree::populateDirectoryTree()
          }
       }
    } else {
-     QMessageBox::warning(this, tr("Bat"),
+     QMessageBox::warning(this, "Bat",
         tr("No jobs were selected in the job query !!!.\n"
       "Press OK to continue?"),
       QMessageBox::Ok );
@@ -324,15 +321,14 @@ void restoreTree::setJobsCheckedList()
  */
 void restoreTree::parseDirectory(QString &dir_in)
 {
-   /* m_debugTrap is to only print debugs for a few occurances of calling parseDirectory
+   /* m_debugTrap is to only print debugs for a few occurennces of calling parseDirectory
     * instead of printing out what could potentially a whole bunch */
    if (m_debugCnt > 2)
       m_debugTrap = false;
-   /* Clean up the directory string remove some funny char after last '/' */
-   QRegExp rgx("[^/]$");
-   int lastslash = rgx.indexIn(dir_in);
-   if (lastslash != -1)
-      dir_in.replace(lastslash, dir_in.length()-lastslash, "");
+   /* Truncate everything after the last / */
+   if (dir_in.right(1) != "/") {
+      dir_in.truncate(dir_in.lastIndexOf("/") + 1);
+   }
    if ((mainWin->m_miscDebug) && (m_debugTrap))
       Pmsg1(000, "parsing %s\n", dir_in.toUtf8().data());
 
@@ -344,7 +340,7 @@ void restoreTree::parseDirectory(QString &dir_in)
    /* start from the end, turn /etc/somedir/subdir/ into /etc/somedir and subdir/ 
     * if not added into tree, then try /etc/ and somedir/ if not added, then try
     * / and etc/ .  That should succeed, then add the ones that failed in reverse */
-   while (((index = m_slashregex.lastIndexIn(dir_in, -2)) != -1) && (!done)) {
+   while (((index = dir_in.lastIndexOf("/", -2)) != -1) && (!done)) {
       direct = path = dir_in;
       path.replace(index+1, dir_in.length()-index-1,"");
       direct.replace(0, index+1, "");
@@ -373,6 +369,7 @@ void restoreTree::parseDirectory(QString &dir_in)
    }
 }
 
+
 /*
  * Function called from fill directory when a directory is found to see if this
  * directory exists in the directory pane and then add it to the directory pane
@@ -384,7 +381,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
    bool ok = true, added = false;
 
    if ((mainWin->m_miscDebug) && (m_debugTrap)) {
-      QString msg = QString("In addDirectory cwd \"%1\" newdir \"%2\"\n")
+      QString msg = QString(tr("In addDirectory cwd \"%1\" newdir \"%2\"\n"))
                     .arg(m_cwd)
                     .arg(newdir);
       Pmsg0(000, msg.toUtf8().data());
@@ -392,7 +389,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
 
    if (!m_slashTrap) {
       /* add unix '/' directory first */
-      if (m_dirPaths.empty() && (m_winRegExpPath.indexIn(fullPath, 0) == -1)) {
+      if (m_dirPaths.empty() && !isWin32Path(fullPath)) {
          m_slashTrap = true;
          QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
          QString text("/");
@@ -406,7 +403,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
          m_dirPaths.insert(text, item);
       }
       /* no need to check for windows drive if unix */
-      if (m_winRegExpDrive.indexIn(m_cwd, 0) == 0) {
+      if (isWin32Path(m_cwd)) {
          if (!m_dirPaths.contains(m_cwd)) {
             /* this is a windows drive add the base widget */
             QTreeWidgetItem *item = new QTreeWidgetItem(directoryTree);
@@ -438,7 +435,7 @@ bool restoreTree::addDirectory(QString &m_cwd, QString &newdirr)
       } else {
          ok = false;
          if ((mainWin->m_miscDebug) && (m_debugTrap)) {
-            QString msg = QString("In else of if parent cwd \"%1\" newdir \"%2\"\n")
+            QString msg = QString(tr("In else of if parent cwd \"%1\" newdir \"%2\"\n"))
                  .arg(m_cwd)
                  .arg(newdir);
             Pmsg0(000, msg.toUtf8().data());
@@ -482,8 +479,8 @@ void restoreTree::refreshButtonPushed()
  */
 void restoreTree::jobComboChanged(int)
 {
-   if (jobCombo->currentText() == "Any") {
-      fileSetCombo->setCurrentIndex(fileSetCombo->findText("Any", Qt::MatchExactly));
+   if (jobCombo->currentText() == tr("Any")) {
+      fileSetCombo->setCurrentIndex(fileSetCombo->findText(tr("Any"), Qt::MatchExactly));
       return;
    }
    job_defaults job_defs;
@@ -511,7 +508,7 @@ void restoreTree::directoryCurrentItemChanged(QTreeWidgetItem *item, QTreeWidget
    versionTable->setRowCount(0);
    versionTable->setColumnCount(0);
 
-   QStringList headerlist = (QStringList() << "File Name" << "Filename Id");
+   QStringList headerlist = (QStringList() << tr("File Name") << tr("Filename Id"));
    fileTable->setColumnCount(headerlist.size());
    fileTable->setHorizontalHeaderLabels(headerlist);
    fileTable->setRowCount(0);
@@ -521,7 +518,7 @@ void restoreTree::directoryCurrentItemChanged(QTreeWidgetItem *item, QTreeWidget
            this, SLOT(fileTableItemChanged(QTableWidgetItem *)));
    QBrush blackBrush(Qt::black);
    QString directory = item->data(0, Qt::UserRole).toString();
-   directoryLabel->setText("Present Working Directory : " + directory);
+   directoryLabel->setText(tr("Present Working Directory : ") + directory);
    int pathid = m_directoryPathIdHash.value(directory, -1);
    if (pathid != -1) {
       QString cmd =
@@ -615,7 +612,8 @@ void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem,
 
    QBrush blackBrush(Qt::black);
 
-   QStringList headerlist = (QStringList() << "Job Id" << "Type" << "End Time" << "Md5" << "FileId");
+   QStringList headerlist = (QStringList() 
+      << tr("Job Id") << tr("Type") << tr("End Time") << tr("Hash") << tr("FileId"));
    versionTable->clear();
    versionTable->setColumnCount(headerlist.size());
    versionTable->setHorizontalHeaderLabels(headerlist);
@@ -624,7 +622,7 @@ void restoreTree::fileCurrentItemChanged(QTableWidgetItem *currentFileTableItem,
    int pathid = m_directoryPathIdHash.value(directory, -1);
    if ((pathid != -1) && (fileNameId != -1)) {
       QString cmd = 
-         "SELECT Job.JobId AS JobId, Job.Level AS Type, Job.EndTime AS EndTime, File.Md5 AS MD5, File.FileId AS FileId"
+         "SELECT Job.JobId AS JobId,Job.Level AS Type,Job.EndTime AS EndTime,File.MD5 AS MD5,File.FileId AS FileId"
          " FROM File"
          " INNER JOIN Filename on (Filename.FilenameId=File.FilenameId)"
          " INNER JOIN Path ON (Path.PathId=File.PathId)"
@@ -701,7 +699,7 @@ void restoreTree::writeSettings()
  */
 void restoreTree::readSettings()
 {
-   m_groupText = "RestoreTreePage";
+   m_groupText = tr("RestoreTreePage");
    m_splitText = "splitterSizes_1";
    QSettings settings(m_console->m_dir->name(), "bat");
    settings.beginGroup(m_groupText);
@@ -725,7 +723,7 @@ void restoreTree::directoryItemExpanded(QTreeWidgetItem *item)
 }
 
 /*
- * I wanted a table to show what jobs meet the criterion and are being used to
+ * Show what jobs meet the criteria and are being used to
  * populate the directory tree and file and version tables.
  */
 void restoreTree::populateJobTable()
@@ -733,25 +731,28 @@ void restoreTree::populateJobTable()
    QBrush blackBrush(Qt::black);
 
    if (mainWin->m_rtPopDirDebug) Pmsg0(000, "Repopulating the Job Table\n");
-   QStringList headerlist = (QStringList() << "Job Id" << "End Time" << "Level" << "Name" << "Purged" << "TU" << "TD");
-   m_toggleUpIndex = headerlist.indexOf("TU");
-   m_toggleDownIndex = headerlist.indexOf("TD");
-   int purgedIndex = headerlist.indexOf("Purged");
+   QStringList headerlist = (QStringList() 
+      << tr("Job Id") << tr("End Time") << tr("Level") 
+      << tr("Name") << tr("Purged") << tr("TU") << tr("TD"));
+   m_toggleUpIndex = headerlist.indexOf(tr("TU"));
+   m_toggleDownIndex = headerlist.indexOf(tr("TD"));
+   int purgedIndex = headerlist.indexOf(tr("Purged"));
    jobTable->clear();
    jobTable->setColumnCount(headerlist.size());
    jobTable->setHorizontalHeaderLabels(headerlist);
    QString jobQuery =
-      "SELECT Job.Jobid AS Id, Job.EndTime AS EndTime, Job.Level AS Level, Job.Name AS JobName, Job.purgedfiles AS Purged"
+      "SELECT Job.Jobid AS Id,Job.EndTime AS EndTime,Job.Level AS Level,"
+      "Job.Name AS JobName,Job.purgedfiles AS Purged"
       " FROM Job"
       /* INNER JOIN FileSet eliminates all restore jobs */
       " INNER JOIN Client ON (Job.ClientId=Client.ClientId)"
       " INNER JOIN FileSet ON (Job.FileSetId=FileSet.FileSetId)"
       " WHERE"
       " Client.Name='" + clientCombo->currentText() + "'";
-   if ((jobCombo->currentIndex() >= 0) && (jobCombo->currentText() != "Any")) {
+   if ((jobCombo->currentIndex() >= 0) && (jobCombo->currentText() != tr("Any"))) {
       jobQuery += " AND Job.name = '" + jobCombo->currentText() + "'";
    }
-   if ((fileSetCombo->currentIndex() >= 0) && (fileSetCombo->currentText() != "Any")) {
+   if ((fileSetCombo->currentIndex() >= 0) && (fileSetCombo->currentText() != tr("Any"))) {
       jobQuery += " AND FileSet.FileSet='" + fileSetCombo->currentText() + "'";
    }
    /* If Limit check box For limit by days is checked  */
@@ -1280,7 +1281,7 @@ void restoreTree::fullPathtoSubPaths(QStringList &subPaths, QString &fullPath_in
    bool done = false;
    QString fullPath = fullPath_in;
    QString direct, path;
-   while (((index = m_slashregex.lastIndexIn(fullPath, -2)) != -1) && (!done)) {
+   while (((index = fullPath.lastIndexOf("/", -2)) != -1) && (!done)) {
       direct = path = fullPath;
       path.replace(index+1, fullPath.length()-index-1, "");
       direct.replace(0, index+1, "");
@@ -1730,7 +1731,7 @@ int restoreTree::mostRecentVersionfromFullPath(QString &fullPath)
 {
    int qversion = 0;
    QString directory, fileName;
-   int index = m_slashregex.lastIndexIn(fullPath, -2);
+   int index = fullPath.lastIndexOf("/", -2);
    if (index != -1) {
       directory = fileName = fullPath;
       directory.replace(index+1, fullPath.length()-index-1, "");
@@ -1783,7 +1784,7 @@ int restoreTree::queryFileIndex(QString &fullPath, int jobId)
 {
    int qfileIndex = 0;
    QString directory, fileName;
-   int index = m_slashregex.lastIndexIn(fullPath, -2);
+   int index = fullPath.lastIndexOf("/", -2);
    if (index != -1) {
       directory = fileName = fullPath;
       directory.replace(index+1, fullPath.length()-index-1, "");