Logo Search packages:      
Sourcecode: d3lphin version File versions  Download package

void Dolphin::addUndoOperation ( KIO::Job *  job  )  [private, slot]

Adds the undo operation given by job to the UndoManager.

Definition at line 1000 of file dolphin.cpp.

References UndoManager::addCommand(), DolphinStatusBar::setMessage(), DolphinCommand::setSource(), slotHandleJobError(), DolphinCommand::source(), DolphinView::statusBar(), and DolphinCommand::type().

{
    if (job->error() != 0) {
        slotHandleJobError(job);
    }
    else {
        const int id = job->progressId();

        // set iterator to the executed command with the current id...
        QValueList<UndoInfo>::Iterator it = m_pendingUndoJobs.begin();
        const QValueList<UndoInfo>::Iterator end = m_pendingUndoJobs.end();
        bool found = false;
        while (!found && (it != end)) {
            if ((*it).id == id) {
                found = true;
            }
            else {
                ++it;
            }
        }

        if (found) {
            DolphinCommand command = (*it).command;
            if (command.type() == DolphinCommand::Trash) {
                // To be able to perform an undo for the 'Move to Trash' operation
                // all source URLs must be updated with the trash URL. E. g. when moving
                // a file "test.txt" and a second file "test.txt" to the trash,
                // then the filenames in the trash are "0-test.txt" and "1-test.txt".
                QMap<QString, QString> metaData = job->metaData();
                KURL::List newSourceURLs;

                KURL::List sourceURLs = command.source();
                KURL::List::Iterator sourceIt = sourceURLs.begin();
                const KURL::List::Iterator sourceEnd = sourceURLs.end();

                while (sourceIt != sourceEnd) {
                    QMap<QString, QString>::ConstIterator metaIt = metaData.find("trashURL-" + (*sourceIt).path());
                    if (metaIt != metaData.end()) {
                        newSourceURLs.append(KURL(metaIt.data()));
                    }
                    ++sourceIt;
                }
                command.setSource(newSourceURLs);
            }

            UndoManager::instance().addCommand(command);
            m_pendingUndoJobs.erase(it);

            DolphinStatusBar* statusBar = m_activeView->statusBar();
            switch (command.type()) {
                case DolphinCommand::Copy:
                    statusBar->setMessage(i18n("Copy operation completed."),
                                          DolphinStatusBar::OperationCompleted);
                    break;
                case DolphinCommand::Move:
                    statusBar->setMessage(i18n("Move operation completed."),
                                          DolphinStatusBar::OperationCompleted);
                    break;
                case DolphinCommand::Trash:
                    statusBar->setMessage(i18n("Move to trash operation completed."),
                                          DolphinStatusBar::OperationCompleted);
                    break;
                default:
                    break;
            }
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index