20 #include "pimcommon/util/pimutil.h"
21 #include "pimcommon/texteditor/plaintexteditor/plaintexteditorwidget.h"
22 #include "pimcommon/texteditor/plaintexteditor/plaintexteditor.h"
25 #include <KStandardDirs>
28 #include <QInputDialog>
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..."));
39 mResult =
new PimCommon::PlainTextEditorWidget;
40 mResult->setReadOnly(
true);
41 setMainWidget( mResult );
43 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(slotSaveAs()));
44 connect(
this, SIGNAL(user2Clicked()),
this, SLOT(slotSearchInfoWithNepomuk()));
46 executeNepomukShow(nepomukId);
54 void SearchDebugNepomukShowDialog::slotSearchInfoWithNepomuk()
57 if (mResult->editor()->textCursor().hasSelection()) {
58 defaultValue = mResult->editor()->textCursor().selectedText().trimmed();
60 const QString nepomukId = QInputDialog::getText(
this, i18n(
"Search with nepomukshow"), i18n(
"Nepomuk id:"), QLineEdit::Normal, defaultValue);
61 if (nepomukId.isEmpty())
68 void SearchDebugNepomukShowDialog::executeNepomukShow(
const QString &nepomukId)
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."));
74 QStringList arguments;
75 arguments << nepomukId;
77 proc.start(path, arguments);
78 if (!proc.waitForFinished()) {
79 mResult->editor()->setPlainText(i18n(
"Sorry there is a problem with virtuoso."));
82 QByteArray result = proc.readAll();
84 mResult->editor()->setPlainText(QString::fromUtf8(result));
88 void SearchDebugNepomukShowDialog::readConfig()
90 KConfigGroup group( KGlobal::config(),
"SearchDebugNepomukShowDialog" );
91 const QSize sizeDialog = group.readEntry(
"Size", QSize(800,600) );
92 if ( sizeDialog.isValid() ) {
97 void SearchDebugNepomukShowDialog::writeConfig()
99 KConfigGroup group( KGlobal::config(),
"SearchDebugNepomukShowDialog" );
100 group.writeEntry(
"Size", size() );
103 void SearchDebugNepomukShowDialog::slotSaveAs()
105 const QString filter = i18n(
"all files (*)" );
106 PimCommon::Util::saveTextAs(mResult->editor()->toPlainText(), filter,
this);
111 #include "searchdebugnepomukshowdialog.moc"
~SearchDebugNepomukShowDialog()
SearchDebugNepomukShowDialog(const QString &nepomukId, QWidget *parent=0)