+ mainWin->waitExit();
+}
+
+/*
+ * 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
+ */
+void restorePage::addDirectory(QString &newdirr)
+{
+ QString newdir = newdirr;
+ QString fullpath = m_cwd + newdirr;
+ bool ok = true;
+ bool windrive = false;
+
+ if (mainWin->m_miscDebug) {
+ QString msg = QString(tr("In addDirectory cwd \"%1\" newdir \"%2\" fullpath \"%3\"\n"))
+ .arg(m_cwd)
+ .arg(newdir)
+ .arg(fullpath);
+ Pmsg0(dbglvl, msg.toUtf8().data());
+ }
+
+ if (isWin32Path(newdir)) {
+ /* this is a windows drive */
+ if (mainWin->m_miscDebug) {
+ Pmsg0(dbglvl, "Found windows drive\n");
+ }
+ windrive = true;
+ }
+
+ if (windrive) {
+ if (fullpath.left(1) == "/") {
+ fullpath.replace(0, 1, ""); /* strip leading / */
+ }
+ /* If drive and not already in add it */
+ if (fullpath.length() == 3 && !m_dirPaths.contains(fullpath)) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
+ item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+ item->setText(0, fullpath.toUtf8().data());
+ if (mainWin->m_miscDebug) {
+ Pmsg1(dbglvl, "Pre Inserting %s\n",fullpath.toUtf8().data());
+ }
+ m_dirPaths.insert(fullpath, item);
+ m_dirTreeItems.insert(item, fullpath);
+ directoryWidget->setCurrentItem(NULL);
+ }
+ } else {
+ // Unix add / first if not already there
+ if (m_dirPaths.empty()) {
+ QTreeWidgetItem *item = new QTreeWidgetItem(directoryWidget);
+ item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+
+ QString text("/");
+ item->setText(0, text.toUtf8().data());
+ if (mainWin->m_miscDebug) {
+ Pmsg1(dbglvl, "Pre Inserting %s\n",text.toUtf8().data());
+ }
+ m_dirPaths.insert(text, item);
+ m_dirTreeItems.insert(item, text);
+ }
+ }
+
+ /* Does it already exist ?? */
+ if (!m_dirPaths.contains(fullpath)) {
+ QTreeWidgetItem *item = NULL;
+ if (windrive) {
+ /* this is the base widget */
+ item = new QTreeWidgetItem(directoryWidget);
+ item->setText(0, fullpath.toUtf8().data());
+ item->setIcon(0,QIcon(QString::fromUtf8(":images/folder.png")));
+ } 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.png")));
+ directoryWidget->expandItem(parent);
+ } else {
+ ok = false;
+ if (mainWin->m_miscDebug) {
+ QString msg = QString(tr("In else of if parent cwd \"%1\" newdir \"%2\"\n"))
+ .arg(m_cwd)
+ .arg(newdir);
+ Pmsg0(dbglvl, msg.toUtf8().data());
+ }
+ }
+ }
+ /* insert into both forward and reverse hash */
+ if (ok) {
+ if (mainWin->m_miscDebug) {
+ Pmsg1(dbglvl, "Inserting %s\n",fullpath.toUtf8().data());
+ }
+ m_dirPaths.insert(fullpath, item);
+ m_dirTreeItems.insert(item, fullpath);
+ }
+ }
+}
+
+/*
+ * Executed when the tree item in the directory pane is changed. This will
+ * allow us to populate the file pane and make this the cwd.
+ */
+void restorePage::directoryItemChanged(QTreeWidgetItem *currentitem,
+ QTreeWidgetItem * /*previousitem*/)
+{
+ QString fullpath = m_dirTreeItems.value(currentitem);
+ statusLine->setText("");
+ if (fullpath != "") {
+ cwd(fullpath.toUtf8().data());
+ fillDirectory();
+ }