#include <assert.h>
+#include <QApplication>
#include <QDropEvent>
#include <QItemSelectionModel>
#include <QMouseEvent>
int DolphinView::contentsX() const
{
- return 0; //scrollView()->contentsX();
+ return itemView()->horizontalScrollBar()->value();
}
int DolphinView::contentsY() const
{
- return 0; //scrollView()->contentsY();
+ return itemView()->verticalScrollBar()->value();
}
void DolphinView::refreshSettings()
void DolphinView::triggerItem(const QModelIndex& index)
{
+ const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
+ if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
+ // items are selected by the user, hence don't trigger the
+ // item specified by 'index'
+ return;
+ }
+
KFileItem* item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
if (item == 0) {
return;
}
if (item->isDir()) {
- // Prefer the local path over the Url. This assures that the
- // volume space information is correct. Assuming that the Url is media:/sda1,
- // and the local path is /windows/C: For the Url the space info is related
+ // Prefer the local path over the URL. This assures that the
+ // volume space information is correct. Assuming that the URL is media:/sda1,
+ // and the local path is /windows/C: For the URL the space info is related
// to the root partition (and hence wrong) and for the local path the space
// info is related to the windows partition (-> correct).
const QString localPath(item->localPath());
}
updateStatusBar();
+
+ QTimer::singleShot(0, this, SLOT(restoreContentsPos()));
+}
+
+void DolphinView::restoreContentsPos()
+{
+ int index = 0;
+ const QLinkedList<UrlNavigator::HistoryElem> history = urlHistory(index);
+ if (!history.isEmpty()) {
+ QAbstractItemView* view = itemView();
+ // TODO: view->setCurrentItem(history[index].currentFileName());
+
+ QLinkedList<UrlNavigator::HistoryElem>::const_iterator it = history.begin();
+ it += index;
+ view->horizontalScrollBar()->setValue((*it).contentsX());
+ view->verticalScrollBar()->setValue((*it).contentsY());
+ }
}
void DolphinView::showInfoMessage(const QString& msg)
QString DolphinView::defaultStatusBarText() const
{
- // TODO: the following code is not suitable for languages where multiple forms
- // of plurals are given (e. g. in Poland three forms of plurals exist).
const int itemCount = m_folderCount + m_fileCount;
- QString text;
- if (itemCount == 1) {
- text = i18n("1 Item");
- }
- else {
- text = i18n("%1 Items",itemCount);
- }
-
+ QString text = i18np("1 Item", "%n Items", itemCount);
text += " (";
-
- if (m_folderCount == 1) {
- text += i18n("1 Folder");
- }
- else {
- text += i18n("%1 Folders",m_folderCount);
- }
-
+ text += i18np("1 Folder", "%n Folders", m_folderCount);
text += ", ";
-
- if (m_fileCount == 1) {
- text += i18n("1 File");
- }
- else {
- text += i18n("%1 Files",m_fileCount);
- }
-
+ text += i18np("1 File", "%n Files", m_fileCount);
text += ")";
return text;
QString DolphinView::selectionStatusBarText() const
{
- // TODO: the following code is not suitable for languages where multiple forms
- // of plurals are given (e. g. in Poland three forms of plurals exist).
QString text;
const KFileItemList list = selectedItems();
if (list.isEmpty()) {
- // TODO: assert(!list.isEmpty()) should be used, as this method is only invoked if
- // DolphinView::hasSelection() is true. Inconsistent behavior?
+ // when an item is triggered, it is temporary selected but selectedItems()
+ // will return an empty list
return QString();
}
++it;
}
- if (folderCount == 1) {
- text = i18n("1 Folder selected");
- }
- else if (folderCount > 1) {
- text = i18n("%1 Folders selected",folderCount);
- }
-
- if ((fileCount > 0) && (folderCount > 0)) {
- text += ", ";
+ if (folderCount > 0) {
+ text = i18np("1 Folder selected", "%n Folders selected", folderCount);
+ if (fileCount > 0) {
+ text += ", ";
+ }
}
- const QString sizeText(KIO::convertSize(byteSize));
- if (fileCount == 1) {
- text += i18n("1 File selected (%1)",sizeText);
- }
- else if (fileCount > 1) {
- text += i18n("%1 Files selected (%1)",fileCount,sizeText);
+ if (fileCount > 0) {
+ const QString sizeText(KIO::convertSize(byteSize));
+ text += i18np("1 File selected (%1)", "%n Files selected (%1)", fileCount, sizeText);
}
return text;