[Nepomuk] Re: Load/Save queries

Who Knows who828 at gmail.com
Tue Mar 22 17:42:24 CET 2011


 Okay i think i have changed everything as you specified but if you find
anything do let me know though.

On Tue, Mar 22, 2011 at 8:11 PM, Sebastian Trüg <trueg at kde.org> wrote:

> Very good. But since I am a pita some more comments. :)
>
> On 03/22/2011 11:20 AM, Who Knows wrote:
> > diff --git a/mainwindow.cpp b/mainwindow.cpp
> > index d9cd450..29579ab 100644
> > --- a/mainwindow.cpp
> > +++ b/mainwindow.cpp
> > @@ -210,7 +210,20 @@ void MainWindow::setupActions()
> >      // misc actions
> >      // =============================================
> >      KStandardAction::preferences( this, SLOT( slotSettings() ),
> actionCollection() );
> > -    KStandardAction::open( this, SLOT( slotOpen() ), actionCollection()
> );
> > +
> > +    m_actionOpenResource=KStandardAction::open( this, SLOT( slotOpen()
> ), actionCollection() );
>
> spaces around the "="
>
> > +    m_actionOpenResource->setText(i18nc( "@action:button open a
> resource", "Open Resource" ));
> > +    actionCollection()->addAction( QLatin1String( "open_resource" ),
> m_actionOpenResource );
> > +
> > +    KStandardAction::quit( kapp, SLOT( quit() ), actionCollection() );
>
> This line is now duplicated.
>
> > +    m_actionSaveQuery = KStandardAction::save( this, SLOT( slotSave() ),
> actionCollection() );
> > +    m_actionSaveQuery->setText(i18nc( "@action:button save a query",
> "Save Query" ));
> > +    actionCollection()->addAction( QLatin1String( "save_query" ),
> m_actionSaveQuery );
> > +
> > +    m_actionOpenQuery= new KAction( KIcon( QLatin1String( "open-new" )
> ), i18nc( "@action:button open a new query", "Open Query" ),
> actionCollection() );
>
> This does not open a "new query". It simply opens a query from a file.
>
> > +    connect( m_actionOpenQuery, SIGNAL(triggered()), this,
> SLOT(slotLoad()) );
> > +    actionCollection()->addAction( QLatin1String( "open_query" ),
> m_actionOpenQuery );
> > +
> >      KStandardAction::quit( kapp, SLOT( quit() ), actionCollection() );
> >
> >      setupGUI( Keys|Save|Create );
> > @@ -320,6 +333,19 @@ void MainWindow::slotOpen()
> >      }
> >  }
> >
> > +void MainWindow::slotSave()
>
> Please call it slotSaveQuery()
>
> > +{
> > +    m_mainStack->setCurrentWidget( m_resourceQueryWidget );
> > +    m_resourceQueryWidget->slotQuerySaveButtonClicked();
> > +}
> > +
> > +
> > +
> > +void MainWindow::slotLoad()
>
> please call it slotOpenQuery()
>
> > +{
> > +    m_resourceQueryWidget->slotQueryLoadButtonClicked();
> > +    m_mainStack->setCurrentWidget( m_resourceQueryWidget );
> > +}
> >
> >  void MainWindow::slotShowSource()
> >  {
> > @@ -365,3 +391,4 @@ MainWindow* MainWindow::nepomukShellMain()
> >  }
> >
> >  #include "mainwindow.moc"
> > +
> > diff --git a/mainwindow.h b/mainwindow.h
> > index ebf4dd5..a7d5f22 100644
> > --- a/mainwindow.h
> > +++ b/mainwindow.h
> > @@ -58,6 +58,8 @@ private Q_SLOTS:
> >      void slotSettings();
> >      void slotOpen();
> >      void slotShowSource();
> > +    void slotSave();
> > +    void slotLoad();
> >
> >  private:
> >      bool queryClose();
> > @@ -73,7 +75,11 @@ private:
> >      KAction* m_actionNewSubClass;
> >      KAction* m_actionNewProperty;
> >      KAction* m_actionNewResource;
> > -
> > +    KAction* m_actionOpenResource;
> > +    KAction* m_actionSaveQuery;
> > +    KAction* m_actionOpenQuery;
> > +
> > +
> >      KAction* m_actionModeBrowse;
> >      KAction* m_actionModeQuery;
> >      KAction* m_actionModeEdit;
> > @@ -86,3 +92,4 @@ private:
> >  };
> >
> >  #endif
> > +
> > diff --git a/nepomukshellui.rc b/nepomukshellui.rc
> > index e4d59c2..9fdffda 100644
> > --- a/nepomukshellui.rc
> > +++ b/nepomukshellui.rc
> > @@ -8,6 +8,11 @@
>
> you need to raise the version number. Otherwise KDE will not pick up the
> new version of the UI file and use an older local copy in the user's
> home dir.
>
> >    <MenuBar>
> >      <Menu name="file" >
> > +      <Action name="open_resource" />
> > +      <Separator />
> > +      <Action name="open_query" />
> > +      <Action name="save_query" />
> > +      <Separator />
> >        <Action name="create_class" />
> >        <Action name="create_property" />
> >        <Action name="create_resource" />
> > diff --git a/resourcequerywidget.cpp b/resourcequerywidget.cpp
> > index 757674f..3a28c45 100644
> > --- a/resourcequerywidget.cpp
> > +++ b/resourcequerywidget.cpp
> > @@ -30,6 +30,7 @@
> >  #include <KGlobal>
> >  #include <KLocale>
> >  #include <KMessageBox>
> > +#include <KFileDialog>
> >
> >  #include <Soprano/Node>
> >
> > @@ -208,5 +209,33 @@ void
> ResourceQueryWidget::slotQueryShortenButtonClicked()
> >      query= query.simplified();
> >      m_queryEdit->setPlainText( query );
> >  }
> > +void ResourceQueryWidget::slotQueryLoadButtonClicked()
> > +{   KUrl kurl = KUrl::fromPath("/home/");
>
> Using /home as the start URL seems very random to me. I prefer using
> KUrl() which will make KFileDialog remember the last used folder.
>
> > +    QString fileName =  KFileDialog::getOpenFileName(kurl, tr("*.txt"),
> this, tr("Open file"));
> > +    QFile file(fileName);
> > +    QString line;
> > +    if ( file.open(QIODevice::ReadOnly) ){
> > +        QTextStream stream( &file );
> > +        line=stream.readAll();
> > +        file.close();
> > +    }
> > +    m_queryEdit->setPlainText( line );
> > +}
> > +
> > +void ResourceQueryWidget::slotQuerySaveButtonClicked()
> > +{   KUrl kurl = KUrl::fromPath("/home/");
>
> same as above.
>
> > +    QString query = m_queryEdit->toPlainText();
> > +    QString fileName = KFileDialog::getSaveFileName(kurl,
> tr("*.txt"),this,tr("Save File"));
> > +    QFile file(fileName);
> > +    if (file.open(QIODevice::WriteOnly)){
> > +        QTextStream out(&file);
> > +        out << query;
> > +        file.close();
> > +    }
> > +}
> >
> >  #include "resourcequerywidget.moc"
> > +
> > +
> > +
> > +
>
> Four trailing new lines. ;)
>
> > diff --git a/resourcequerywidget.h b/resourcequerywidget.h
> > index 22224fc..9d0c1d2 100644
> > --- a/resourcequerywidget.h
> > +++ b/resourcequerywidget.h
> > @@ -65,6 +65,10 @@ private Q_SLOTS:
> >      void slotQueryFinished();
> >      void slotQueryShortenButtonClicked();
> >
> > +public Q_SLOTS:
> > +    void slotQuerySaveButtonClicked();
> > +    void slotQueryLoadButtonClicked();
> > +
>
> How about calling these openQuery() and saveQuery() instead since the
> query widget has no notion of buttons being clicked.
>
> As you can see all of my comments are mostly cosmetic. Nice work.
>
> Cheers,
> Sebastian
>
> >  private:
> >      void updateHistoryButtonStates();
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/nepomuk/attachments/20110322/b2657c11/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 4895 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/nepomuk/attachments/20110322/b2657c11/attachment-0001.diff 


More information about the Nepomuk mailing list