[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/actions
From: Christoph Pfister <christophpfister () gmail ! com>
Date: 2009-03-15 14:22:36
Message-ID: 1237126956.522836.23739.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 939699 by pfister:
enhance KRecentFilesAction with an action for clearing the recent files list
as discussed on k-c-d
the clear action is only shown if the list isn't empty
- don't delete / reconstruct the special actions, instead use setVisible
- do not put the special actions into selectableActionGroup, as the code assumes that
those actions are recent actions (e.g. for maxItems calculation and in saveEntries)
- fix clear() comment
M +14 -10 krecentfilesaction.cpp
M +4 -1 krecentfilesaction.h
M +6 -2 krecentfilesaction_p.h
--- trunk/KDE/kdelibs/kdeui/actions/krecentfilesaction.cpp #939698:939699
@@ -77,9 +77,12 @@
delete q->menu();
q->setMenu(new KMenu());
q->setToolBarMode(KSelectAction::MenuMode);
- m_noEntriesAction=new QAction(i18n("No entries"),q->selectableActionGroup());
+ m_noEntriesAction = q->menu()->addAction(i18n("No entries"));
m_noEntriesAction->setEnabled(false);
- q->KSelectAction::addAction(m_noEntriesAction);
+ clearSeparator = q->menu()->addSeparator();
+ clearSeparator->setVisible(false);
+ clearAction = q->menu()->addAction(i18n("Clear list"), q, SLOT(clear()));
+ clearAction->setVisible(false);
q->connect(q, SIGNAL(triggered(QAction*)), SLOT(_k_urlSelected(QAction*)));
}
@@ -145,7 +148,9 @@
delete removeAction(selectableActionGroup()->actions().first());
}
- if (d->m_noEntriesAction) removeAction(d->m_noEntriesAction)->deleteLater();
+ d->m_noEntriesAction->setVisible(false);
+ d->clearSeparator->setVisible(true);
+ d->clearAction->setVisible(true);
// add file to list
const QString title = tmpName + " [" + file + ']';
QAction* action = new QAction(title, selectableActionGroup());
@@ -205,10 +210,9 @@
KSelectAction::clear();
d->m_shortNames.clear();
d->m_urls.clear();
- if (d->m_noEntriesAction) \
KSelectAction::removeAction(d->m_noEntriesAction)->deleteLater();
- d->m_noEntriesAction=new QAction(i18n("No entries"),selectableActionGroup());
- d->m_noEntriesAction->setEnabled(false);
- KSelectAction::addAction(d->m_noEntriesAction);
+ d->m_noEntriesAction->setVisible(true);
+ d->clearSeparator->setVisible(false);
+ d->clearAction->setVisible(false);
}
void KRecentFilesAction::loadEntries( const KConfigGroup& _config)
@@ -261,7 +265,9 @@
}
if (thereAreEntries)
{
- if (d->m_noEntriesAction) \
KSelectAction::removeAction(d->m_noEntriesAction)->deleteLater(); + \
d->m_noEntriesAction->setVisible(false); + \
d->clearSeparator->setVisible(true); + d->clearAction->setVisible(true);
}
}
@@ -279,8 +285,6 @@
cg.deleteGroup();
// write file list
- if ( (selectableActionGroup()->actions().count()>1) ||
- ( (selectableActionGroup()->actions().count()==1) && \
(selectableActionGroup()->actions()[0]!=d->m_noEntriesAction) ) )
for ( int i = 1 ; i <= selectableActionGroup()->actions().count() ; i++ )
{
key = QString( "File%1" ).arg( i );
--- trunk/KDE/kdelibs/kdeui/actions/krecentfilesaction.h #939698:939699
@@ -102,11 +102,14 @@
*/
virtual QAction* removeAction(QAction* action);
+public Q_SLOTS:
/**
- * Reimplemented for internal reasons.
+ * Clears the recent files list.
+ * Note that there is also an action shown to the user for clearing the list.
*/
virtual void clear();
+public:
/**
* Returns the maximum of items in the recent files list.
*/
--- trunk/KDE/kdelibs/kdeui/actions/krecentfilesaction_p.h #939698:939699
@@ -38,7 +38,9 @@
KRecentFilesActionPrivate()
{
m_maxItems = 10;
- m_noEntriesAction=0;
+ m_noEntriesAction = 0;
+ clearSeparator = 0;
+ clearAction = 0;
}
virtual ~KRecentFilesActionPrivate()
@@ -52,7 +54,9 @@
int m_maxItems;
QMap<QAction*, QString> m_shortNames;
QMap<QAction*, KUrl> m_urls;
- QPointer<QAction> m_noEntriesAction;
+ QAction *m_noEntriesAction;
+ QAction *clearSeparator;
+ QAction *clearAction;
};
/* vim: et sw=2 ts=2
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic