[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 21:15:30
Message-ID: 200804152315.31378.dhdev () gmx ! de
[Download RAW message or body]

On Tuesday 15 April 2008, Ivo Anjo wrote:
> Hi.
>
> Yes, according to QDir docs:
>
> Qt uses "/" as a universal directory separator in the same way that "/"
> is used as a path separator in URLs. If you always use "/" as a directory
> separator, Qt will translate your paths to conform to the underlying
> operating system.
>
> Also, looking at this again, I realized that using QString::remove might
> have the corner case where your path repeats (eg, if scanning /home/user/
> and /home/user/stuff/home/user/file.txt matches, it would show up as
> stufffile.txt [and I tested it, it does]).
>
> So attached is a new version of the patch that doesn't cause that.

Looks good, ok to commit.

> I also just noticed a bug, but couldn't find where it's coming from: the
> last line on a file is never matched. E.g. I had created a file with just
> "test" inside, and it wasn't matching. Adding two \n to the end of the
> file made it match. Should I open the bug on b.k.o?

Maybe it's a "<= instead of < bug" somewhere. Opening a report is a good 
idea, too :)

> Ivo
>
> P.s.: Please CC me directly as I have mail delivery for the list off.
>
> On Tue, Apr 15, 2008 at 9:54 PM, Christian Ehrlicher
> <Ch.Ehrlicher@gmx.de>
>
> wrote:
> > Dominik Haumann schrieb:
> >
> >  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?
> > >
> > >  Yes, why not :)
> >
> > In Qt all internal paths have '/' as path separator.
> >
> >
> > Christian


_______________________________________________
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