Commit a3b0a85e authored by Eduardo Robles Elvira's avatar Eduardo Robles Elvira

Support for undo closed windows (see...

Support for undo closed windows (see http://lists.kde.org/?l=kfm-devel&m=120570110719593&w=2 for details)


svn path=/trunk/KDE/kdebase/apps/; revision=786639
parent 5e7161ef
......@@ -22,13 +22,23 @@
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
#include <konqpixmapprovider.h>
K_GLOBAL_STATIC_WITH_ARGS(KConfig, s_config, ("konqueror_closedtabs", KConfig::NoGlobals) )
KonqClosedItem::KonqClosedItem(const QString& title, const QString& group, quint64 serialNumber)
: m_title(title), m_configGroup(s_config, group), m_serialNumber(serialNumber)
{
}
KonqClosedItem::~KonqClosedItem()
{
m_configGroup.deleteGroup();
kDebug(1202) << "deleted group" << m_configGroup.name();
}
KonqClosedTabItem::KonqClosedTabItem(const QString& url, const QString& title, int pos, quint64 serialNumber)
: m_url(url), m_title(title), m_pos(pos),
m_configGroup(s_config, "Closed_Tab" + QString::number((qint64)this)),
m_serialNumber(serialNumber)
: KonqClosedItem(title, "Closed_Tab" + QString::number((qint64)this), serialNumber), m_url(url), m_pos(pos)
{
kDebug(1202) << m_configGroup.name();
}
......@@ -38,3 +48,23 @@ KonqClosedTabItem::~KonqClosedTabItem()
m_configGroup.deleteGroup();
kDebug(1202) << "deleted group" << m_configGroup.name();
}
QPixmap KonqClosedTabItem::icon() {
return KonqPixmapProvider::self()->pixmapFor(m_url);
}
KonqClosedWindowItem::KonqClosedWindowItem(const QString& title, quint64 serialNumber)
: KonqClosedItem(title, "Closed_Window" + QString::number((qint64)this), serialNumber)
{
kDebug(1202) << m_configGroup.name();
}
KonqClosedWindowItem::~KonqClosedWindowItem()
{
m_configGroup.deleteGroup();
kDebug(1202) << "deleted group" << m_configGroup.name();
}
QPixmap KonqClosedWindowItem::icon() {
return KonqPixmapProvider::self()->pixmapFor("about:blank");
}
......@@ -25,31 +25,49 @@
#include <kconfiggroup.h>
#include <QString>
class KONQ_TESTS_EXPORT KonqClosedItem : public QObject {
public:
virtual ~KonqClosedItem();
const KConfigGroup& configGroup() const { return m_configGroup; }
KConfigGroup& configGroup() { return m_configGroup; }
quint64 serialNumber() const { return m_serialNumber; }
QString title() const { return m_title; }
virtual QPixmap icon() = 0;
protected:
KonqClosedItem(const QString& title, const QString& group, quint64 serialNumber);
QString m_title;
KConfigGroup m_configGroup;
quint64 m_serialNumber;
};
/**
* This class stores all the needed information about a closed tab
* in order to be able to reopen it if requested
*/
class KONQ_TESTS_EXPORT KonqClosedTabItem {
class KONQ_TESTS_EXPORT KonqClosedTabItem : public KonqClosedItem {
public:
KonqClosedTabItem(const QString& url, const QString& title, int index, quint64 serialNumber);
~KonqClosedTabItem();
const KConfigGroup& configGroup() const { return m_configGroup; }
KConfigGroup& configGroup() { return m_configGroup; }
quint64 serialNumber() const { return m_serialNumber; }
virtual ~KonqClosedTabItem();
virtual QPixmap icon();
QString url() const { return m_url; }
QString title() const { return m_title; }
/// The position inside the tabbar that the tab had when it was closed
/// The position inside the tabbar that the tab had when it was closed
int pos() const { return m_pos; }
private:
protected:
QString m_url;
QString m_title;
int m_pos;
KConfigGroup m_configGroup;
quint64 m_serialNumber;
};
// Copying an item would delete the group in the config file (see destructor)!
Q_DISABLE_COPY(KonqClosedTabItem)
/**
* This class stores all the needed information about a closed tab
* in order to be able to reopen it if requested
*/
class KONQ_TESTS_EXPORT KonqClosedWindowItem : public KonqClosedItem {
public:
KonqClosedWindowItem(const QString& title, quint64 serialNumber);
virtual ~KonqClosedWindowItem();
virtual QPixmap icon();
};
#endif /* KONQCLOSEDTABITEM_H */
......
......@@ -169,6 +169,7 @@ KonqOpenURLRequest KonqOpenURLRequest::null;
static int current_memory_usage( int* limit = NULL );
static unsigned short int s_closedTabsListLength = 10;
static unsigned long s_konqMainWindowInstancesCount = 0;
KonqExtendedBookmarkOwner::KonqExtendedBookmarkOwner(KonqMainWindow *w)
{
......@@ -177,8 +178,9 @@ KonqExtendedBookmarkOwner::KonqExtendedBookmarkOwner(KonqMainWindow *w)
KonqMainWindow::KonqMainWindow( const KUrl &initialURL, const QString& xmluiFile)
: KParts::MainWindow(),
m_paClosedTabs(0)
m_paClosedItems(0)
{
incInstancesCount();
setPreloadedFlag( false );
if ( !s_lstViews )
......@@ -319,7 +321,7 @@ KonqMainWindow::KonqMainWindow( const KUrl &initialURL, const QString& xmluiFile
KonqMainWindow::~KonqMainWindow()
{
//kDebug(1202) << "KonqMainWindow::~KonqMainWindow " << this;
kDebug(1202) << "KonqMainWindow::~KonqMainWindow " << this;
delete m_pViewManager;
m_pViewManager = 0;
......@@ -341,7 +343,7 @@ KonqMainWindow::~KonqMainWindow()
delete m_paBookmarkBar;
delete m_pBookmarksOwner;
delete m_pURLCompletion;
delete m_paClosedTabs;
delete m_paClosedItems;
if ( s_lstViews == 0 ) {
delete s_comboConfig;
......@@ -354,10 +356,23 @@ KonqMainWindow::~KonqMainWindow()
m_combo = 0;
delete m_locationLabel;
m_locationLabel = 0;
m_undoManager->disconnect();
delete m_undoManager;
decInstancesCount();
//kDebug(1202) << "KonqMainWindow::~KonqMainWindow " << this << " done";
}
void KonqMainWindow::incInstancesCount()
{
s_konqMainWindowInstancesCount++;
}
void KonqMainWindow::decInstancesCount()
{
s_konqMainWindowInstancesCount--;
}
QWidget * KonqMainWindow::createContainer( QWidget *parent, int index, const QDomElement &element, QAction* &containerAction )
{
QWidget *res = KParts::MainWindow::createContainer( parent, index, element, containerAction );
......@@ -2859,32 +2874,31 @@ void KonqMainWindow::slotBackAboutToShow()
/**
* Fill the closed tabs action menu before it's shown
*/
void KonqMainWindow::slotClosedTabsListAboutToShow()
void KonqMainWindow::slotClosedItemsListAboutToShow()
{
kDebug(1202);
QMenu* popup = m_paClosedTabs->menu();
QMenu* popup = m_paClosedItems->menu();
// Clear the menu and fill it with a maximum of s_closedTabsListLength number of urls
popup->clear();
QAction* clearAction = popup->addAction( i18n("Empty Closed Tabs History") );
connect(clearAction, SIGNAL(triggered()), m_undoManager, SLOT(clearClosedTabsList()));
connect(clearAction, SIGNAL(triggered()), m_undoManager, SLOT(clearClosedItemsList()));
popup->insertSeparator();
QList<KonqClosedTabItem *>::ConstIterator it = m_undoManager->closedTabsList().begin();
const QList<KonqClosedTabItem *>::ConstIterator end = m_undoManager->closedTabsList().end();
QList<KonqClosedItem *>::ConstIterator it = m_undoManager->closedTabsList().begin();
const QList<KonqClosedItem *>::ConstIterator end = m_undoManager->closedTabsList().end();
for ( int i = 0; it != end && i < s_closedTabsListLength; ++it, ++i ) {
const QString text = QString::number(i) + ' ' + (*it)->title();
const QString url = (*it)->url();
QAction* action = popup->addAction( KonqPixmapProvider::self()->pixmapFor(url), text );
action->setActionGroup(m_closedTabsGroup);
QAction* action = popup->addAction( (*it)->icon(), text );
action->setActionGroup(m_closedItemsGroup);
action->setData(i);
}
KAcceleratorManager::manage(popup);
kDebug(1202) << "done";
}
void KonqMainWindow::updateClosedTabsAction()
void KonqMainWindow::updateClosedItemsAction()
{
m_paClosedTabs->setEnabled(!m_undoManager->closedTabsList().isEmpty());
m_paClosedItems->setEnabled(!m_undoManager->closedTabsList().isEmpty());
}
void KonqMainWindow::slotBack()
......@@ -3515,17 +3529,18 @@ void KonqMainWindow::initActions()
// Trash bin of closed tabs
m_paClosedTabs = new KToolBarPopupAction( KIcon("edit-undo-closed-tabs"), i18n( "Closed Tabs" ), this );
actionCollection()->addAction( "closedtabs", m_paClosedTabs );
m_closedTabsGroup = new QActionGroup(m_paClosedTabs->menu());
m_paClosedItems = new KToolBarPopupAction( KIcon("edit-undo-closed-tabs"), i18n( "Closed Tabs" ), this );
actionCollection()->addAction( "closedtabs", m_paClosedItems );
m_closedItemsGroup = new QActionGroup(m_paClosedItems->menu());
// set the maximum number of closed tabs list shown
connect( m_paClosedTabs, SIGNAL(triggered()), m_undoManager, SLOT(undoLastClosedTab()) );
connect( m_paClosedTabs->menu(), SIGNAL(aboutToShow()), this, SLOT(slotClosedTabsListAboutToShow()) );
connect( m_closedTabsGroup, SIGNAL(triggered(QAction*)), m_undoManager, SLOT(slotClosedTabsActivated(QAction*)) );
connect( m_paClosedItems, SIGNAL(triggered()), m_undoManager, SLOT(undoLastClosedItem()) );
connect( m_paClosedItems->menu(), SIGNAL(aboutToShow()), this, SLOT(slotClosedItemsListAboutToShow()) );
connect( m_closedItemsGroup, SIGNAL(triggered(QAction*)), m_undoManager, SLOT(slotClosedItemsActivated(QAction*)) );
connect( m_pViewManager, SIGNAL(aboutToRemoveTab(KonqFrameBase*)), this, SLOT(slotAddClosedUrl(KonqFrameBase*)) );
connect( m_undoManager, SIGNAL(openClosedTab(KonqClosedTabItem)), m_pViewManager, SLOT(openClosedTab(KonqClosedTabItem)) );
connect( m_undoManager, SIGNAL(closedTabsListChanged()), this, SLOT(updateClosedTabsAction()));
connect( m_undoManager, SIGNAL(openClosedTab(const KonqClosedTabItem&)), m_pViewManager, SLOT(openClosedTab(const KonqClosedTabItem&)) );
connect( m_undoManager, SIGNAL(openClosedWindow(const KonqClosedWindowItem&)), m_pViewManager, SLOT(openClosedWindow(const KonqClosedWindowItem&)) );
connect( m_undoManager, SIGNAL(closedItemsListChanged()), this, SLOT(updateClosedItemsAction()));
m_paBack = new KToolBarPopupAction( KIcon(backForward.first.iconName()), backForward.first.text(), this );
actionCollection()->addAction( "go_back", m_paBack );
......@@ -3803,8 +3818,8 @@ void KonqMainWindow::initActions()
m_paForward->setToolTip( i18n( "Move forward one step in the browsing history" ) );
m_paClosedTabs->setWhatsThis( i18n( "Move backwards one step in the closed tabs history" ) );
m_paClosedTabs->setToolTip( i18n( "Move backwards one step in the closed tabs history" ) );
m_paClosedItems->setWhatsThis( i18n( "Move backwards one step in the closed tabs history" ) );
m_paClosedItems->setToolTip( i18n( "Move backwards one step in the closed tabs history" ) );
m_paHome->setWhatsThis( i18n( "<html>Navigate to your 'Home Location'<br /><br />"
......@@ -4217,7 +4232,7 @@ void KonqMainWindow::enableAllActions( bool enable )
currentProfileChanged();
updateViewActions(); // undo, lock, link and other view-dependent actions
updateClosedTabsAction();
updateClosedItemsAction();
m_paStop->setEnabled( m_currentView && m_currentView->isLoading() );
......@@ -4457,7 +4472,7 @@ void KonqMainWindow::slotPopupMenu( const QPoint &global, const KFileItemList &i
popupMenuCollection.addAction( "go_forward", m_paForward );
popupMenuCollection.addAction( "go_up", m_paUp );
popupMenuCollection.addAction( "reload", m_paReload );
popupMenuCollection.addAction( "closedtabs", m_paClosedTabs );
popupMenuCollection.addAction( "closedtabs", m_paClosedItems );
#if 0
popupMenuCollection.addAction( "find", m_paFindFiles );
......@@ -4970,6 +4985,10 @@ void KonqMainWindow::closeEvent( QCloseEvent *e )
// save size to have something to restore if the profile does not contain size
saveWindowSize();
// Save the window tabs so that we can restore it later, but only if there
// are other windows opened
if(s_konqMainWindowInstancesCount > 1)
addClosedWindowToUndoList();
hide();
qApp->flush();
......@@ -4990,6 +5009,52 @@ void KonqMainWindow::closeEvent( QCloseEvent *e )
kDebug(1202) << "KonqMainWindow::closeEvent end";
}
void KonqMainWindow::addClosedWindowToUndoList()
{
kDebug(1202);
// 1. We get the current tab, and the title (which might end up being its url)
KonqFrameTabs* tabContainer = m_pViewManager->tabContainer();
QString title( i18n("no name") ), url("about:blank");
KonqFrameBase* tab = dynamic_cast<KonqFrameBase*>(m_pViewManager->tabContainer()->currentWidget());
// Did the tab contain a single frame, or a splitter?
KonqFrame* frame = dynamic_cast<KonqFrame *>(tab);
if (!frame) {
KonqFrameContainer* frameContainer = dynamic_cast<KonqFrameContainer *>(tab);
if (frameContainer->activeChildView())
frame = frameContainer->activeChildView()->frame();
}
KParts::ReadOnlyPart* part = frame ? frame->part() : 0;
if (part)
url = part->url().url();
if (frame)
title = frame->title().trimmed();
if (title.isEmpty())
title = url;
title = KStringHandler::csqueeze( title, 50 );
kDebug(1202) << "1";
// 2. Create the KonqClosedWindowItem and save its config
KonqClosedWindowItem* closedWindowItem = new KonqClosedWindowItem(title, m_undoManager->newCommandSerialNumber());
KonqFrameBase::Options flags = KonqFrameBase::saveHistoryItems;
QString prefix = QString::fromLatin1( childFrame()->frameType() ) + QString::number(0);
closedWindowItem->configGroup().writeEntry( "RootItem", prefix );
prefix.append( QLatin1Char( '_' ) );
closedWindowItem->configGroup().writeEntry( "Width", width() );
closedWindowItem->configGroup().writeEntry( "Height", height() );
closedWindowItem->configGroup().writeEntry( "FullScreen", fullScreenMode() );
tabContainer->saveConfig( closedWindowItem->configGroup(), prefix, flags, 0L, 0, 1);
kDebug(1202) << "2";
// 3. Finally add the KonqClosedWindowItem to the undo list
m_paClosedItems->setEnabled(true);
m_undoManager->addWindowInOtherInstances( closedWindowItem );
kDebug(1202) << "done";
}
bool KonqMainWindow::queryExit()
{
if( kapp && kapp->sessionSaving()) // *sigh*
......@@ -5063,7 +5128,7 @@ void KonqMainWindow::slotAddClosedUrl(KonqFrameBase *tab)
KonqFrameBase::Options flags = KonqFrameBase::saveHistoryItems;
tab->saveConfig( closedTabItem->configGroup(), prefix, flags, 0L, 0, 1);
m_paClosedTabs->setEnabled(true);
m_paClosedItems->setEnabled(true);
m_undoManager->addClosedTabItem( closedTabItem );
kDebug(1202) << "done";
......
......@@ -73,7 +73,6 @@ class KConfigGroup;
class KUrlRequester;
class KBookmarkManager;
struct HistoryEntry;
class KonqClosedTabItem;
namespace KParts {
class BrowserExtension;
......@@ -456,8 +455,8 @@ private Q_SLOTS:
void slotBackAboutToShow();
void slotForwardAboutToShow();
void slotClosedTabsListAboutToShow();
void updateClosedTabsAction();
void slotClosedItemsListAboutToShow();
void updateClosedItemsAction();
void slotUpActivated( int id );
void slotBackActivated( int id );
......@@ -572,7 +571,7 @@ private:
void initActions();
void popupNewTab(bool infront, bool openAfterCurrentPage);
void addClosedWindowToUndoList();
/**
* Tries to find a index.html (.kde.html) file in the specified directory
*/
......@@ -586,6 +585,12 @@ private:
bool stayPreloaded();
bool checkPreloadResourceUsage();
/**
* Manage how many instances of this class are out there.
*/
void incInstancesCount();
void decInstancesCount();
QObject* lastFrame( KonqView *view );
......@@ -601,7 +606,8 @@ private: // members
KToolBarPopupAction *m_paUp;
KToolBarPopupAction *m_paBack;
KToolBarPopupAction *m_paForward;
KToolBarPopupAction *m_paClosedTabs; /// Action for the trash that contains closed tabs
/// Action for the trash that contains closed tabs/windows
KToolBarPopupAction *m_paClosedItems;
KAction *m_paHome;
KonqBidiHistoryAction *m_paHistory;
......@@ -703,7 +709,7 @@ private: // members
QList<QAction *> m_openWithActions;
KActionMenu *m_viewModeMenu;
QActionGroup* m_viewModesGroup;
QActionGroup* m_closedTabsGroup;
QActionGroup* m_closedItemsGroup;
static QList<KonqMainWindow*> *s_lstViews;
......
......@@ -26,20 +26,55 @@
#include <kdebug.h>
#include <klocale.h>
static unsigned long s_konqUndoManagerRefCnt = 0;
KonqUndoManager::KonqUndoManager(QObject* parent)
: QObject(parent)
{
KonqFileUndoManager::incRef();
incRef();
connect( KonqFileUndoManager::self(), SIGNAL(undoAvailable(bool)),
this, SLOT(slotFileUndoAvailable(bool)) );
connect( KonqFileUndoManager::self(), SIGNAL(undoTextChanged(QString)),
this, SLOT(slotFileUndoTextChanged(QString)) );
connect(KonqFileUndoManager::self(), SIGNAL(bypassCustomInfo(QVariant &)),
this, SLOT( slotBypassCustomInfo(QVariant &) ) );
connect(this, SIGNAL( bypassCustomInfo( QVariant &) ),
KonqFileUndoManager::self(), SIGNAL( bypassCustomInfo( QVariant &) ) );
}
KonqUndoManager::~KonqUndoManager()
{
clearClosedTabsList();
disconnect( KonqFileUndoManager::self(), SIGNAL(undoAvailable(bool)),
this, SLOT(slotFileUndoAvailable(bool)) );
disconnect( KonqFileUndoManager::self(), SIGNAL(undoTextChanged(QString)),
this, SLOT(slotFileUndoTextChanged(QString)) );
disconnect(KonqFileUndoManager::self(), SIGNAL(bypassCustomInfo(QVariant &)),
this, SLOT( slotBypassCustomInfo(QVariant &) ) );
disconnect(this, SIGNAL( bypassCustomInfo( QVariant &) ),
KonqFileUndoManager::self(), SIGNAL( bypassCustomInfo( QVariant &) ) );
decRef();
// Important! do decRef() before doing clearClosedItemsList() here:
clearClosedItemsList();
}
void KonqUndoManager::incRef()
{
kDebug();
KonqFileUndoManager::incRef();
s_konqUndoManagerRefCnt++;
kDebug() << s_konqUndoManagerRefCnt;
}
void KonqUndoManager::decRef()
{
kDebug();
KonqFileUndoManager::decRef();
s_konqUndoManagerRefCnt--;
}
void KonqUndoManager::slotFileUndoAvailable(bool)
......@@ -49,7 +84,7 @@ void KonqUndoManager::slotFileUndoAvailable(bool)
bool KonqUndoManager::undoAvailable() const
{
if (!m_closedTabsList.isEmpty())
if (!m_closedItemList.isEmpty())
return true;
else
return (m_supportsFileUndo && KonqFileUndoManager::self()->undoAvailable());
......@@ -57,10 +92,15 @@ bool KonqUndoManager::undoAvailable() const
QString KonqUndoManager::undoText() const
{
if (!m_closedTabsList.isEmpty()) {
const KonqClosedTabItem* closedTabItem = m_closedTabsList.first();
if (closedTabItem->serialNumber() > KonqFileUndoManager::self()->currentCommandSerialNumber()) {
return i18n("Und&o: Closed Tab");
if (!m_closedItemList.isEmpty()) {
const KonqClosedItem* closedItem = m_closedItemList.first();
if (closedItem->serialNumber() > KonqFileUndoManager::self()->currentCommandSerialNumber()) {
const KonqClosedTabItem* closedTabItem =
dynamic_cast<const KonqClosedTabItem *>(closedItem);
if(closedTabItem)
return i18n("Und&o: Closed Tab");
else
return i18n("Und&o: Closed Window");
}
}
return KonqFileUndoManager::self()->undoText();
......@@ -68,19 +108,28 @@ QString KonqUndoManager::undoText() const
void KonqUndoManager::undo()
{
if (!m_closedTabsList.isEmpty()) {
const KonqClosedTabItem* closedTabItem = m_closedTabsList.first();
if (!m_closedItemList.isEmpty()) {
const KonqClosedItem* closedItem = m_closedItemList.first();
// Check what to undo
kDebug() << "closedTabItem->serialNumber:" << closedTabItem->serialNumber()
kDebug() << "closedTabItem->serialNumber:" << closedItem->serialNumber()
<< ", KonqFileUndoManager currentCommandSerialNumber(): " << KonqFileUndoManager::self()->currentCommandSerialNumber();
if (closedTabItem->serialNumber() > KonqFileUndoManager::self()->currentCommandSerialNumber()) {
m_closedTabsList.removeFirst();
emit openClosedTab(*closedTabItem);
delete closedTabItem;
if (closedItem->serialNumber() > KonqFileUndoManager::self()->currentCommandSerialNumber()) {
m_closedItemList.removeFirst();
const KonqClosedTabItem* closedTabItem =
dynamic_cast<const KonqClosedTabItem *>(closedItem);
const KonqClosedWindowItem* closedWindowItem =
dynamic_cast<const KonqClosedWindowItem *>(closedItem);
if(closedTabItem)
emit openClosedTab(*closedTabItem);
else if(closedWindowItem) {
emit openClosedWindow(*closedWindowItem);
removeWindowInOtherInstances(closedWindowItem);
}
delete closedItem;
emit undoAvailable(this->undoAvailable());
emit closedTabsListChanged();
emit closedItemsListChanged();
} else {
KonqFileUndoManager::self()->undo();
}
......@@ -89,28 +138,93 @@ void KonqUndoManager::undo()
}
}
const QList<KonqClosedTabItem *>& KonqUndoManager::closedTabsList() const
void KonqUndoManager::removeWindowInOtherInstances(const KonqClosedWindowItem
*closedWindowItem)
{
QList<QVariant> items;
QString order("remove");
const QObject *myClosedWindowItem =
reinterpret_cast<const QObject *>(closedWindowItem);
items.append(qVariantFromValue(reinterpret_cast<QObject *>(this)));
items.append(qVariantFromValue(order));
items.append(qVariantFromValue(const_cast<QObject *>(myClosedWindowItem)));
QVariant myData(items);
emit bypassCustomInfo(myData);
}
void KonqUndoManager::addWindowInOtherInstances(const KonqClosedWindowItem
*closedWindowItem)
{
QList<QVariant> items;
QString order("add");
const QObject *myClosedWindowItem =
reinterpret_cast<const QObject *>(closedWindowItem);
items.append(qVariantFromValue(reinterpret_cast<QObject *>(this)));
items.append(qVariantFromValue(order));
items.append(qVariantFromValue(const_cast<QObject *>(myClosedWindowItem)));
QVariant myData(items);
emit bypassCustomInfo(myData);
}
void KonqUndoManager::slotBypassCustomInfo(QVariant &customData)
{
QList<QVariant> items = customData.toList();
KonqUndoManager *undoManager =
static_cast<KonqUndoManager *>(items.first().value<QObject*>());
QString order = items.at(1).toString();
KonqClosedWindowItem *closedWindowItem =
static_cast<KonqClosedWindowItem *>(items.at(2).value<QObject*>());
if(undoManager != this)
{
if(order == "remove")
{
QList<KonqClosedItem *>::iterator it = qFind(m_closedItemList.begin(), m_closedItemList.end(), closedWindowItem);
// If the item was found, remove it from the list
if(it != m_closedItemList.end()) {
m_closedItemList.erase(it);
emit undoAvailable(this->undoAvailable());
emit closedItemsListChanged();
}
} else if (order == "add")
{
addClosedWindowItem(closedWindowItem);
}
}
}
const QList<KonqClosedItem *>& KonqUndoManager::closedTabsList() const
{
return m_closedTabsList;
return m_closedItemList;
}
void KonqUndoManager::undoClosedTab(int index)
void KonqUndoManager::undoClosedItem(int index)
{
Q_ASSERT(!m_closedTabsList.isEmpty());
KonqClosedTabItem* closedTabItem = m_closedTabsList.at( index );
m_closedTabsList.removeAt(index);
emit openClosedTab(*closedTabItem);
Q_ASSERT(!m_closedItemList.isEmpty());
KonqClosedItem* closedItem = m_closedItemList.at( index );
m_closedItemList.removeAt(index);
const KonqClosedTabItem* closedTabItem =
dynamic_cast<const KonqClosedTabItem *>(closedItem);
const KonqClosedWindowItem* closedWindowItem =
dynamic_cast<const KonqClosedWindowItem *>(closedItem);
if(closedTabItem)