Commit 112d9685 authored by Tony Murray's avatar Tony Murray

Some cleanups based on Urs' suggestions.

Tooltip for the favorite column in the new connection view to indicate that you can click it.
Changed to autosize columns for the new connection view (disables user resize).
bookmarkmanager: no more recursive helper function

svn path=/trunk/KDE/kdenetwork/krdc/; revision=1079830
parent efff3da3
......@@ -155,30 +155,26 @@ KBookmarkManager* BookmarkManager::getManager()
return m_manager;
}
QStringList BookmarkManager::findBookmarkAddresses(KBookmarkManager *manager, const QString &url)
const QStringList BookmarkManager::findBookmarkAddresses(const KBookmarkGroup &group, const QString &url)
{
QStringList bookmarkAddresses = QStringList();
findBookmarkAddressesRecursive(&bookmarkAddresses, manager->root(), url);
return bookmarkAddresses;
}
void BookmarkManager::findBookmarkAddressesRecursive(QStringList *bookmarkAddresses, const KBookmarkGroup &group, const QString &url)
{
KBookmark bm = group.first();
while (!bm.isNull()) {
if (bm.isGroup())
findBookmarkAddressesRecursive(bookmarkAddresses, bm.toGroup(), url);
if (bm.isGroup()) {
bookmarkAddresses.append(findBookmarkAddresses(bm.toGroup(), url));
}
if (bm.url() == url) {
bookmarkAddresses->append(bm.address());
bookmarkAddresses.append(bm.address());
}
bm = group.next(bm);
}
return bookmarkAddresses;
}
void BookmarkManager::removeByUrl(KBookmarkManager *manager, const QString &url, bool ignoreHistory, const QString updateTitle)
{
QStringList bookmarkAddresses = findBookmarkAddresses(manager, url);
const QStringList bookmarkAddresses = findBookmarkAddresses(manager->root(), url);
foreach(QString address, bookmarkAddresses) {
KBookmark bm = manager->findByAddress(address);
if (ignoreHistory && bm.parentGroup().metaDataItem("krdc-history") == "historyfolder") {
......@@ -199,7 +195,7 @@ void BookmarkManager::removeByUrl(KBookmarkManager *manager, const QString &url,
void BookmarkManager::updateTitle(KBookmarkManager *manager, const QString &url, const QString &title)
{
QStringList bookmarkAddresses = findBookmarkAddresses(manager, url);
const QStringList bookmarkAddresses = findBookmarkAddresses(manager->root(), url);
foreach(QString address, bookmarkAddresses) {
KBookmark bm = manager->findByAddress(address);
bm.setFullText(title);
......
......@@ -52,7 +52,7 @@ public:
static void removeByUrl(KBookmarkManager *manager, const QString &url, bool ignoreHistory = false, const QString updateTitle = QString());
static void updateTitle(KBookmarkManager *manager, const QString &url, const QString &title);
// returns a QStringList for all bookmarks that point to this url using KBookmark::address()
static QStringList findBookmarkAddresses(KBookmarkManager *manager, const QString &url);
static const QStringList findBookmarkAddresses(const KBookmarkGroup &group, const QString &url);
signals:
void openUrl(const KUrl &url);
......@@ -67,7 +67,6 @@ private:
KBookmarkGroup m_historyGroup;
MainWindow *m_mainWindow;
static void findBookmarkAddressesRecursive(QStringList *bookmarkAddresses, const KBookmarkGroup &group, const QString &url);
};
#endif
......@@ -1080,14 +1080,18 @@ QWidget* MainWindow::newConnectionWidget()
m_newConnectionTableView = new QTableView(remoteDesktopsGroupWidget);
m_newConnectionTableView->setModel(m_remoteDesktopsModelProxy);
// set up the view so it looks nice
m_newConnectionTableView->setItemDelegate(new ConnectionDelegate(m_newConnectionTableView));
m_newConnectionTableView->setShowGrid(false);
m_newConnectionTableView->verticalHeader()->hide();
m_newConnectionTableView->verticalHeader()->setDefaultSectionSize(
m_newConnectionTableView->fontMetrics().height() + 3);
m_newConnectionTableView->horizontalHeader()->setStretchLastSection(true);
m_newConnectionTableView->resizeColumnsToContents();
// m_newConnectionTableView->resizeColumnsToContents(); // not needed when resize mode is ResizeToContents
m_newConnectionTableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
m_newConnectionTableView->setAlternatingRowColors(true);
// set up sorting and actions (double click open, right click custom menu)
m_newConnectionTableView->setSortingEnabled(true);
m_newConnectionTableView->sortByColumn(Settings::connectionListSortColumn(), Qt::SortOrder(Settings::connectionListSortOrder()));
connect(m_newConnectionTableView->horizontalHeader(), SIGNAL(sortIndicatorChanged(const int, const Qt::SortOrder)),
......@@ -1097,6 +1101,7 @@ QWidget* MainWindow::newConnectionWidget()
m_newConnectionTableView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_newConnectionTableView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showConnectionContextMenu(QPoint)));
// set up the filter input field
QLabel *filterLabel = new QLabel(i18nc("Verb, to remove items that don't match", "Filter"), remoteDesktopsGroupWidget);
KLineEdit *filterLineEdit = new KLineEdit(remoteDesktopsGroupWidget);
filterLineEdit->setClickMessage(i18n("Type here to filter the connection list."));
......
......@@ -122,18 +122,34 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
default:
return QVariant();
}
case Qt::CheckStateRole:
if (index.column() == RemoteDesktopsModel::Favorite)
return item.favorite ? Qt::Checked : Qt::Unchecked;
return QVariant();
case Qt::ToolTipRole:
if (index.column() == RemoteDesktopsModel::LastConnected && !item.lastConnected.isNull())
return KGlobal::locale()->formatDateTime(item.lastConnected.toLocalZone(), KLocale::FancyLongDate);
return item.url; //use the url for the tooltip
switch(index.column()) {
case RemoteDesktopsModel::Favorite:
if (item.favorite) {
return i18nc("Remove the selected url from the bookarks menu", "Remove the bookmark for %1.", item.title);
} else {
return i18nc("Add the selected url to the bookmarks menu", "Bookmark %1.", item.title);
}
case RemoteDesktopsModel::LastConnected:
if (!item.lastConnected.isNull()) {
return KGlobal::locale()->formatDateTime(item.lastConnected.toLocalZone(), KLocale::FancyLongDate);
} // else fall through to default
default:
return item.url; //use the url for the tooltip
}
case 10001: //url for dockwidget
return item.url;
case 10002: //filter
return item.url + item.title; // return both uservisible and data
default:
return QVariant();
}
......
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