Added SearchBox
FossilOrigin-Name: 097bed86191fae72e1bf76078b8e9d8da37b2932
This commit is contained in:
parent
adbd44da3a
commit
91163a8502
192
fuel.pro
192
fuel.pro
@ -1,95 +1,97 @@
|
||||
#-------------------------------------------------
|
||||
# Fuel
|
||||
#-------------------------------------------------
|
||||
|
||||
QT = core gui webkit
|
||||
|
||||
contains(QT_VERSION, ^5\\..*) {
|
||||
QT += widgets webkitwidgets
|
||||
QT -= quick multimediawidgets opengl printsupport qml multimedia positioning sensors
|
||||
}
|
||||
|
||||
TARGET = Fuel
|
||||
TEMPLATE = app
|
||||
|
||||
win32 {
|
||||
RC_FILE = rsrc/fuel.rc
|
||||
LIBS += -luser32 -lshell32 -luuid
|
||||
}
|
||||
|
||||
macx {
|
||||
ICON = rsrc/icons/fuel.icns
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
TARGET = fuel
|
||||
ICON = rsrc/icons/fuel.png
|
||||
PREFIX = /usr
|
||||
BINDIR = $$PREFIX/bin
|
||||
DATADIR = $$PREFIX/share
|
||||
target.path = $$BINDIR
|
||||
|
||||
desktop.path = $$DATADIR/applications
|
||||
desktop.files += rsrc/fuel.desktop
|
||||
|
||||
icon.path = $$DATADIR/icons/hicolor/256x256/apps
|
||||
icon.files += rsrc/icons/fuel.png
|
||||
|
||||
INSTALLS += target desktop icon
|
||||
system(intl/convert.sh)
|
||||
}
|
||||
|
||||
|
||||
INCLUDEPATH += src
|
||||
|
||||
SOURCES += src/main.cpp\
|
||||
src/MainWindow.cpp \
|
||||
src/CommitDialog.cpp \
|
||||
src/FileActionDialog.cpp \
|
||||
src/SettingsDialog.cpp \
|
||||
src/CloneDialog.cpp \
|
||||
src/RevisionDialog.cpp \
|
||||
src/Utils.cpp \
|
||||
src/FileTableView.cpp \
|
||||
src/LoggedProcess.cpp \
|
||||
src/BrowserWidget.cpp \
|
||||
src/CustomWebView.cpp \
|
||||
src/Fossil.cpp \
|
||||
src/Workspace.cpp
|
||||
|
||||
HEADERS += src/MainWindow.h \
|
||||
src/CommitDialog.h \
|
||||
src/FileActionDialog.h \
|
||||
src/SettingsDialog.h \
|
||||
src/CloneDialog.h \
|
||||
src/RevisionDialog.h \
|
||||
src/Utils.h \
|
||||
src/FileTableView.h \
|
||||
src/LoggedProcess.h \
|
||||
src/BrowserWidget.h \
|
||||
src/CustomWebView.h \
|
||||
src/Fossil.h \
|
||||
src/Workspace.h
|
||||
|
||||
FORMS += ui/MainWindow.ui \
|
||||
ui/CommitDialog.ui \
|
||||
ui/FileActionDialog.ui \
|
||||
ui/SettingsDialog.ui \
|
||||
ui/CloneDialog.ui \
|
||||
ui/BrowserWidget.ui \
|
||||
ui/RevisionDialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
rsrc/resources.qrc
|
||||
|
||||
CODECFORTR = UTF-8
|
||||
|
||||
TRANSLATIONS += \
|
||||
intl/en_US.ts \
|
||||
intl/el_GR.ts \
|
||||
intl/de_DE.ts \
|
||||
intl/es_ES.ts \
|
||||
intl/fr_FR.ts \
|
||||
intl/ru_RU.ts \
|
||||
intl/pt_PT.ts
|
||||
|
||||
#-------------------------------------------------
|
||||
# Fuel
|
||||
#-------------------------------------------------
|
||||
|
||||
QT = core gui webkit
|
||||
|
||||
contains(QT_VERSION, ^5\\..*) {
|
||||
QT += widgets webkitwidgets
|
||||
QT -= quick multimediawidgets opengl printsupport qml multimedia positioning sensors
|
||||
}
|
||||
|
||||
TARGET = Fuel
|
||||
TEMPLATE = app
|
||||
|
||||
win32 {
|
||||
RC_FILE = rsrc/fuel.rc
|
||||
LIBS += -luser32 -lshell32 -luuid
|
||||
}
|
||||
|
||||
macx {
|
||||
ICON = rsrc/icons/fuel.icns
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
TARGET = fuel
|
||||
ICON = rsrc/icons/fuel.png
|
||||
PREFIX = /usr
|
||||
BINDIR = $$PREFIX/bin
|
||||
DATADIR = $$PREFIX/share
|
||||
target.path = $$BINDIR
|
||||
|
||||
desktop.path = $$DATADIR/applications
|
||||
desktop.files += rsrc/fuel.desktop
|
||||
|
||||
icon.path = $$DATADIR/icons/hicolor/256x256/apps
|
||||
icon.files += rsrc/icons/fuel.png
|
||||
|
||||
INSTALLS += target desktop icon
|
||||
system(intl/convert.sh)
|
||||
}
|
||||
|
||||
|
||||
INCLUDEPATH += src
|
||||
|
||||
SOURCES += src/main.cpp\
|
||||
src/MainWindow.cpp \
|
||||
src/CommitDialog.cpp \
|
||||
src/FileActionDialog.cpp \
|
||||
src/SettingsDialog.cpp \
|
||||
src/CloneDialog.cpp \
|
||||
src/RevisionDialog.cpp \
|
||||
src/Utils.cpp \
|
||||
src/FileTableView.cpp \
|
||||
src/LoggedProcess.cpp \
|
||||
src/BrowserWidget.cpp \
|
||||
src/CustomWebView.cpp \
|
||||
src/Fossil.cpp \
|
||||
src/Workspace.cpp \
|
||||
src/SearchBox.cpp
|
||||
|
||||
HEADERS += src/MainWindow.h \
|
||||
src/CommitDialog.h \
|
||||
src/FileActionDialog.h \
|
||||
src/SettingsDialog.h \
|
||||
src/CloneDialog.h \
|
||||
src/RevisionDialog.h \
|
||||
src/Utils.h \
|
||||
src/FileTableView.h \
|
||||
src/LoggedProcess.h \
|
||||
src/BrowserWidget.h \
|
||||
src/CustomWebView.h \
|
||||
src/Fossil.h \
|
||||
src/Workspace.h \
|
||||
src/SearchBox.h
|
||||
|
||||
FORMS += ui/MainWindow.ui \
|
||||
ui/CommitDialog.ui \
|
||||
ui/FileActionDialog.ui \
|
||||
ui/SettingsDialog.ui \
|
||||
ui/CloneDialog.ui \
|
||||
ui/BrowserWidget.ui \
|
||||
ui/RevisionDialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
rsrc/resources.qrc
|
||||
|
||||
CODECFORTR = UTF-8
|
||||
|
||||
TRANSLATIONS += \
|
||||
intl/en_US.ts \
|
||||
intl/el_GR.ts \
|
||||
intl/de_DE.ts \
|
||||
intl/es_ES.ts \
|
||||
intl/fr_FR.ts \
|
||||
intl/ru_RU.ts \
|
||||
intl/pt_PT.ts
|
||||
|
||||
|
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C The\sheader\sof\sthe\sworkspace\sview\sis\sno\slonger\sregenerated\severy\srefresh\n
|
||||
D 2015-05-12T19:13:27.768
|
||||
C Added\sSearchBox
|
||||
D 2015-05-12T20:38:16.320
|
||||
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
|
||||
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
|
||||
F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b
|
||||
@ -15,7 +15,7 @@ F dist/win/fuel.iss ef3558dbba409eb194938b930377fc9ee27d319e
|
||||
F doc/Building.txt 17b43fa23da764b5d1b828cc48c5a95e612bbd8f
|
||||
F doc/Changes.txt b03302545e4a6c0b16a30d623a7627f8aef65ef6
|
||||
F doc/License.txt 4cc77b90af91e615a64ae04893fdffa7939db84c
|
||||
F fuel.pro d64e2a78105bf9ecbb288a17b2706afcc4c12514
|
||||
F fuel.pro b1813a5c54474ca67e484aec4cc9a246ca9a1b07
|
||||
F intl/convert.bat 4222ae403418381452b843929d15259ea9850ab1 x
|
||||
F intl/convert.sh 2ca2179ff53e727f241925b75e19182607883c45 x
|
||||
F intl/de_DE.ts e2faceab920ac60c97bbc6fba038e261d51fc741
|
||||
@ -200,10 +200,12 @@ F src/Fossil.cpp ca7ad24622e1fc1a03c92d7ae9b51afc17f7c09c
|
||||
F src/Fossil.h d65a7461d213bcc30f08724d3306c6ee00843217
|
||||
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
|
||||
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
|
||||
F src/MainWindow.cpp fe78b884abb2e123c2526ed28eda3b7d88d27843
|
||||
F src/MainWindow.h 2b84fe52f8184364d63a7c9518500017b866e8ea
|
||||
F src/MainWindow.cpp a4ce4ef0d6a49829b23d26954aa866c7ed154370
|
||||
F src/MainWindow.h 7a2ac41cdd205acccd64a5314f25621ecb616288
|
||||
F src/RevisionDialog.cpp 51065c65a07c118dd1a7363da4a55a135d1c6c9c
|
||||
F src/RevisionDialog.h b718c3009342eaabad39c8a11a253a4e4fef7a73
|
||||
F src/SearchBox.cpp d4209c575baa9933e1ce5ed376e785b289a145ba
|
||||
F src/SearchBox.h 0c78d3a68136dab3e0e71b83ae36f22bd2688ab2
|
||||
F src/SettingsDialog.cpp a46cff5e5dd425e3dbdd15632abfd5829f5562b4
|
||||
F src/SettingsDialog.h 4e2790f581e991c744ae9f86580f1972b8c7ff43
|
||||
F src/Utils.cpp 748a58f19187aff7f3b867894129291cbe091678
|
||||
@ -220,7 +222,7 @@ F ui/FileActionDialog.ui 89bb4dc2d0b8adcd41adcb11ec65f2028a09a12d
|
||||
F ui/MainWindow.ui 9dd0f9ef3f486413c9af912ac557c0e7bf9c6f50
|
||||
F ui/RevisionDialog.ui 27c3b98c665fec014a50cbf3352c0627f75e68cd
|
||||
F ui/SettingsDialog.ui 2b7c2870e0054b0f4106f495d85d02c0b814df8b
|
||||
P 0bdfeb81b088e0b1476518a320428b235967936f
|
||||
R 2d33b0f451ed31f3d6f54ffd9cf1f7d3
|
||||
P d1823f2de2e505cae5c738292e71f54e54908ea0
|
||||
R f18b61f87c30ab5d96166c7cdb065ec4
|
||||
U kostas
|
||||
Z 23fe2012ed952500a94dffca4949ebb4
|
||||
Z 94fdd6bb117bbef8d98dd141fa290c48
|
||||
|
@ -1 +1 @@
|
||||
d1823f2de2e505cae5c738292e71f54e54908ea0
|
||||
097bed86191fae72e1bf76078b8e9d8da37b2932
|
@ -12,6 +12,7 @@
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
#include "SearchBox.h"
|
||||
#include "CommitDialog.h"
|
||||
#include "FileActionDialog.h"
|
||||
#include "CloneDialog.h"
|
||||
@ -84,7 +85,6 @@ struct WorkspaceItem
|
||||
};
|
||||
Q_DECLARE_METATYPE(WorkspaceItem)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspacePath) :
|
||||
QMainWindow(parent),
|
||||
@ -230,6 +230,30 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
abortShortcut->setEnabled(false);
|
||||
connect(abortShortcut, SIGNAL(activated()), this, SLOT(onAbort()));
|
||||
|
||||
// Searchbox
|
||||
// Add spacer to pad to right
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
ui->mainToolBar->addWidget(spacer);
|
||||
|
||||
// Search shortcut
|
||||
searchShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this);
|
||||
searchShortcut->setContext(Qt::ApplicationShortcut);
|
||||
searchShortcut->setEnabled(true);
|
||||
connect(searchShortcut, SIGNAL(activated()), this, SLOT(onSearch()));
|
||||
|
||||
|
||||
// Create SearchBox
|
||||
searchBox = new SearchBox(this);
|
||||
searchBox->setPlaceholderText(tr("Find (%0)").arg(searchShortcut->key().toString()));
|
||||
searchBox->setMaximumWidth(450);
|
||||
ui->mainToolBar->addWidget(searchBox);
|
||||
|
||||
connect( searchBox,
|
||||
SIGNAL( textChanged(const QString&)),
|
||||
SLOT( onSearchBoxTextChanged(const QString&)),
|
||||
Qt::DirectConnection );
|
||||
|
||||
viewMode = VIEWMODE_TREE;
|
||||
|
||||
uiCallback.init(this);
|
||||
@ -373,6 +397,7 @@ bool MainWindow::openWorkspace(const QString &path)
|
||||
|
||||
// Select the Root of the tree to update the file view
|
||||
selectRootDir();
|
||||
searchBox->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -760,38 +785,46 @@ void MainWindow::updateFileView()
|
||||
|
||||
bool display_path = viewMode==VIEWMODE_LIST || selectedDirs.count() > 1;
|
||||
|
||||
const QString &status_unknown = QString(tr("Unknown"));
|
||||
const QString &search_text = searchBox->text();
|
||||
|
||||
size_t item_id=0;
|
||||
for(Workspace::filemap_t::iterator it = getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
{
|
||||
const WorkspaceFile &e = *it.value();
|
||||
QString path = e.getPath();
|
||||
const QString &path = e.getPath();
|
||||
const QString &file_path = e.getFilePath();
|
||||
QString native_file_path = QDir::toNativeSeparators(file_path);
|
||||
|
||||
// Apply filter if available
|
||||
if(!search_text.isEmpty() && !native_file_path.contains(search_text, Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
||||
// In Tree mode, filter all items not included in the current dir
|
||||
if(viewMode==VIEWMODE_TREE && !selectedDirs.contains(path))
|
||||
continue;
|
||||
|
||||
// Status Column
|
||||
QString status_text = QString(tr("Unknown"));
|
||||
const QString *status_text = &status_unknown;
|
||||
const char *status_icon_path= ":icons/icons/Button Blank Gray-01.png"; // Default icon
|
||||
|
||||
for(size_t t=0; t<COUNTOF(stats); ++t)
|
||||
{
|
||||
if(e.getType() == stats[t].type)
|
||||
{
|
||||
status_text = stats[t].text;
|
||||
status_text = &stats[t].text;
|
||||
status_icon_path = stats[t].icon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QStandardItem *status = new QStandardItem(getInternalIcon(status_icon_path), status_text);
|
||||
status->setToolTip(status_text);
|
||||
QStandardItem *status = new QStandardItem(getInternalIcon(status_icon_path), *status_text);
|
||||
status->setToolTip(*status_text);
|
||||
getWorkspace().getFileModel().setItem(item_id, COLUMN_STATUS, status);
|
||||
|
||||
QFileInfo finfo = e.getFileInfo();
|
||||
QString icon_type = iconProvider.type(finfo);
|
||||
|
||||
|
||||
if(!iconCache.contains(icon_type))
|
||||
iconCache.insert(icon_type, iconProvider.icon(finfo));
|
||||
|
||||
@ -801,13 +834,13 @@ void MainWindow::updateFileView()
|
||||
getWorkspace().getFileModel().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, native_file_path);
|
||||
else
|
||||
filename_item = new QStandardItem(*icon, e.getFilename());
|
||||
|
||||
Q_ASSERT(filename_item);
|
||||
// Keep the path in the user data
|
||||
filename_item->setData(e.getFilePath());
|
||||
filename_item->setData(file_path);
|
||||
getWorkspace().getFileModel().setItem(item_id, COLUMN_FILENAME, filename_item);
|
||||
|
||||
getWorkspace().getFileModel().setItem(item_id, COLUMN_EXTENSION, new QStandardItem(finfo.suffix()));
|
||||
@ -2334,3 +2367,16 @@ void MainWindow::on_actionMergeBranch_triggered()
|
||||
revision = selectedBranches.first();
|
||||
MergeRevision(revision);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::onSearchBoxTextChanged(const QString &)
|
||||
{
|
||||
updateFileView();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::onSearch()
|
||||
{
|
||||
searchBox->selectAll();
|
||||
searchBox->setFocus();
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ private slots:
|
||||
void onWorkspaceTreeViewSelectionChanged(const class QItemSelection &selected, const class QItemSelection &deselected);
|
||||
void onFileViewDragOut();
|
||||
void onAbort();
|
||||
void onSearchBoxTextChanged(const QString &text);
|
||||
void onSearch();
|
||||
|
||||
// Designer slots
|
||||
void on_actionRefresh_triggered();
|
||||
@ -161,6 +163,8 @@ private:
|
||||
class QLabel *lblRevision;
|
||||
class QLabel *lblTags;
|
||||
class QShortcut *abortShortcut;
|
||||
class SearchBox *searchBox;
|
||||
class QShortcut *searchShortcut;
|
||||
QMenu *menuWorkspace;
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
|
24
src/SearchBox.cpp
Normal file
24
src/SearchBox.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "SearchBox.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
SearchBox::SearchBox(QWidget *parent) : QLineEdit(parent)
|
||||
{
|
||||
}
|
||||
|
||||
SearchBox::~SearchBox()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SearchBox::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
// Clear text on escape
|
||||
if(event->key() == Qt::Key_Escape)
|
||||
{
|
||||
setText("");
|
||||
clearFocus();
|
||||
}
|
||||
else
|
||||
QLineEdit::keyPressEvent(event);
|
||||
}
|
||||
|
23
src/SearchBox.h
Normal file
23
src/SearchBox.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef SEARCHBOX_H
|
||||
#define SEARCHBOX_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class SearchBox : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchBox(QWidget* parent=0);
|
||||
~SearchBox();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SEARCHBOX_H
|
Loading…
x
Reference in New Issue
Block a user