• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • searchdialog
  • debug
searchdebugnepomukshowdialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "searchdebugnepomukshowdialog.h"
19 
20 #include "pimcommon/util/pimutil.h"
21 #include "pimcommon/texteditor/plaintexteditor/plaintexteditorwidget.h"
22 #include "pimcommon/texteditor/plaintexteditor/plaintexteditor.h"
23 
24 #include <KLocale>
25 #include <KStandardDirs>
26 
27 #include <QProcess>
28 #include <QInputDialog>
29 #include <QPointer>
30 
31 SearchDebugNepomukShowDialog::SearchDebugNepomukShowDialog(const QString &nepomukId, QWidget *parent)
32  : KDialog(parent)
33 {
34  setCaption( i18n( "Nepomuk show result" ) );
35  setButtons( Close | User1 | User2 );
36  setButtonText(User1, i18n("Save As..."));
37  setButtonText(User2, i18n("Search info with nepomukshow..."));
38 
39  mResult = new PimCommon::PlainTextEditorWidget;
40  mResult->setReadOnly(true);
41  setMainWidget( mResult );
42 
43  connect(this, SIGNAL(user1Clicked()), this, SLOT(slotSaveAs()));
44  connect(this, SIGNAL(user2Clicked()), this, SLOT(slotSearchInfoWithNepomuk()));
45  readConfig();
46  executeNepomukShow(nepomukId);
47 }
48 
49 SearchDebugNepomukShowDialog::~SearchDebugNepomukShowDialog()
50 {
51  writeConfig();
52 }
53 
54 void SearchDebugNepomukShowDialog::slotSearchInfoWithNepomuk()
55 {
56  QString defaultValue;
57  if (mResult->editor()->textCursor().hasSelection()) {
58  defaultValue = mResult->editor()->textCursor().selectedText().trimmed();
59  }
60  const QString nepomukId = QInputDialog::getText(this, i18n("Search with nepomukshow"), i18n("Nepomuk id:"), QLineEdit::Normal, defaultValue);
61  if (nepomukId.isEmpty())
62  return;
63  QPointer<SearchDebugNepomukShowDialog> dlg = new SearchDebugNepomukShowDialog(nepomukId, this);
64  dlg->exec();
65  delete dlg;
66 }
67 
68 void SearchDebugNepomukShowDialog::executeNepomukShow(const QString &nepomukId)
69 {
70  const QString path = KStandardDirs::findExe( QLatin1String("nepomukshow") );
71  if ( path.isEmpty() ) {
72  mResult->editor()->setPlainText(i18n("Sorry you don't have \"nepomukshow\" installed on your computer."));
73  } else {
74  QStringList arguments;
75  arguments << nepomukId;
76  QProcess proc;
77  proc.start(path, arguments);
78  if (!proc.waitForFinished()) {
79  mResult->editor()->setPlainText(i18n("Sorry there is a problem with virtuoso."));
80  return;
81  }
82  QByteArray result = proc.readAll();
83  proc.close();
84  mResult->editor()->setPlainText(QString::fromUtf8(result));
85  }
86 }
87 
88 void SearchDebugNepomukShowDialog::readConfig()
89 {
90  KConfigGroup group( KGlobal::config(), "SearchDebugNepomukShowDialog" );
91  const QSize sizeDialog = group.readEntry( "Size", QSize(800,600) );
92  if ( sizeDialog.isValid() ) {
93  resize( sizeDialog );
94  }
95 }
96 
97 void SearchDebugNepomukShowDialog::writeConfig()
98 {
99  KConfigGroup group( KGlobal::config(), "SearchDebugNepomukShowDialog" );
100  group.writeEntry( "Size", size() );
101 }
102 
103 void SearchDebugNepomukShowDialog::slotSaveAs()
104 {
105  const QString filter = i18n( "all files (*)" );
106  PimCommon::Util::saveTextAs(mResult->editor()->toPlainText(), filter, this);
107 }
108 
109 
110 
111 #include "searchdebugnepomukshowdialog.moc"
QWidget
KDialog
SearchDebugNepomukShowDialog::~SearchDebugNepomukShowDialog
~SearchDebugNepomukShowDialog()
Definition: searchdebugnepomukshowdialog.cpp:49
SearchDebugNepomukShowDialog::SearchDebugNepomukShowDialog
SearchDebugNepomukShowDialog(const QString &nepomukId, QWidget *parent=0)
Definition: searchdebugnepomukshowdialog.cpp:31
searchdebugnepomukshowdialog.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal