[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: [PATCH] Kate Find in Files plugin relative path
From:       Dominik Haumann <dhdev () gmx ! de>
Date:       2008-04-15 20:29:36
Message-ID: 200804152229.36463.dhdev () gmx ! de
[Download RAW message or body]

Hi,

looks good, but one question though, see below.

On Monday 14 April 2008, Ivo Anjo wrote:
> Hi.
>
> This patch adds the relative path (from the root folder of the grep) to
> the filename shown on the file in files plugin.
> So if I have /somedir/text/boo.txt and I grep with /somedir as root, and
> boo.txt matches, instead of appearing "boo.txt", it appears
> "text/boo.txt".
>
> This is specially useful in java projects, where you have tons of classes
> in different dirs, and this helps to know what things are without opening
> them and looking at the package.
>
> Ivo Anjo
>
> P.s.: Please CC me directly as I have mail delivery for the list off.
> kate_find_in_files_relpath.patch
>   Index: plugins/findinfiles/kategrepthread.h
> ===================================================================
> --- plugins/findinfiles/kategrepthread.h        (revision 795790)
> +++ plugins/findinfiles/kategrepthread.h        (working copy)
> @@ -51,7 +51,7 @@
>      void grepInFile (const QString &fileName, const QString &baseName);
>  
>    Q_SIGNALS:
> -    void foundMatch (const QString &filename, int line, int column,
> const QString &basename, const QString &lineContent, QWidget *parentTab);
> +    void foundMatch (const QString &filename, const QString &relname,
> int line, int column, const QString &basename, const QString
> &lineContent, QWidget *parentTab); 
>    private:
>      QWidget* m_parentTab;
> @@ -60,6 +60,7 @@
>      bool m_recursive;
>      QStringList m_fileWildcards;
>      QList<QRegExp> m_searchPattern;
> +    QString m_dir;
>  };
>  
>  #endif
> Index: plugins/findinfiles/kategrepdialog.cpp
> ===================================================================
> --- plugins/findinfiles/kategrepdialog.cpp      (revision 795790)
> +++ plugins/findinfiles/kategrepdialog.cpp      (working copy)
> @@ -296,8 +296,8 @@
>    connect(lbResult, SIGNAL(destroyed()), m_grepThread, SLOT(cancel()));
>    connect(lbResult, SIGNAL(destroyed()), this, SLOT(searchFinished()));
>    connect (m_grepThread, SIGNAL(finished()), this,
> SLOT(searchFinished())); -  connect (m_grepThread, SIGNAL(foundMatch
> (const QString &, int, int, const QString &, const QString &, QWidget
> *)), -           this, SLOT(searchMatchFound(const QString &, int, int,
> const QString &, const QString &, QWidget *))); +  connect (m_grepThread,
> SIGNAL(foundMatch (const QString &, const QString &, int, int, const
> QString &, const QString &, QWidget *)), +           this,
> SLOT(searchMatchFound(const QString &, const QString &, int, int, const
> QString &, const QString &, QWidget *))); 
>    // grep
>    m_grepThread->start();
> @@ -369,7 +369,7 @@
>    }
>  }
>  
> -void KateGrepDialog::searchMatchFound(const QString &filename, int line,
> int column, const QString &basename, const QString &lineContent, QWidget
> *parentTab) +void KateGrepDialog::searchMatchFound(const QString
> &filename, const QString &relname, int line, int column, const QString
> &basename, const QString &lineContent, QWidget *parentTab) {
>    // should never happen
>    if(lbResult->indexOf(parentTab) < 0)
> @@ -379,7 +379,7 @@
>  
>    QTreeWidgetItem* item = new QTreeWidgetItem(w);
>    // visible text
> -  item->setText(0, basename);
> +  item->setText(0, relname);
>    item->setText(1, QString::number (line + 1));
>    item->setText(2, lineContent.trimmed());
>  
> Index: plugins/findinfiles/kategrepdialog.h
> ===================================================================
> --- plugins/findinfiles/kategrepdialog.h        (revision 795790)
> +++ plugins/findinfiles/kategrepdialog.h        (working copy)
> @@ -63,7 +63,7 @@
>      void slotClear();
>      void patternTextChanged( const QString &);
>      void searchFinished ();
> -    void searchMatchFound(const QString &filename, int line, int column,
> const QString &basename, const QString &lineContent, QWidget *parentTab);
> +    void searchMatchFound(const QString &filename, const QString
> &relname, int line, int column, const QString &basename, const QString
> &lineContent, QWidget *parentTab); void syncDir();
>  
>    private:
> Index: plugins/findinfiles/kategrepthread.cpp
> ===================================================================
> --- plugins/findinfiles/kategrepthread.cpp      (revision 795790)
> +++ plugins/findinfiles/kategrepthread.cpp      (working copy)
> @@ -36,6 +36,8 @@
>      , m_searchPattern (searchPattern)
>  {
>    m_workQueue << dir;
> +  QDir baseDir(dir);
> +  m_dir = baseDir.absolutePath() + '/';

Does this work on Windows, too?

>  }
>  
>  KateGrepThread::~KateGrepThread ()
> @@ -107,7 +109,9 @@
>        if (firstColumn != -1)
>        {
>          kDebug () << "found match: " << fileName << " : " << lineNumber;
> -        emit foundMatch (fileName, lineNumber, firstColumn, baseName,
> lines.at (0), m_parentTab); +        QString relName = fileName;
> +        relName.remove(m_dir);
> +        emit foundMatch (fileName, relName, lineNumber, firstColumn,
> baseName, lines.at (0), m_parentTab); }
>  
>        // remove first line...
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic