Commit 4da778df authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent 66fba87b
......@@ -35,18 +35,18 @@
#include "kquery.h"
#include "kfindtreeview.h"
KfindDlg::KfindDlg(const QUrl & url, QWidget *parent)
: KDialog( parent )
KfindDlg::KfindDlg(const QUrl &url, QWidget *parent)
: KDialog(parent)
{
setButtons( User1 | User2 | User3 | Close | Help );
setDefaultButton( User3 );
setModal( true );
setButtons(User1 | User2 | User3 | Close | Help);
setDefaultButton(User3);
setModal(true);
setButtonGuiItem( User3, KStandardGuiItem::find());
setButtonGuiItem( User2, KStandardGuiItem::stop() );
setButtonGuiItem( User1, KStandardGuiItem::saveAs() );
setButtonGuiItem(User3, KStandardGuiItem::find());
setButtonGuiItem(User2, KStandardGuiItem::stop());
setButtonGuiItem(User1, KStandardGuiItem::saveAs());
QWidget::setWindowTitle( i18nc("@title:window", "Find Files/Folders" ) );
QWidget::setWindowTitle(i18nc("@title:window", "Find Files/Folders"));
setButtonsOrientation(Qt::Vertical);
enableButton(User3, true); // Enable "Find"
......@@ -56,11 +56,11 @@ KfindDlg::KfindDlg(const QUrl & url, QWidget *parent)
isResultReported = false;
QFrame *frame = new QFrame;
setMainWidget( frame );
setMainWidget(frame);
// create tabwidget
tabWidget = new KfindTabWidget( frame );
tabWidget->setURL( url );
tabWidget = new KfindTabWidget(frame);
tabWidget->setURL(url);
tabWidget->setFocus();
// prepare window for find results
......@@ -68,7 +68,7 @@ KfindDlg::KfindDlg(const QUrl & url, QWidget *parent)
mStatusBar = new KStatusBar(frame);
mStatusBar->insertItem(QStringLiteral("AMiddleLengthText..."), 0);
setStatusMsg( i18nc("the application is currently idle, there is no active search", "Idle.") );
setStatusMsg(i18nc("the application is currently idle, there is no active search", "Idle."));
mStatusBar->setItemAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
mStatusBar->insertPermanentItem(QString(), 1, 1);
mStatusBar->setItemAlignment(1, Qt::AlignRight | Qt::AlignVCenter);
......@@ -87,18 +87,18 @@ KfindDlg::KfindDlg(const QUrl & url, QWidget *parent)
connect(this, SIGNAL(user1Clicked()),
win, SLOT(saveResults()));
connect( this, SIGNAL(closeClicked()), this, SLOT(finishAndClose()) );
connect(this, SIGNAL(closeClicked()), this, SLOT(finishAndClose()));
connect(win ,SIGNAL(resultSelected(bool)),
this,SIGNAL(resultSelected(bool)));
connect(win, SIGNAL(resultSelected(bool)),
this, SIGNAL(resultSelected(bool)));
query = new KQuery(frame);
connect(query, SIGNAL(result(int)), SLOT(slotResult(int)));
connect(query, SIGNAL(foundFileList(QList<QPair<KFileItem,QString> >)), SLOT(addFiles(QList<QPair<KFileItem,QString> >)));
KHelpMenu *helpMenu = new KHelpMenu(this, KAboutData::applicationData(), true);
setButtonMenu( Help, helpMenu->menu() );
dirwatch=NULL;
setButtonMenu(Help, helpMenu->menu());
dirwatch = NULL;
}
KfindDlg::~KfindDlg()
......@@ -125,7 +125,6 @@ void KfindDlg::setStatusMsg(const QString &msg)
mStatusBar->changeItem(msg, 0);
}
void KfindDlg::startSearch()
{
tabWidget->setQuery(query);
......@@ -143,7 +142,7 @@ void KfindDlg::startSearch()
enableButton(User1, false); // Disable "Save As..."
delete dirwatch;
dirwatch=new KDirWatch();
dirwatch = new KDirWatch();
connect(dirwatch, SIGNAL(created(QString)), this, SLOT(slotNewItems(QString)));
connect(dirwatch, SIGNAL(deleted(QString)), this, SLOT(slotDeleteItem(QString)));
dirwatch->addDir(query->url().toLocalFile(), KDirWatch::WatchFiles);
......@@ -161,11 +160,11 @@ void KfindDlg::startSearch()
// been fixed in KDirWatch, but that has not yet been confirmed.
//Getting a list of all subdirs
if(tabWidget->isSearchRecursive() && (dirwatch->internalMethod() == KDirWatch::FAM))
{
const QStringList subdirs=getAllSubdirs(query->url().path());
for(QStringList::const_iterator it = subdirs.constBegin(); it != subdirs.constEnd(); ++it)
dirwatch->addDir(*it,true);
if (tabWidget->isSearchRecursive() && (dirwatch->internalMethod() == KDirWatch::FAM)) {
const QStringList subdirs = getAllSubdirs(query->url().path());
for (QStringList::const_iterator it = subdirs.constBegin(); it != subdirs.constEnd(); ++it) {
dirwatch->addDir(*it, true);
}
}
#endif
......@@ -196,25 +195,20 @@ void KfindDlg::newSearch()
void KfindDlg::slotResult(int errorCode)
{
if (errorCode == 0)
setStatusMsg( i18nc("the application is currently idle, there is no active search", "Idle.") );
else if (errorCode == KIO::ERR_USER_CANCELED)
if (errorCode == 0) {
setStatusMsg(i18nc("the application is currently idle, there is no active search", "Idle."));
} else if (errorCode == KIO::ERR_USER_CANCELED) {
setStatusMsg(i18n("Canceled."));
else if (errorCode == KIO::ERR_MALFORMED_URL)
{
} else if (errorCode == KIO::ERR_MALFORMED_URL) {
setStatusMsg(i18n("Error."));
KMessageBox::sorry( this, i18n("Please specify an absolute path in the \"Look in\" box."));
}
else if (errorCode == KIO::ERR_DOES_NOT_EXIST)
{
KMessageBox::sorry(this, i18n("Please specify an absolute path in the \"Look in\" box."));
} else if (errorCode == KIO::ERR_DOES_NOT_EXIST) {
setStatusMsg(i18n("Error."));
KMessageBox::sorry( this, i18n("Could not find the specified folder."));
}
else
{
KMessageBox::sorry(this, i18n("Could not find the specified folder."));
} else {
//qDebug()<<"KIO error code: "<<errorCode;
setStatusMsg(i18n("Error."));
};
}
enableButton(User3, true); // Enable "Find"
enableButton(User2, false); // Disable "Stop"
......@@ -223,21 +217,19 @@ void KfindDlg::slotResult(int errorCode)
win->endSearch();
tabWidget->endSearch();
setFocus();
}
void KfindDlg::addFiles( const QList< QPair<KFileItem,QString> > & pairs)
void KfindDlg::addFiles(const QList< QPair<KFileItem, QString> > &pairs)
{
win->insertItems( pairs );
win->insertItems(pairs);
if (!isResultReported)
{
if (!isResultReported) {
emit haveResults(true);
isResultReported = true;
}
QString str = i18np("one file found", "%1 files found", win->itemCount());
setProgressMsg( str );
setProgressMsg(str);
}
void KfindDlg::setFocus()
......@@ -250,31 +242,31 @@ void KfindDlg::copySelection()
win->copySelection();
}
void KfindDlg::about ()
void KfindDlg::about()
{
KAboutApplicationDialog dlg(KAboutData::applicationData(), 0, this);
dlg.exec ();
dlg.exec();
}
void KfindDlg::slotDeleteItem(const QString& file)
void KfindDlg::slotDeleteItem(const QString &file)
{
//qDebug()<<QString("Will remove one item: %1").arg(file);
win->removeItem( QUrl::fromLocalFile(file) );
win->removeItem(QUrl::fromLocalFile(file));
QString str = i18np("one file found", "%1 files found", win->itemCount());
setProgressMsg( str );
setProgressMsg(str);
}
void KfindDlg::slotNewItems( const QString& file )
void KfindDlg::slotNewItems(const QString &file)
{
//qDebug()<<QString("Will add this item") << file;
const QUrl url = QUrl::fromLocalFile(file);
if( query->url().isParentOf(url) )
{
if ( !win->isInserted( url ) )
query->slotListEntries( QStringList() << file );
if (query->url().isParentOf(url)) {
if (!win->isInserted(url)) {
query->slotListEntries(QStringList() << file);
}
}
}
......@@ -283,15 +275,15 @@ QStringList KfindDlg::getAllSubdirs(QDir d)
QStringList dirs;
QStringList subdirs;
d.setFilter( QDir::Dirs );
d.setFilter(QDir::Dirs);
dirs = d.entryList();
for(QStringList::const_iterator it = dirs.constBegin(); it != dirs.constEnd(); ++it)
{
if((*it==QLatin1String(".")) || (*it==QLatin1String("..")))
for (QStringList::const_iterator it = dirs.constBegin(); it != dirs.constEnd(); ++it) {
if ((*it == QLatin1String(".")) || (*it == QLatin1String(".."))) {
continue;
}
subdirs.append(d.path()+QLatin1Char('/')+*it);
subdirs+=getAllSubdirs(QString(d.path()+QLatin1Char('/')+*it));
subdirs += getAllSubdirs(QString(d.path()+QLatin1Char('/')+*it));
}
return subdirs;
}
......@@ -35,12 +35,12 @@ class KfindTabWidget;
class KFindTreeView;
class KStatusBar;
class KfindDlg: public KDialog
class KfindDlg : public KDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit KfindDlg(const QUrl & url, QWidget * parent = 0);
explicit KfindDlg(const QUrl &url, QWidget *parent = 0);
~KfindDlg();
void copySelection();
......@@ -55,13 +55,13 @@ public Q_SLOTS:
void startSearch();
void stopSearch();
void newSearch();
void addFiles( const QList< QPair<KFileItem,QString> > & );
void addFiles(const QList< QPair<KFileItem, QString> > &);
void setFocus();
void slotResult(int);
// void slotSearchDone();
void about ();
void slotDeleteItem(const QString&);
void slotNewItems( const QString& );
void about();
void slotDeleteItem(const QString &);
void slotNewItems(const QString &);
void finishAndClose();
......@@ -71,7 +71,7 @@ Q_SIGNALS:
private:
KfindTabWidget *tabWidget;
KFindTreeView * win;
KFindTreeView *win;
bool isResultReported;
KQuery *query;
......
This diff is collapsed.
......@@ -38,15 +38,22 @@ class KfindDlg;
class KFindItem
{
public:
explicit KFindItem( const KFileItem & = KFileItem(), const QString & subDir = QString(), const QString & matchingLine = QString() );
public:
explicit KFindItem(const KFileItem & = KFileItem(), const QString &subDir = QString(), const QString &matchingLine = QString());
QVariant data(int column, int role) const;
KFileItem getFileItem() const { return m_fileItem; }
bool isValid() const { return !m_fileItem.isNull(); }
KFileItem getFileItem() const
{
return m_fileItem;
}
private:
bool isValid() const
{
return !m_fileItem.isNull();
}
private:
KFileItem m_fileItem;
QString m_matchingLine;
QString m_subDir;
......@@ -54,79 +61,98 @@ class KFindItem
QIcon m_icon;
};
class KFindItemModel: public QAbstractTableModel
class KFindItemModel : public QAbstractTableModel
{
public:
KFindItemModel( KFindTreeView* parent);
public:
KFindItemModel(KFindTreeView *parent);
void insertFileItems( const QList< QPair<KFileItem,QString> > &);
void insertFileItems(const QList< QPair<KFileItem, QString> > &);
void removeItem(const QUrl &);
bool isInserted(const QUrl &);
void clear();
Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE { return Qt::CopyAction | Qt::MoveAction; }
Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE
{
return Qt::CopyAction | Qt::MoveAction;
}
Qt::ItemFlags flags(const QModelIndex &) const Q_DECL_OVERRIDE;
QMimeData * mimeData(const QModelIndexList &) const Q_DECL_OVERRIDE;
QMimeData *mimeData(const QModelIndexList &) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE
{
Q_UNUSED(parent);
return 6;
}
int columnCount ( const QModelIndex & parent = QModelIndex() ) const Q_DECL_OVERRIDE { Q_UNUSED(parent); return 6; }
int rowCount ( const QModelIndex & parent = QModelIndex() ) const Q_DECL_OVERRIDE;
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
KFindItem itemAtIndex( const QModelIndex & index ) const;
KFindItem itemAtIndex(const QModelIndex &index) const;
QList<KFindItem> getItemList() const { return m_itemList; }
QList<KFindItem> getItemList() const
{
return m_itemList;
}
private:
private:
QList<KFindItem> m_itemList;
KFindTreeView* m_view;
KFindTreeView *m_view;
};
class KFindSortFilterProxyModel: public QSortFilterProxyModel
class KFindSortFilterProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
KFindSortFilterProxyModel(QObject * parent = 0):
QSortFilterProxyModel(parent){}
public:
KFindSortFilterProxyModel(QObject *parent = 0)
: QSortFilterProxyModel(parent)
{
}
protected:
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
};
class KFindTreeView: public QTreeView
class KFindTreeView : public QTreeView
{
Q_OBJECT
public:
KFindTreeView( QWidget * parent, KfindDlg * findDialog);
public:
KFindTreeView(QWidget *parent, KfindDlg *findDialog);
~KFindTreeView();
void beginSearch(const QUrl& baseUrl);
void beginSearch(const QUrl &baseUrl);
void endSearch();
void insertItems(const QList< QPair<KFileItem,QString> > &);
void removeItem(const QUrl & url);
void insertItems(const QList< QPair<KFileItem, QString> > &);
void removeItem(const QUrl &url);
bool isInserted(const QUrl &url)
{
return m_model->isInserted(url);
}
bool isInserted(const QUrl & url) { return m_model->isInserted( url ); }
QString reducedDir(const QString &fullDir);
QString reducedDir(const QString& fullDir);
int itemCount()
{
return m_model->rowCount();
}
int itemCount() { return m_model->rowCount(); }
QList<QUrl> selectedUrls();
public Q_SLOTS:
public Q_SLOTS:
void copySelection();
void contextMenuRequested( const QPoint & p );
void contextMenuRequested(const QPoint &p);
private Q_SLOTS:
private Q_SLOTS:
void deleteSelectedFiles();
void moveToTrashSelectedFiles();
void slotExecute( const QModelIndex & index );
void slotExecute(const QModelIndex &index);
void slotExecuteSelected();
void openContainingFolder();
......@@ -135,25 +161,28 @@ class KFindTreeView: public QTreeView
void reconfigureMouseSettings();
void updateMouseButtons();
protected:
void dragMoveEvent( QDragMoveEvent *e ) Q_DECL_OVERRIDE { e->accept(); }
protected:
void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE
{
e->accept();
}
Q_SIGNALS:
Q_SIGNALS:
void resultSelected(bool);
private:
private:
void resizeToContents();
QDir m_baseDir;
KFindItemModel * m_model;
KFindSortFilterProxyModel * m_proxyModel;
KActionCollection * m_actionCollection;
QMenu * m_contextMenu;
KFindItemModel *m_model;
KFindSortFilterProxyModel *m_proxyModel;
KActionCollection *m_actionCollection;
QMenu *m_contextMenu;
Qt::MouseButtons m_mouseButtons;
KfindDlg * m_kfindDialog;
KfindDlg *m_kfindDialog;
};
#endif
This diff is collapsed.
......@@ -42,16 +42,16 @@ class QLabel;
class KfDirDialog;
class KfindTabWidget: public KTabWidget
class KfindTabWidget : public KTabWidget
{
Q_OBJECT
public:
KfindTabWidget(QWidget * parent = 0);
KfindTabWidget(QWidget *parent = 0);
virtual ~KfindTabWidget();
void initMimeTypes();
void initSpecialMimeTypes();
void setQuery(class KQuery * query);
void setQuery(class KQuery *query);
void setDefaults();
void beginSearch();
......@@ -60,7 +60,7 @@ public:
void saveHistory();
bool isSearchRecursive();
void setURL( const QUrl & url );
void setURL(const QUrl &url);
QSize sizeHint() const Q_DECL_OVERRIDE;
......@@ -89,7 +89,7 @@ public:
QCheckBox *hiddenFilesCb;
// for third page
KComboBox *typeBox;
KLineEdit * textEdit;
KLineEdit *textEdit;
QCheckBox *caseSensCb;
KComboBox *m_usernameBox;
KComboBox *m_groupBox;
......@@ -115,8 +115,8 @@ private:
QLabel *andL;
QButtonGroup *bg;
QRadioButton *rb[2];
KDateComboBox * fromDate;
KDateComboBox * toDate;
KDateComboBox *fromDate;
KDateComboBox *toDate;
KIntSpinBox *timeBox;
//3rd page
......@@ -141,12 +141,12 @@ class KDigitValidator : public QValidator
Q_OBJECT
public:
KDigitValidator(QWidget * parent);
KDigitValidator(QWidget *parent);
~KDigitValidator();
QValidator::State validate(QString & input, int &) const Q_DECL_OVERRIDE;
QValidator::State validate(QString &input, int &) const Q_DECL_OVERRIDE;
private:
private:
QRegExp *r;
};
......
This diff is collapsed.
......@@ -38,39 +38,41 @@ class KQuery : public QObject
{
Q_OBJECT
public:
public:
KQuery(QObject *parent = 0);
~KQuery();
/* Functions to set Query requirements */
void setSizeRange( int mode, KIO::filesize_t value1, KIO::filesize_t value2);
void setTimeRange( time_t from, time_t to );
void setRegExp( const QString &regexp, bool caseSensitive );
void setRecursive( bool recursive );
void setPath(const QUrl & url );
void setFileType( int filetype );
void setMimeType( const QStringList & mimetype );
void setContext( const QString & context, bool casesensitive,
bool search_binary, bool useRegexp );
void setUsername( const QString &username );
void setGroupname( const QString &groupname );
void setSizeRange(int mode, KIO::filesize_t value1, KIO::filesize_t value2);
void setTimeRange(time_t from, time_t to);
void setRegExp(const QString &regexp, bool caseSensitive);
void setRecursive(bool recursive);
void setPath(const QUrl &url);
void setFileType(int filetype);
void setMimeType(const QStringList &mimetype);
void setContext(const QString &context, bool casesensitive, bool search_binary, bool useRegexp);
void setUsername(const QString &username);
void setGroupname(const QString &groupname);
void setMetaInfo(const QString &metainfo, const QString &metainfokey);
void setUseFileIndex(bool);
void setShowHiddenFiles(bool);
void start();
void kill();
const QUrl& url() {return m_url;}
const QUrl &url()
{
return m_url;
}
private:
private:
/* Check if file meets the find's requirements*/
inline void processQuery(const KFileItem &);
public Q_SLOTS:
public Q_SLOTS:
/* List of files found using slocate */
void slotListEntries(QStringList);
protected Q_SLOTS:
protected Q_SLOTS:
/* List of files found using KIO */
void slotListEntries(KIO::Job *, const KIO::UDSEntryList &);
void slotResult(KJob *);
......@@ -80,11 +82,11 @@ class KQuery : public QObject
void slotreadyReadStandardError();
void slotendProcessLocate(int, QProcess::ExitStatus);
Q_SIGNALS:
void foundFileList( QList< QPair<KFileItem,QString> >);
Q_SIGNALS:
void foundFileList(QList< QPair<KFileItem, QString> >);
void result(int);
private:
private:
void checkEntries();
int m_filetype;
......@@ -110,7 +112,7 @@ class KQuery : public QObject
QByteArray bufferLocate;
QStringList locateList;
KProcess *processLocate;
QList<QRegExp*> m_regexps;// regexps for file name
QList<QRegExp *> m_regexps;// regexps for file name
// QValueList<bool> m_regexpsContainsGlobs; // what should this be good for ? Alex
KIO::ListJob *job;
bool m_insideCheckEntries;
......@@ -121,7 +123,7 @@ class KQuery : public QObject
QStringList ooo_mimetypes; // OpenOffice.org mimetypes
QStringList koffice_mimetypes;
QList< QPair<KFileItem,QString> > m_foundFilesList;
QList< QPair<KFileItem, QString> > m_foundFilesList;
};
#endif
......@@ -19,7 +19,6 @@
#include <QDir>
#include <QFile>
#include <kurl.h>
#include <KLocalizedString>
#include <QApplication>