Commit 806e1687 authored by Tony Murray's avatar Tony Murray

Bookmark Title cleanup

* don't shorten titles with ..., use fullText()
* do not use percent encoded urls in bookmark titles
* convert filterable items to non-percent encoded characters (allows us to filter as typed without any tricks)

svn path=/trunk/KDE/kdenetwork/krdc/; revision=1208291
parent a0f04de8
......@@ -121,7 +121,7 @@ QString BookmarkManager::currentUrl() const
QString BookmarkManager::currentTitle() const
{
return currentUrl();
return QUrl::fromPercentEncoding(currentUrl().toUtf8());
}
bool BookmarkManager::supportsTabs() const
......
......@@ -75,8 +75,6 @@
#include <QToolBar>
#include <QVBoxLayout>
static const QByteArray FILTER_EXCLUSIONS = "@/:";
MainWindow::MainWindow(QWidget *parent)
: KXmlGuiWindow(parent),
m_fullscreenWindow(0),
......@@ -1107,7 +1105,7 @@ QWidget* MainWindow::newConnectionWidget()
m_addressInput = new KLineEdit(m_newConnectionWidget);
m_addressInput->setClearButtonShown(true);
m_addressInput->setClickMessage(i18n("Type here to connect to an address and filter the list."));
connect(m_addressInput, SIGNAL(textChanged(const QString &)), SLOT(updateFilter(const QString &)));
connect(m_addressInput, SIGNAL(textChanged(const QString &)), m_remoteDesktopsModelProxy, SLOT(setFilterFixedString(const QString &)));
foreach(RemoteViewFactory *factory, m_remoteViewFactories) {
m_protocolInput->addItem(factory->scheme());
......@@ -1194,12 +1192,6 @@ int MainWindow::currentRemoteView() const
return m_currentRemoteView;
}
void MainWindow::updateFilter(const QString &text)
{
// use QUrl::toPercentEncoding() to match KUrl::prettyUrl()
m_remoteDesktopsModelProxy->setFilterRegExp(QRegExp("IGNORE|" + QUrl::toPercentEncoding(text, FILTER_EXCLUSIONS), Qt::CaseInsensitive, QRegExp::RegExp));
}
void MainWindow::createDockWidget()
{
QDockWidget *remoteDesktopsDockWidget = new QDockWidget(this);
......@@ -1216,6 +1208,7 @@ void MainWindow::createDockWidget()
RemoteDesktopsModel *remoteDesktopsModel = new RemoteDesktopsModel(this);
m_remoteDesktopsModelProxy = new QSortFilterProxyModel(this);
m_remoteDesktopsModelProxy->setSourceModel(remoteDesktopsModel);
m_remoteDesktopsModelProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_remoteDesktopsModelProxy->setFilterRole(10002);
m_dockWidgetTableView->setModel(m_remoteDesktopsModelProxy);
......@@ -1238,7 +1231,7 @@ void MainWindow::createDockWidget()
KLineEdit *filterLineEdit = new KLineEdit(remoteDesktopsDockLayoutWidget);
filterLineEdit->setClickMessage(i18n("Filter"));
filterLineEdit->setClearButtonShown(true);
connect(filterLineEdit, SIGNAL(textChanged(const QString &)), SLOT(updateFilter(const QString &)));
connect(filterLineEdit, SIGNAL(textChanged(const QString &)), m_remoteDesktopsModelProxy, SLOT(setFilterFixedString(const QString &)));
remoteDesktopsDockLayout->addWidget(filterLineEdit);
remoteDesktopsDockLayout->addWidget(m_dockWidgetTableView);
remoteDesktopsDockWidget->setWidget(remoteDesktopsDockLayoutWidget);
......
......@@ -104,7 +104,6 @@ private slots:
QWidget* newConnectionWidget();
void newConnectionPage();
void openFromRemoteDesktopsModel(const QModelIndex &index);
void updateFilter(const QString &text);
void createDockWidget();
void showConnectionContextMenu(const QPoint &pos);
void saveConnectionListSort(const int logicalindex, const Qt::SortOrder order);
......
......@@ -160,7 +160,7 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
return item.url;
case 10002: //filter
return item.url + item.title; // return both uservisible and data
return QUrl::fromPercentEncoding((item.url + item.title).toUtf8()); // return both user visible title and url data, percent encoded
case 10003: //title for dockwidget
return item.title;
......@@ -223,7 +223,7 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
} else { // not a group
RemoteDesktop item;
item.title = bm.text();
item.title = bm.fullText();
item.url = bm.url().url();
int index = remoteDesktops.indexOf(item); //search for this url to see if we need to update it
bool newItem = index < 0; // do we need to create a new item?
......@@ -259,7 +259,7 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
item.source = RemoteDesktop::Bookmarks;
} else {
// otherwise override these fields with the info from the bookmark
remoteDesktops[index].title = bm.text();
remoteDesktops[index].title = bm.fullText();
remoteDesktops[index].favorite = true;
remoteDesktops[index].source = RemoteDesktop::Bookmarks;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment