00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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
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 >></strong>."), mw );
00059
00060 list =
new KListView( mw );
00061 list->addColumn( i18n(
"Name") );
00062 list->addColumn( i18n(
"URL") );
00063 Kate::Document *currentDoc = mainWindow->m_viewManager->activeView()->getDoc();
00064 uint n = mainWindow->m_docManager->documents();
00065 uint i = 0;
00066 QCheckListItem *item;
00067
while ( i < n ) {
00068 Kate::Document *doc = mainWindow->m_docManager->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"