Implemented an icon cache to speed-up workspace refresh
FossilOrigin-Name: 964b28f34fae482959ce8a96cbc6106f8702fb33
This commit is contained in:
parent
07ec39ec5f
commit
44ea8fe52b
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fixed\sformatting\sin\sbuilding\sinstructions
|
||||
D 2015-04-25T15:10:40.587
|
||||
C Implemented\san\sicon\scache\sto\sspeed-up\sworkspace\srefresh\n
|
||||
D 2015-05-03T19:14:10.535
|
||||
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
|
||||
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
|
||||
F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b
|
||||
@ -198,8 +198,8 @@ F src/FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2
|
||||
F src/FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df
|
||||
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
|
||||
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
|
||||
F src/MainWindow.cpp f023407f57730b695d4eeff8f27eef569c9eec66
|
||||
F src/MainWindow.h dc0a9ed7de8a338e56c38c00ec303796f31bd24d
|
||||
F src/MainWindow.cpp 6758e29796f411f920a0a59ece5002e4aeefd9f2
|
||||
F src/MainWindow.h 77038e9c9fe8a64a1c2dfb8d4c2be7558ab5f372
|
||||
F src/SettingsDialog.cpp a46cff5e5dd425e3dbdd15632abfd5829f5562b4
|
||||
F src/SettingsDialog.h 4e2790f581e991c744ae9f86580f1972b8c7ff43
|
||||
F src/Utils.cpp 9aff456712e4276b49083426301b3b96d3819c77
|
||||
@ -213,7 +213,7 @@ F ui/CommitDialog.ui 6200f6cabdcf40a20812e811be28e0793f82516f
|
||||
F ui/FileActionDialog.ui 89bb4dc2d0b8adcd41adcb11ec65f2028a09a12d
|
||||
F ui/MainWindow.ui 8677f5c8bca5bf7561d5f64bfdd0cef5157c6ac7
|
||||
F ui/SettingsDialog.ui 2b7c2870e0054b0f4106f495d85d02c0b814df8b
|
||||
P 9314ddc02dd302435a4aea987f16cb847a1076b6
|
||||
R 7cb8f99d09af03a8c7fc0a6cb6e77784
|
||||
P 6b51d631f61ea685cf4ce84b3c34954dcd6338e2
|
||||
R 4dbdcef2e6b8d98135af80d15f437e02
|
||||
U kostas
|
||||
Z e7407fd42cdfa4ddd4dc6e2cd76018f5
|
||||
Z ccf17d40f1e416c2bd9554afa0bd3798
|
||||
|
@ -1 +1 @@
|
||||
6b51d631f61ea685cf4ce84b3c34954dcd6338e2
|
||||
964b28f34fae482959ce8a96cbc6106f8702fb33
|
@ -6,7 +6,6 @@
|
||||
#include <QDrag>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QFileIconProvider>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
@ -842,7 +841,7 @@ _done:
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void addPathToTree(QStandardItem &root, const QString &path)
|
||||
static void addPathToTree(QStandardItem &root, const QString &path, const QIcon &folderIcon)
|
||||
{
|
||||
QStringList dirs = path.split('/');
|
||||
QStandardItem *parent = &root;
|
||||
@ -868,7 +867,7 @@ static void addPathToTree(QStandardItem &root, const QString &path)
|
||||
|
||||
if(!found) // Generate it
|
||||
{
|
||||
QStandardItem *child = new QStandardItem(QIcon(":icons/icons/Folder-01.png"), dir);
|
||||
QStandardItem *child = new QStandardItem(folderIcon, dir);
|
||||
child->setData(fullpath); // keep the full path to simplify selection
|
||||
parent->appendRow(child);
|
||||
parent = child;
|
||||
@ -887,7 +886,7 @@ void MainWindow::updateDirView()
|
||||
header << tr("Folders");
|
||||
repoDirModel.setHorizontalHeaderLabels(header);
|
||||
|
||||
QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), projectName);
|
||||
QStandardItem *root = new QStandardItem(getInternalIcon(":icons/icons/My Documents-01.png"), projectName);
|
||||
root->setData(""); // Empty Path
|
||||
root->setEditable(false);
|
||||
|
||||
@ -898,7 +897,7 @@ void MainWindow::updateDirView()
|
||||
if(dir.isEmpty())
|
||||
continue;
|
||||
|
||||
addPathToTree(*root, dir);
|
||||
addPathToTree(*root, dir, getInternalIcon(":icons/icons/Folder-01.png"));
|
||||
}
|
||||
ui->treeView->expandToDepth(0);
|
||||
ui->treeView->sortByColumn(0, Qt::AscendingOrder);
|
||||
@ -922,8 +921,6 @@ void MainWindow::updateFileView()
|
||||
{ RepoFile::TYPE_CONFLICTED, tr("Conflicted"), ":icons/icons/Button Blank Red-01.png" },
|
||||
};
|
||||
|
||||
QFileIconProvider icon_provider;
|
||||
|
||||
bool display_path = viewMode==VIEWMODE_LIST || selectedDirs.count() > 1;
|
||||
|
||||
size_t item_id=0;
|
||||
@ -950,20 +947,26 @@ void MainWindow::updateFileView()
|
||||
}
|
||||
}
|
||||
|
||||
QStandardItem *status = new QStandardItem(QIcon(status_icon_path), status_text);
|
||||
QStandardItem *status = new QStandardItem(getInternalIcon(status_icon_path), status_text);
|
||||
status->setToolTip(status_text);
|
||||
repoFileModel.setItem(item_id, COLUMN_STATUS, status);
|
||||
|
||||
QFileInfo finfo = e.getFileInfo();
|
||||
QIcon icon = icon_provider.icon(finfo);
|
||||
QString icon_type = iconProvider.type(finfo);
|
||||
|
||||
|
||||
if(!iconCache.contains(icon_type))
|
||||
iconCache.insert(icon_type, iconProvider.icon(finfo));
|
||||
|
||||
const QIcon *icon = &iconCache[icon_type];
|
||||
|
||||
QStandardItem *filename_item = 0;
|
||||
repoFileModel.setItem(item_id, COLUMN_PATH, new QStandardItem(path));
|
||||
|
||||
if(display_path)
|
||||
filename_item = new QStandardItem(icon, QDir::toNativeSeparators(e.getFilePath()));
|
||||
filename_item = new QStandardItem(*icon, QDir::toNativeSeparators(e.getFilePath()));
|
||||
else
|
||||
filename_item = new QStandardItem(icon, e.getFilename());
|
||||
filename_item = new QStandardItem(*icon, e.getFilename());
|
||||
|
||||
Q_ASSERT(filename_item);
|
||||
// Keep the path in the user data
|
||||
@ -2447,6 +2450,16 @@ QMenu * MainWindow::createPopupMenu()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const QIcon &MainWindow::getInternalIcon(const char* name)
|
||||
{
|
||||
if(iconCache.contains(name))
|
||||
return iconCache[name];
|
||||
|
||||
iconCache.insert(name, QIcon(name));
|
||||
return iconCache[name];
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionViewStash_triggered()
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QFileIconProvider>
|
||||
#include <QSet>
|
||||
#include "SettingsDialog.h"
|
||||
|
||||
@ -170,6 +171,7 @@ private:
|
||||
void dropEvent(class QDropEvent *event);
|
||||
void setBusy(bool busy);
|
||||
virtual QMenu *createPopupMenu();
|
||||
const QIcon& getInternalIcon(const char *name);
|
||||
|
||||
enum RepoStatus
|
||||
{
|
||||
@ -242,8 +244,11 @@ private:
|
||||
MAX_RECENT=5
|
||||
};
|
||||
|
||||
typedef QMap<QString, QIcon> icon_map_t;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QFileIconProvider iconProvider;
|
||||
icon_map_t iconCache;
|
||||
QStandardItemModel repoFileModel;
|
||||
QStandardItemModel repoDirModel;
|
||||
QStandardItemModel repoStashModel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user