summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp108
-rw-r--r--korganizer/kolistview.h1
2 files changed, 51 insertions, 58 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5797d1b..1f3b4c6 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -368,48 +368,49 @@ QString KOListView::getWhatsThisText(QPoint p)
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
return i18n("That is the list view" );
}
void KOListView::updateList()
{
// qDebug(" KOListView::updateList() ");
}
void KOListView::clearList()
{
clear ();
}
void KOListView::addCat( )
{
setCategories( false );
}
void KOListView::setCat()
{
setCategories( true );
}
+
void KOListView::setAlarm()
{
KOAlarmPrefs kap( this);
if ( !kap.exec() )
return;
QStringList itemList;
QPtrList<KOListViewItem> sel ;
QListViewItem *qitem = mListView->firstChild ();
while ( qitem ) {
if ( qitem->isSelected() ) {
Incidence* inc = ((KOListViewItem *) qitem)->data();
if ( inc->typeID() != journalID ) {
if ( inc->typeID() == todoID ) {
if ( ((Todo*)inc)->hasDueDate() )
sel.append(((KOListViewItem *)qitem));
} else
sel.append(((KOListViewItem *)qitem));
}
}
qitem = qitem->nextSibling();
}
int count = 0;
KOListViewItem * item, *temp;
item = sel.first();
@@ -493,59 +494,50 @@ void KOListView::setCategories( bool removeOld )
i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
i18n("Todo has subtodos"),
i18n("Yes"),
i18n("No"));
if (result == KMessageBox::Cancel) item = 0;
if (result == KMessageBox::Yes) setSub = true;
}
while ( item ) {
inc = item->data();
if ( removeOld ) {
inc->setCategories( catList, setSub );
} else {
inc->addCategories( catList, setSub );
}
ListItemVisitor v(item, mStartDate );
inc->accept(v);
item = sel.next();
}
}
QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::beamSelected()
{
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
+ QPtrList<Incidence> delSel = getSelectedIncidences() ;
+ int icount = delSel.count();
if ( icount ) {
emit beamIncidenceList( delSel );
return;
QString fn ;
fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
QString mes;
bool createbup = true;
if ( createbup ) {
QString description = "\n";
CalendarLocal* cal = new CalendarLocal();
cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
Incidence *incidence = delSel.first();
while ( incidence ) {
Incidence *in = incidence->clone();
description += in->summary() + "\n";
cal->addIncidence( in );
incidence = delSel.next();
}
FileStorage storage( cal, fn, new VCalFormat );
storage.save();
delete cal;
mes = i18n("KO/Pi: Ready for beaming");
topLevelWidget()->setCaption(mes);
@@ -554,59 +546,50 @@ void KOListView::beamSelected()
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
ir->send( fn, description, "text/x-vCalendar" );
#endif
}
}
}
void KOListView::beamDone( Ir *ir )
{
#ifndef DESKTOP_VERSION
delete ir;
#endif
topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
}
void KOListView::saveDescriptionToFile()
{
int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
i18n("Continue"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
return;
}
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
+ QPtrList<Incidence> delSel = getSelectedIncidences() ;
+ int icount = delSel.count();
if ( icount ) {
QString fn = KOPrefs::instance()->mLastSaveFile;
fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
if ( fn == "" )
return;
QFileInfo info;
info.setFile( fn );
QString mes;
bool createbup = true;
if ( info. exists() ) {
mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
0, 1 );
if ( result != 0 ) {
createbup = false;
}
}
if ( createbup ) {
QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
Incidence *incidence = delSel.first();
icount = 0;
@@ -638,101 +621,119 @@ void KOListView::saveDescriptionToFile()
}
QFile file( fn );
if (!file.open( IO_WriteOnly ) ) {
topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
return;
}
QTextStream ts( &file );
ts << text;
file.close();
//qDebug("%s ", text.latin1());
mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
KOPrefs::instance()->mLastSaveFile = fn;
topLevelWidget()->setCaption(mes);
}
}
}
void KOListView::saveToFileVCS()
{
writeToFile( false );
}
void KOListView::saveToFile()
{
writeToFile( true );
}
-void KOListView::writeToFile( bool iCal )
+QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
{
-
- int icount = 0;
QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- bool journal = iCal; // warn only for vCal
bool addSubTodos = false;
bool askSubTodos = true;
+ QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
- if ( !journal )
- if ( ((KOListViewItem *)item)->data()->typeID() == journalID )
- journal = true;
Incidence* inc = ((KOListViewItem *)item)->data();
- if ( addSubTodos ) {
- if ( delSel.findRef( inc ) == -1 )
- delSel.append( inc );
- } else
- delSel.append(inc);
+ if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
+ if ( (inc->typeID() == todoID && includeTodos) ||
+ (inc->typeID() == eventID && includeEvents) ||
+ (inc->typeID() == journalID && includeJournals) ) {
+ if ( inc->typeID() == todoID && onlyDueTodos ) {
+ if ( ((Todo*)inc)->hasDueDate() )
+ delSel.append( inc );
+ } else
+ delSel.append( inc );
+
+ }
+ }
if ( inc->typeID() == todoID ) {
Todo * todo = (Todo*) inc;
if ( todo->relations().count() ) {
if ( askSubTodos ) {
int result = KMessageBox::warningYesNoCancel(this,
- i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"),
+ i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
i18n("Todo has subtodos"),
i18n("Yes"),
i18n("No"));
- if ( result == KMessageBox::Cancel ) {
- return;
+ if ( result == KMessageBox::Cancel ) {
+ delSel.clear();
+ return delSel;
}
if (result == KMessageBox::Yes)
addSubTodos = true;
askSubTodos = false;
}
if ( addSubTodos ) {
inc->addRelationsToList( &delSel );
}
}
}
- ++icount;
}
item = item->nextSibling();
}
- if ( !iCal && journal ) {
- int result = KMessageBox::warningContinueCancel(this,
- i18n("The journal entries can not be\nexported to a vCalendar file."),
- i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
- true);
- if (result != KMessageBox::Continue) return;
+ return delSel;
+}
+
+void KOListView::writeToFile( bool iCal )
+{
+ QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
+ if ( !iCal ) {
+ bool journal = false;
+ Incidence *incidence = delSel.first();
+ while ( incidence ) {
+ if ( incidence->typeID() == journalID ) {
+ journal = true;
+ break;
+ }
+ incidence = delSel.next();
+ }
+ if ( journal ) {
+ int result = KMessageBox::warningContinueCancel(this,
+ i18n("The journal entries can not be\nexported to a vCalendar file."),
+ i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
+ true);
+ if (result != KMessageBox::Continue) return;
+ }
}
- if ( icount ) {
+ if ( delSel.count() ) {
QString fn = KOPrefs::instance()->mLastSaveFile;
QString extension;
if ( iCal ) {
if ( fn.right( 4 ).lower() == ".vcs" ) {
fn = fn.left( fn.length() -3) + "ics";
}
} else {
if ( fn.right( 4 ).lower() == ".ics" ) {
fn = fn.left( fn.length() -3) + "vcs";
}
}
fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
if ( fn == "" )
return;
QFileInfo info;
info.setFile( fn );
QString mes;
bool createbup = true;
if ( info. exists() ) {
mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
0, 1 );
@@ -765,60 +766,51 @@ void KOListView::writeToFile( bool iCal )
}
void KOListView::hideAll()
{
QPtrList<QListViewItem> delSel ;
QListViewItem *item = mListView->firstChild ();
while ( item ) {
if ( item->isSelected() ) {
delSel.append(item);
}
item = item->nextSibling();
}
item = delSel.first() ;
while ( item ) {
QListViewItem * del = item;
item = delSel.next();
delete del;
}
}
void KOListView::printList()
{
mListView->printList();
}
void KOListView::deleteAll()
{
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
- if ( icount ) {
+ QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
+ if ( delSel.count() ) {
+ int icount = delSel.count();
Incidence *incidence = delSel.first();
Incidence *toDelete;
KOPrefs *p = KOPrefs::instance();
bool confirm = p->mConfirm;
QString mess;
mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
p->mConfirm = false;
int delCounter = 0;
QDialog dia ( this, "p-dialog", true );
QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
QProgressBar bar( icount, &dia );
lay.addWidget( &bar);
int w = 220;
int h = 50;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
//dia.resize( 240,50 );
dia.show();
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index c25592d..9da5497 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -241,48 +241,49 @@ class KOListView : public KOEventView
public:
KOListView(Calendar *calendar, QWidget *parent = 0,
const char *name = 0);
~KOListView();
virtual int maxDatesHint();
virtual int currentDateCount();
virtual QPtrList<Incidence> selectedIncidences();
virtual DateList selectedDates();
void showDates(bool show);
Incidence* currentItem();
void addTodos(QPtrList<Todo> eventList);
void addJournals(QPtrList<Journal> eventList);
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
void readSettings(KConfig *config, QString setting = "KOListView Layout");
void writeSettings(KConfig *config, QString setting = "KOListView Layout");
void updateList();
void clearList();
void setStartDate(const QDate &start);
int count();
QString getWhatsThisText(QPoint p);
+ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
signals:
void signalNewEvent();
void beamIncidenceList(QPtrList<Incidence>);
public slots:
void hideAll();
void printList();
void resetFocus();
virtual void updateView();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void clearSelection();
void allSelection();
void clear();
void beamDone( Ir *ir );
void showDates();
void hideDates();
void deleteAll();
void saveToFile();
void saveToFileVCS();
void saveDescriptionToFile();
void beamSelected();
void updateConfig();