mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Merge remote-tracking branch 'origin/KDE/4.11'
The most recent commit from the KDE/4.11 branch (new unit test) had to be modified slightly due to the changed signal emission when resorting the model changes only the groups, and not the order of the items (groupsChaged instead of itemsMoved).
This commit is contained in:
commit
62a8a987ad
4 changed files with 80 additions and 0 deletions
|
@ -98,6 +98,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
|||
|
||||
m_searchBox = new DolphinSearchBox(this);
|
||||
m_searchBox->hide();
|
||||
connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
|
||||
connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
|
||||
connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
|
||||
connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
|
||||
|
@ -195,6 +196,7 @@ KUrl DolphinViewContainer::url() const
|
|||
|
||||
void DolphinViewContainer::setActive(bool active)
|
||||
{
|
||||
m_searchBox->setActive(active);
|
||||
m_urlNavigator->setActive(active);
|
||||
m_view->setActive(active);
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
|
|||
QWidget(parent),
|
||||
m_startedSearching(false),
|
||||
m_readOnly(false),
|
||||
m_active(true),
|
||||
m_topLayout(0),
|
||||
m_searchLabel(0),
|
||||
m_searchInput(0),
|
||||
|
@ -171,6 +172,22 @@ bool DolphinSearchBox::isReadOnly() const
|
|||
return m_readOnly;
|
||||
}
|
||||
|
||||
void DolphinSearchBox::setActive(bool active)
|
||||
{
|
||||
if (active != m_active) {
|
||||
m_active = active;
|
||||
|
||||
if (active) {
|
||||
emit activated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DolphinSearchBox::isActive() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
bool DolphinSearchBox::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Polish) {
|
||||
|
@ -199,6 +216,21 @@ void DolphinSearchBox::keyReleaseEvent(QKeyEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
bool DolphinSearchBox::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::FocusIn:
|
||||
setActive(true);
|
||||
setFocus();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void DolphinSearchBox::emitSearchRequest()
|
||||
{
|
||||
m_startSearchTimer->stop();
|
||||
|
@ -253,6 +285,7 @@ void DolphinSearchBox::slotFacetChanged()
|
|||
|
||||
void DolphinSearchBox::initButton(QToolButton* button)
|
||||
{
|
||||
button->installEventFilter(this);
|
||||
button->setAutoExclusive(true);
|
||||
button->setAutoRaise(true);
|
||||
button->setCheckable(true);
|
||||
|
@ -298,6 +331,7 @@ void DolphinSearchBox::init()
|
|||
|
||||
// Create search box
|
||||
m_searchInput = new KLineEdit(this);
|
||||
m_searchInput->installEventFilter(this);
|
||||
m_searchInput->setClearButtonShown(true);
|
||||
m_searchInput->setFont(KGlobalSettings::generalFont());
|
||||
setFocusProxy(m_searchInput);
|
||||
|
@ -348,6 +382,7 @@ void DolphinSearchBox::init()
|
|||
connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled()));
|
||||
|
||||
m_facetsWidget = new DolphinFacetsWidget(this);
|
||||
m_facetsWidget->installEventFilter(this);
|
||||
m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
connect(m_facetsWidget, SIGNAL(facetChanged()), this, SLOT(slotFacetChanged()));
|
||||
|
||||
|
|
|
@ -87,10 +87,27 @@ public:
|
|||
void setReadOnly(bool readOnly, const KUrl& query = KUrl());
|
||||
bool isReadOnly() const;
|
||||
|
||||
/**
|
||||
* Set the search box to the active mode, if \a active
|
||||
* is true. The active mode is default. The inactive mode only differs
|
||||
* visually from the active mode, no change of the behavior is given.
|
||||
*
|
||||
* Using the search box in the inactive mode is useful when having split views,
|
||||
* where the inactive view is indicated by an search box visually.
|
||||
*/
|
||||
void setActive(bool active);
|
||||
|
||||
/**
|
||||
* @return True, if the search box is in the active mode.
|
||||
* @see DolphinSearchBox::setActive()
|
||||
*/
|
||||
bool isActive() const;
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent* event);
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void keyReleaseEvent(QKeyEvent* event);
|
||||
virtual bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
@ -111,6 +128,13 @@ signals:
|
|||
*/
|
||||
void closeRequest();
|
||||
|
||||
/**
|
||||
* Is emitted, if the searchbox has been activated by
|
||||
* an user interaction
|
||||
* @see DolphinSearchBox::setActive()
|
||||
*/
|
||||
void activated();
|
||||
|
||||
private slots:
|
||||
void emitSearchRequest();
|
||||
void emitCloseRequest();
|
||||
|
@ -137,6 +161,7 @@ private:
|
|||
private:
|
||||
bool m_startedSearching;
|
||||
bool m_readOnly;
|
||||
bool m_active;
|
||||
|
||||
QVBoxLayout* m_topLayout;
|
||||
|
||||
|
|
|
@ -1286,6 +1286,24 @@ void KFileItemModelTest::testNameRoleGroups()
|
|||
expectedGroups << QPair<int, QVariant>(2, QLatin1String("D"));
|
||||
expectedGroups << QPair<int, QVariant>(3, QLatin1String("E"));
|
||||
QCOMPARE(m_model->groups(), expectedGroups);
|
||||
|
||||
// Change d.txt back to c.txt, but this time using the dir lister's refreshItems() signal.
|
||||
const KFileItem fileItemD = m_model->fileItem(2);
|
||||
KFileItem fileItemC = fileItemD;
|
||||
KUrl urlC = fileItemC.url();
|
||||
urlC.setFileName("c.txt");
|
||||
fileItemC.setUrl(urlC);
|
||||
|
||||
m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemC));
|
||||
QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout));
|
||||
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt");
|
||||
|
||||
expectedGroups.clear();
|
||||
expectedGroups << QPair<int, QVariant>(0, QLatin1String("A"));
|
||||
expectedGroups << QPair<int, QVariant>(1, QLatin1String("B"));
|
||||
expectedGroups << QPair<int, QVariant>(2, QLatin1String("C"));
|
||||
expectedGroups << QPair<int, QVariant>(3, QLatin1String("E"));
|
||||
QCOMPARE(m_model->groups(), expectedGroups);
|
||||
}
|
||||
|
||||
QStringList KFileItemModelTest::itemsInModel() const
|
||||
|
|
Loading…
Reference in a new issue