• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kate

katemailfilesdialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "katemailfilesdialog.h"
00020 #include "katemainwindow.h"
00021 #include "kateviewmanager.h"
00022 #include "katedocmanager.h"
00023 
00024 #include <klistview.h>
00025 #include <klocale.h>
00026 #include <kurl.h>
00027 
00028 #include <qevent.h>
00029 #include <qlabel.h>
00030 #include <qstringlist.h>
00031 #include <qvbox.h>
00032 
00033 /* a private check list item, that can store a Kate::Document*.  */
00034 class KateDocCheckItem : public QCheckListItem {
00035   public:
00036     KateDocCheckItem( QListView *parent, const QString& text, Kate::Document *d )
00037       : QCheckListItem( parent, text, QCheckListItem::CheckBox ), mdoc(d) {};
00038     Kate::Document *doc() { return mdoc; };
00039   private:
00040     Kate::Document *mdoc;
00041 };
00042 
00044 // KateMailDialog implementation
00046 KateMailDialog::KateMailDialog( QWidget *parent, KateMainWindow  *mainwin )
00047   : KDialogBase( parent, "kate mail dialog", true, i18n("Email Files"),
00048                 Ok|Cancel|User1, Ok, false,
00049                 KGuiItem( i18n("&Show All Documents >>") ) ),
00050     mainWindow( mainwin )
00051 {
00052   setButtonGuiItem( KDialogBase::Ok, KGuiItem( i18n("&Mail..."), "mail_send") );
00053   mw = makeVBoxMainWidget();
00054   mw->installEventFilter( this );
00055 
00056   lInfo = new QLabel( i18n(
00057         "<p>Press <strong>Mail...</strong> to email the current document."
00058         "<p>To select more documents to send, press <strong>Show All Documents&nbsp;&gt;&gt;</strong>."), mw );
00059   // TODO avoid untill needed - later
00060   list = new KListView( mw );
00061   list->addColumn( i18n("Name") );
00062   list->addColumn( i18n("URL") );
00063   Kate::Document *currentDoc = mainWindow->viewManager()->activeView()->getDoc();
00064   uint n = KateDocManager::self()->documents();
00065   uint i = 0;
00066   QCheckListItem *item;
00067   while ( i < n ) {
00068     Kate::Document *doc = KateDocManager::self()->document( i );
00069     if ( doc ) {
00070       item = new KateDocCheckItem( list, doc->docName(), doc );
00071       item->setText( 1, doc->url().prettyURL() );
00072       if ( doc == currentDoc ) {
00073         item->setOn( true );
00074         item->setSelected( true );
00075       }
00076     }
00077     i++;
00078   }
00079   list->hide();
00080   connect( this, SIGNAL(user1Clicked()), this, SLOT(slotShowButton()) );
00081   mw->setMinimumSize( lInfo->sizeHint() );
00082 }
00083 
00084 QPtrList<Kate::Document> KateMailDialog::selectedDocs()
00085 {
00086   QPtrList<Kate::Document> l;
00087   QListViewItem *item = list->firstChild();
00088   while ( item ) {
00089     if ( ((KateDocCheckItem*)item)->isOn() )
00090       l.append( ((KateDocCheckItem*)item)->doc() );
00091     item = item->nextSibling();
00092   }
00093   return l;
00094 }
00095 
00096 void KateMailDialog::slotShowButton()
00097 {
00098   if ( list->isVisible() ) {
00099     setButtonText( User1, i18n("&Show All Documents >>") );
00100     list->hide();
00101   }
00102   else {
00103     list->show();
00104     setButtonText( User1, i18n("&Hide Document List <<") );
00105     lInfo->setText( i18n("Press <strong>Mail...</strong> to send selected documents") );
00106 
00107   }
00108   mw->setMinimumSize( QSize( lInfo->sizeHint().width(), mw->sizeHint().height()) );
00109   setMinimumSize( calculateSize( mw->minimumSize().width(), mw->sizeHint().height() ) );
00110   resize( width(), minimumHeight() );
00111 }
00112 #include "katemailfilesdialog.moc"

kate

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

API Reference

Skip menu "API Reference"
  • kate
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal