Changeset 561 for trunk/src/gui/dialogs/qsidebar.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qsidebar.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 56 56 QT_BEGIN_NAMESPACE 57 57 58 void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option, 59 const QModelIndex &index) const 60 { 61 QStyledItemDelegate::initStyleOption(option,index); 62 QVariant value = index.data(QUrlModel::EnabledRole); 63 if (value.isValid()) { 64 //If the bookmark/entry is not enabled then we paint it in gray 65 if (!qvariant_cast<bool>(value)) 66 option->state &= ~QStyle::State_Enabled; 67 } 68 } 69 58 70 /*! 59 71 QUrlModel lets you have indexes from a QFileSystemModel to a list. When QFileSystemModel … … 87 99 88 100 if (index.data(Qt::DecorationRole).isNull()) 89 flags &= ~Qt::ItemIsEnabled;90 91 if (invalidUrls.contains(index.data(UrlRole).toUrl()))92 101 flags &= ~Qt::ItemIsEnabled; 93 102 … … 194 203 if (!invalidUrls.contains(url)) 195 204 invalidUrls.append(url); 205 //The bookmark is invalid then we set to false the EnabledRole 206 setData(index, false, EnabledRole); 207 } else { 208 //The bookmark is valid then we set to true the EnabledRole 209 setData(index, true, EnabledRole); 196 210 } 197 211 … … 234 248 if (!url.isValid() || url.scheme() != QLatin1String("file")) 235 249 continue; 250 //this makes sure the url is clean 251 const QString cleanUrl = QDir::cleanPath(url.toLocalFile()); 252 url = QUrl::fromLocalFile(cleanUrl); 253 236 254 for (int j = 0; move && j < rowCount(); ++j) { 237 if (index(j, 0).data(UrlRole) == url) { 255 QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile(); 256 #if defined(Q_OS_WIN) 257 if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == cleanUrl.toLower()) { 258 #else 259 if (index(j, 0).data(UrlRole).toUrl().toLocalFile() == cleanUrl) { 260 #endif 238 261 removeRow(j); 239 262 if (j <= row) … … 243 266 } 244 267 row = qMax(row, 0); 245 QModelIndex idx = fileSystemModel->index( url.toLocalFile());268 QModelIndex idx = fileSystemModel->index(cleanUrl); 246 269 if (!fileSystemModel->isDir(idx)) 247 270 continue; 248 271 insertRows(row, 1); 249 272 setUrl(index(row, 0), url, idx); 250 watching.append( QPair<QModelIndex, QString>(idx, url.toLocalFile()));273 watching.append(qMakePair(idx, cleanUrl)); 251 274 } 252 275 } … … 271 294 return; 272 295 if (fileSystemModel != 0) { 273 disconnect(model, SIGNAL(dataChanged( const QModelIndex &, const QModelIndex &)),274 this, SLOT(dataChanged( const QModelIndex &, const QModelIndex &)));296 disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 297 this, SLOT(dataChanged(QModelIndex,QModelIndex))); 275 298 disconnect(model, SIGNAL(layoutChanged()), 276 299 this, SLOT(layoutChanged())); 277 disconnect(model, SIGNAL(rowsRemoved( const QModelIndex &, int,int)),300 disconnect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 278 301 this, SLOT(layoutChanged())); 279 302 } 280 303 fileSystemModel = model; 281 304 if (fileSystemModel != 0) { 282 connect(model, SIGNAL(dataChanged( const QModelIndex &, const QModelIndex &)),283 this, SLOT(dataChanged( const QModelIndex &, const QModelIndex &)));305 connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 306 this, SLOT(dataChanged(QModelIndex,QModelIndex))); 284 307 connect(model, SIGNAL(layoutChanged()), 285 308 this, SLOT(layoutChanged())); 286 connect(model, SIGNAL(rowsRemoved( const QModelIndex &, int,int)),309 connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), 287 310 this, SLOT(layoutChanged())); 288 311 } … … 357 380 urlModel->setFileSystemModel(model); 358 381 setModel(urlModel); 359 360 connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), 361 this, SLOT(clicked(const QModelIndex &))); 382 setItemDelegate(new QSideBarDelegate(this)); 383 384 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 385 this, SLOT(clicked(QModelIndex))); 362 386 #ifndef QT_NO_DRAGANDDROP 363 387 setDragDropMode(QAbstractItemView::DragDrop); 364 388 #endif 365 389 setContextMenuPolicy(Qt::CustomContextMenu); 366 connect(this, SIGNAL(customContextMenuRequested( const QPoint &)),367 this, SLOT(showContextMenu( const QPoint &)));390 connect(this, SIGNAL(customContextMenuRequested(QPoint)), 391 this, SLOT(showContextMenu(QPoint))); 368 392 urlModel->setUrls(newUrls); 369 393 setCurrentIndex(this->model()->index(0,0)); … … 391 415 void QSidebar::selectUrl(const QUrl &url) 392 416 { 393 disconnect(selectionModel(), SIGNAL(currentChanged( const QModelIndex &, const QModelIndex &)),394 this, SLOT(clicked( const QModelIndex &)));417 disconnect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 418 this, SLOT(clicked(QModelIndex))); 395 419 396 420 selectionModel()->clear(); … … 402 426 } 403 427 404 connect(selectionModel(), SIGNAL(currentChanged( const QModelIndex &, const QModelIndex &)),405 this, SLOT(clicked( const QModelIndex &)));428 connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), 429 this, SLOT(clicked(QModelIndex))); 406 430 } 407 431
Note:
See TracChangeset
for help on using the changeset viewer.