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

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • snippets
snippetdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * snippet feature from kdevelop/plugins/snippet/ *
3  * *
4  * Copyright (C) 2007 by Robert Gruber *
5  * rgruber@users.sourceforge.net *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 
14 #include "snippetdialog_p.h"
15 
16 #include "ui_snippetdialog.h"
17 
18 #include <kactioncollection.h>
19 #include <kdialog.h>
20 #include <klocale.h>
21 
22 SnippetDialog::SnippetDialog( KActionCollection *actionCollection, bool inGroupMode, QWidget *parent )
23  : KDialog( parent ), mActionCollection( actionCollection )
24 {
25  mUi = new Ui::SnippetDialog;
26  mUi->setupUi( mainWidget() );
27 
28  mUi->keyWidget->setCheckActionCollections( QList<KActionCollection*>() << actionCollection );
29  enableButton( Ok, false );
30 
31  connect( mUi->nameEdit, SIGNAL(textChanged(QString)),
32  this, SLOT(slotTextChanged()) );
33  connect( mUi->nameEdit, SIGNAL(returnPressed()),
34  this, SLOT(slotReturnPressed()) );
35  connect( mUi->groupBox, SIGNAL(currentIndexChanged(QString)),
36  this, SLOT(slotGroupChanged()));
37 
38  mUi->snippetText->setMinimumSize( 500, 300 );
39 
40  mUi->groupWidget->setVisible( !inGroupMode );
41  mUi->nameEdit->setFocus();
42 }
43 
44 SnippetDialog::~SnippetDialog()
45 {
46  delete mUi;
47 }
48 
49 void SnippetDialog::slotGroupChanged()
50 {
51  enableButton( Ok, snippetIsValid() );
52 }
53 
54 void SnippetDialog::setName( const QString &name )
55 {
56  mUi->nameEdit->setText( name );
57 }
58 
59 QString SnippetDialog::name() const
60 {
61  return mUi->nameEdit->text();
62 }
63 
64 void SnippetDialog::setText( const QString &text )
65 {
66  mUi->snippetText->setText( text );
67 }
68 
69 QString SnippetDialog::text() const
70 {
71  return mUi->snippetText->toPlainText();
72 }
73 
74 void SnippetDialog::setKeySequence( const QKeySequence &sequence )
75 {
76  mUi->keyWidget->setKeySequence( sequence );
77 }
78 
79 QKeySequence SnippetDialog::keySequence() const
80 {
81  return mUi->keyWidget->keySequence();
82 }
83 
84 void SnippetDialog::setGroupModel( QAbstractItemModel *model )
85 {
86  mUi->groupBox->setModel( model );
87 }
88 
89 void SnippetDialog::setGroupIndex( const QModelIndex &index )
90 {
91  mUi->groupBox->setCurrentIndex( index.row() );
92 }
93 
94 QModelIndex SnippetDialog::groupIndex() const
95 {
96  return mUi->groupBox->model()->index( mUi->groupBox->currentIndex(), 0 );
97 }
98 
99 void SnippetDialog::slotTextChanged()
100 {
101  enableButton( Ok, snippetIsValid() );
102 }
103 
104 bool SnippetDialog::snippetIsValid() const
105 {
106  if ( mUi->groupWidget->isVisible() )
107  return ( !mUi->nameEdit->text().trimmed().isEmpty() &&
108  !mUi->groupBox->currentText().trimmed().isEmpty() );
109  else
110  return ( !mUi->nameEdit->text().trimmed().isEmpty() );
111 }
112 
113 void SnippetDialog::slotReturnPressed()
114 {
115  if ( snippetIsValid() ) {
116  accept();
117  }
118 }
119 
120 #include "snippetdialog_p.moc"
text
const char * text
Definition: mdnadvicedialog.cpp:52
QWidget
KDialog
SnippetDialog::setName
void setName(const QString &name)
Definition: snippetdialog.cpp:54
SnippetDialog::~SnippetDialog
~SnippetDialog()
Definition: snippetdialog.cpp:44
SnippetDialog::setKeySequence
void setKeySequence(const QKeySequence &sequence)
Definition: snippetdialog.cpp:74
SnippetDialog::name
QString name() const
Definition: snippetdialog.cpp:59
QAbstractItemModel
snippetdialog_p.h
SnippetDialog::setText
void setText(const QString &text)
Definition: snippetdialog.cpp:64
SnippetDialog::text
QString text() const
Definition: snippetdialog.cpp:69
SnippetDialog::keySequence
QKeySequence keySequence() const
Definition: snippetdialog.cpp:79
SnippetDialog::SnippetDialog
SnippetDialog(KActionCollection *actionCollection, bool inGroupMode, QWidget *parent=0)
Definition: snippetdialog.cpp:22
SnippetDialog::groupIndex
QModelIndex groupIndex() const
Definition: snippetdialog.cpp:94
SnippetDialog::setGroupIndex
void setGroupIndex(const QModelIndex &index)
Definition: snippetdialog.cpp:89
QList
SnippetDialog::setGroupModel
void setGroupModel(QAbstractItemModel *model)
Definition: snippetdialog.cpp:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

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