summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index b1c7709..b597a6a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1598,531 +1598,537 @@ void MainWindow::keyPressEvent ( QKeyEvent * e )
1598 1598
1599void MainWindow::fillFilterMenu() 1599void MainWindow::fillFilterMenu()
1600{ 1600{
1601 selectFilterMenu->clear(); 1601 selectFilterMenu->clear();
1602 bool disable = false; 1602 bool disable = false;
1603 if ( mView->filterView()->filtersEnabled() ) { 1603 if ( mView->filterView()->filtersEnabled() ) {
1604 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1604 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1605 } 1605 }
1606 else { 1606 else {
1607 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1607 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1608 disable = true; 1608 disable = true;
1609 } 1609 }
1610 selectFilterMenu->insertSeparator(); 1610 selectFilterMenu->insertSeparator();
1611 QPtrList<CalFilter> fili = mView->filters(); 1611 QPtrList<CalFilter> fili = mView->filters();
1612 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1612 CalFilter *curfilter = mView->filterView()->selectedFilter();
1613 CalFilter *filter = fili.first(); 1613 CalFilter *filter = fili.first();
1614 int iii = 1; 1614 int iii = 1;
1615 while(filter) { 1615 while(filter) {
1616 selectFilterMenu->insertItem( filter->name(), iii ); 1616 selectFilterMenu->insertItem( filter->name(), iii );
1617 if ( filter == curfilter) 1617 if ( filter == curfilter)
1618 selectFilterMenu->setItemChecked( iii, true ); 1618 selectFilterMenu->setItemChecked( iii, true );
1619 if ( disable ) 1619 if ( disable )
1620 selectFilterMenu->setItemEnabled( iii, false ); 1620 selectFilterMenu->setItemEnabled( iii, false );
1621 filter = fili.next(); 1621 filter = fili.next();
1622 ++iii; 1622 ++iii;
1623 } 1623 }
1624} 1624}
1625void MainWindow::selectFilter( int fil ) 1625void MainWindow::selectFilter( int fil )
1626{ 1626{
1627 if ( fil == 0 ) { 1627 if ( fil == 0 ) {
1628 mView->toggleFilerEnabled( ); 1628 mView->toggleFilerEnabled( );
1629 } else { 1629 } else {
1630 mView->selectFilter( fil-1 ); 1630 mView->selectFilter( fil-1 );
1631 } 1631 }
1632} 1632}
1633void MainWindow::configureToolBar( int item ) 1633void MainWindow::configureToolBar( int item )
1634{ 1634{
1635 1635
1636 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1636 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1637 KOPrefs *p = KOPrefs::instance(); 1637 KOPrefs *p = KOPrefs::instance();
1638 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1638 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1639 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1639 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1640 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1640 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1641 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1641 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1642 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1642 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1643 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1643 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1644 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1644 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1645 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1645 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1646 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1646 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1647 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1647 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1648 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1648 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1649 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1649 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1650 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1650 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1651 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1651 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1652 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1652 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1653 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1653 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1654 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1654 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1655 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1655 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1656 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1656 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1657 // initActions(); 1657 // initActions();
1658} 1658}
1659 1659
1660void MainWindow::setCaptionToDates() 1660void MainWindow::setCaptionToDates()
1661{ 1661{
1662 QString selDates; 1662 QString selDates;
1663 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1663 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1664 if (mView->startDate() < mView->endDate() ) 1664 if (mView->startDate() < mView->endDate() )
1665 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1665 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1666 setCaption( i18n("Dates: ") + selDates ); 1666 setCaption( i18n("Dates: ") + selDates );
1667 1667
1668} 1668}
1669// parameter item == 0: reinit 1669// parameter item == 0: reinit
1670void MainWindow::configureAgenda( int item ) 1670void MainWindow::configureAgenda( int item )
1671{ 1671{
1672 1672
1673 KOPrefs *p = KOPrefs::instance(); 1673 KOPrefs *p = KOPrefs::instance();
1674 1674
1675 int i; 1675 int i;
1676 if ( item == 1 ) { 1676 if ( item == 1 ) {
1677 mView->toggleAllDaySize(); 1677 mView->toggleAllDaySize();
1678 return; 1678 return;
1679 } 1679 }
1680 // do not allow 4 for widgets higher than 480 1680 // do not allow 4 for widgets higher than 480
1681 // if ( QApplication::desktop()->height() > 480 ) { 1681 // if ( QApplication::desktop()->height() > 480 ) {
1682// if ( item == 4 ) 1682// if ( item == 4 )
1683// item = 6; 1683// item = 6;
1684// } 1684// }
1685 for ( i = 4; i <= 18; i= i+2 ) 1685 for ( i = 4; i <= 18; i= i+2 )
1686 configureAgendaMenu->setItemChecked( i, false ); 1686 configureAgendaMenu->setItemChecked( i, false );
1687 configureAgendaMenu->setItemChecked( item, true ); 1687 configureAgendaMenu->setItemChecked( item, true );
1688 if ( p->mHourSize == item ) 1688 if ( p->mHourSize == item )
1689 return; 1689 return;
1690 p->mHourSize=item; 1690 p->mHourSize=item;
1691 mView->viewManager()->agendaView()->updateConfig(); 1691 mView->viewManager()->agendaView()->updateConfig();
1692} 1692}
1693 1693
1694void MainWindow::saveCalendar() 1694void MainWindow::saveCalendar()
1695{ 1695{
1696 QString fn = KOPrefs::instance()->mLastSaveFile; 1696 QString fn = KOPrefs::instance()->mLastSaveFile;
1697 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1697 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1698 1698
1699 if ( fn == "" ) 1699 if ( fn == "" )
1700 return; 1700 return;
1701 QFileInfo info; 1701 QFileInfo info;
1702 info.setFile( fn ); 1702 info.setFile( fn );
1703 QString mes; 1703 QString mes;
1704 bool createbup = true; 1704 bool createbup = true;
1705 if ( info. exists() ) { 1705 if ( info. exists() ) {
1706 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1706 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1707 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1707 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1708 i18n("Overwrite!"), i18n("Cancel"), 0, 1708 i18n("Overwrite!"), i18n("Cancel"), 0,
1709 0, 1 ); 1709 0, 1 );
1710 if ( result != 0 ) { 1710 if ( result != 0 ) {
1711 createbup = false; 1711 createbup = false;
1712 } 1712 }
1713 } 1713 }
1714 if ( createbup ) { 1714 if ( createbup ) {
1715 mView->saveCalendar( fn ); 1715 mView->saveCalendar( fn );
1716 mes = i18n("KO/Pi:Saved %1").arg(fn); 1716 mes = i18n("KO/Pi:Saved %1").arg(fn);
1717 KOPrefs::instance()->mLastSaveFile = fn; 1717 KOPrefs::instance()->mLastSaveFile = fn;
1718 setCaption(mes); 1718 setCaption(mes);
1719 } 1719 }
1720} 1720}
1721void MainWindow::loadCalendar() 1721void MainWindow::loadCalendar()
1722{ 1722{
1723 1723
1724 QString fn = KOPrefs::instance()->mLastLoadFile; 1724 QString fn = KOPrefs::instance()->mLastLoadFile;
1725 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1725 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1726 1726
1727 if ( fn == "" ) 1727 if ( fn == "" )
1728 return; 1728 return;
1729 QFileInfo info; 1729 QFileInfo info;
1730 info.setFile( fn ); 1730 info.setFile( fn );
1731 QString mess; 1731 QString mess;
1732 bool loadbup = true; 1732 bool loadbup = true;
1733 if ( info. exists() ) { 1733 if ( info. exists() ) {
1734 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1734 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1735 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1735 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1736 mess, 1736 mess,
1737 i18n("Load!"), i18n("Cancel"), 0, 1737 i18n("Load!"), i18n("Cancel"), 0,
1738 0, 1 ); 1738 0, 1 );
1739 if ( result != 0 ) { 1739 if ( result != 0 ) {
1740 loadbup = false; 1740 loadbup = false;
1741 } 1741 }
1742 } else { 1742 } else {
1743 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1743 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1744 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1744 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1745 0, 1 ); 1745 0, 1 );
1746 1746
1747 return; 1747 return;
1748 } 1748 }
1749 if ( loadbup ) { 1749 if ( loadbup ) {
1750 mView->openCalendar( fn ); 1750 mView->openCalendar( fn );
1751 KOPrefs::instance()->mLastLoadFile = fn; 1751 KOPrefs::instance()->mLastLoadFile = fn;
1752 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1752 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1753 setCaption(mess); 1753 setCaption(mess);
1754 } 1754 }
1755 1755
1756} 1756}
1757void MainWindow::quickImportIcal() 1757void MainWindow::quickImportIcal()
1758{ 1758{
1759 importFile( KOPrefs::instance()->mLastImportFile, false ); 1759 importFile( KOPrefs::instance()->mLastImportFile, false );
1760} 1760}
1761void MainWindow::importFile( QString fn, bool quick ) 1761void MainWindow::importFile( QString fn, bool quick )
1762{ 1762{
1763 QFileInfo info; 1763 QFileInfo info;
1764 info.setFile( fn ); 1764 info.setFile( fn );
1765 QString mess; 1765 QString mess;
1766 bool loadbup = true; 1766 bool loadbup = true;
1767 if ( !info. exists() ) { 1767 if ( !info. exists() ) {
1768 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1768 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1769 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1769 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1770 mess ); 1770 mess );
1771 return; 1771 return;
1772 } 1772 }
1773 int result = 0; 1773 int result = 0;
1774 if ( !quick ) { 1774 if ( !quick ) {
1775 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1775 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1776 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1776 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1777 mess, 1777 mess,
1778 "Import", "Cancel", 0, 1778 "Import", "Cancel", 0,
1779 0, 1 ); 1779 0, 1 );
1780 } 1780 }
1781 if ( result == 0 ) { 1781 if ( result == 0 ) {
1782 if ( mView->openCalendar( fn, true )) { 1782 if ( mView->openCalendar( fn, true )) {
1783 KOPrefs::instance()->mLastImportFile = fn; 1783 KOPrefs::instance()->mLastImportFile = fn;
1784 setCaption(i18n("Imported file successfully")); 1784 setCaption(i18n("Imported file successfully"));
1785 } else { 1785 } else {
1786 setCaption(i18n("Error importing file")); 1786 setCaption(i18n("Error importing file"));
1787 } 1787 }
1788 } 1788 }
1789} 1789}
1790 1790
1791void MainWindow::importIcal() 1791void MainWindow::importIcal()
1792{ 1792{
1793 1793
1794 QString fn =KOPrefs::instance()->mLastImportFile; 1794 QString fn =KOPrefs::instance()->mLastImportFile;
1795 1795
1796 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1796 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1797 if ( fn == "" ) 1797 if ( fn == "" )
1798 return; 1798 return;
1799 importFile( fn, true ); 1799 importFile( fn, true );
1800 1800
1801} 1801}
1802 1802
1803void MainWindow::exportVCalendar() 1803void MainWindow::exportVCalendar()
1804{ 1804{
1805 QString fn = KOPrefs::instance()->mLastVcalFile; 1805 QString fn = KOPrefs::instance()->mLastVcalFile;
1806 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1806 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1807 if ( fn == "" ) 1807 if ( fn == "" )
1808 return; 1808 return;
1809 QFileInfo info; 1809 QFileInfo info;
1810 info.setFile( fn ); 1810 info.setFile( fn );
1811 QString mes; 1811 QString mes;
1812 bool createbup = true; 1812 bool createbup = true;
1813 if ( info. exists() ) { 1813 if ( info. exists() ) {
1814 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1814 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1815 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1815 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1816 i18n("Overwrite!"), i18n("Cancel"), 0, 1816 i18n("Overwrite!"), i18n("Cancel"), 0,
1817 0, 1 ); 1817 0, 1 );
1818 if ( result != 0 ) { 1818 if ( result != 0 ) {
1819 createbup = false; 1819 createbup = false;
1820 } 1820 }
1821 } 1821 }
1822 if ( createbup ) { 1822 if ( createbup ) {
1823 if ( mView->exportVCalendar( fn ) ) { 1823 if ( mView->exportVCalendar( fn ) ) {
1824 KOPrefs::instance()->mLastVcalFile = fn; 1824 KOPrefs::instance()->mLastVcalFile = fn;
1825 if ( fn.length() > 20 ) 1825 if ( fn.length() > 20 )
1826 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1826 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1827 else 1827 else
1828 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1828 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1829 setCaption(mes); 1829 setCaption(mes);
1830 } 1830 }
1831 } 1831 }
1832 1832
1833} 1833}
1834#include <qpushbutton.h> 1834#include <qpushbutton.h>
1835QString MainWindow::getPassword( ) 1835QString MainWindow::getPassword( )
1836{ 1836{
1837 QString retfile = ""; 1837 QString retfile = "";
1838 QDialog dia ( this, "input-dialog", true ); 1838 QDialog dia ( this, "input-dialog", true );
1839 QLineEdit lab ( &dia ); 1839 QLineEdit lab ( &dia );
1840 lab.setEchoMode( QLineEdit::Password ); 1840 lab.setEchoMode( QLineEdit::Password );
1841 QVBoxLayout lay( &dia ); 1841 QVBoxLayout lay( &dia );
1842 lay.setMargin(7); 1842 lay.setMargin(7);
1843 lay.setSpacing(7); 1843 lay.setSpacing(7);
1844 lay.addWidget( &lab); 1844 lay.addWidget( &lab);
1845 dia.setFixedSize( 230,50 ); 1845 dia.setFixedSize( 230,50 );
1846 dia.setCaption( i18n("Enter password") ); 1846 dia.setCaption( i18n("Enter password") );
1847 QPushButton pb ( "OK", &dia); 1847 QPushButton pb ( "OK", &dia);
1848 lay.addWidget( &pb ); 1848 lay.addWidget( &pb );
1849 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1849 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1850 dia.show(); 1850 dia.show();
1851 int res = dia.exec(); 1851 int res = dia.exec();
1852 if ( res ) 1852 if ( res )
1853 retfile = lab.text(); 1853 retfile = lab.text();
1854 dia.hide(); 1854 dia.hide();
1855 qApp->processEvents(); 1855 qApp->processEvents();
1856 return retfile; 1856 return retfile;
1857 1857
1858} 1858}
1859 1859
1860void MainWindow::syncLocalFile() 1860void MainWindow::syncLocalFile()
1861{ 1861{
1862 1862
1863 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1863 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1864 1864
1865 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1865 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1866 if ( fn == "" ) 1866 if ( fn == "" )
1867 return; 1867 return;
1868 //mView->setSyncDevice("local-file" ); 1868 //mView->setSyncDevice("local-file" );
1869 if ( syncWithFile( fn, false ) ) { 1869 if ( syncWithFile( fn, false ) ) {
1870 // Event* e = mView->getLastSyncEvent(); 1870 // Event* e = mView->getLastSyncEvent();
1871// e->setReadOnly( false ); 1871// e->setReadOnly( false );
1872// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1872// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1873// e->setReadOnly( true ); 1873// e->setReadOnly( true );
1874 } 1874 }
1875 1875
1876} 1876}
1877 1877
1878bool MainWindow::syncWithFile( QString fn , bool quick ) 1878bool MainWindow::syncWithFile( QString fn , bool quick )
1879{ 1879{
1880 bool ret = false; 1880 bool ret = false;
1881 QFileInfo info; 1881 QFileInfo info;
1882 info.setFile( fn ); 1882 info.setFile( fn );
1883 QString mess; 1883 QString mess;
1884 bool loadbup = true; 1884 bool loadbup = true;
1885 if ( !info. exists() ) { 1885 if ( !info. exists() ) {
1886 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1886 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1887 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1887 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1888 mess ); 1888 mess );
1889 return ret; 1889 return ret;
1890 } 1890 }
1891 int result = 0; 1891 int result = 0;
1892 if ( !quick ) { 1892 if ( !quick ) {
1893 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1893 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1894 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1894 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1895 mess, 1895 mess,
1896 i18n("Sync"), i18n("Cancel"), 0, 1896 i18n("Sync"), i18n("Cancel"), 0,
1897 0, 1 ); 1897 0, 1 );
1898 if ( result ) 1898 if ( result )
1899 return false; 1899 return false;
1900 } 1900 }
1901 if ( KOPrefs::instance()->mAskForPreferences ) 1901 if ( KOPrefs::instance()->mAskForPreferences )
1902 mView->edit_sync_options(); 1902 mView->edit_sync_options();
1903 if ( result == 0 ) { 1903 if ( result == 0 ) {
1904 //qDebug("Now sycing ... "); 1904 //qDebug("Now sycing ... ");
1905 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1905 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1906 setCaption( i18n("Synchronization successful") ); 1906 setCaption( i18n("Synchronization successful") );
1907 else 1907 else
1908 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1908 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1909 if ( ! quick ) 1909 if ( ! quick )
1910 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1910 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1911 slotModifiedChanged( true ); 1911 slotModifiedChanged( true );
1912 } 1912 }
1913 return ret; 1913 return ret;
1914} 1914}
1915void MainWindow::quickSyncLocalFile() 1915void MainWindow::quickSyncLocalFile()
1916{ 1916{
1917 //mView->setSyncDevice("local-file" ); 1917 //mView->setSyncDevice("local-file" );
1918 //qDebug("quickSyncLocalFile() "); 1918 //qDebug("quickSyncLocalFile() ");
1919 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1919 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1920 // Event* e = mView->getLastSyncEvent(); 1920 // Event* e = mView->getLastSyncEvent();
1921// e->setReadOnly( false ); 1921// e->setReadOnly( false );
1922// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1922// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1923// e->setReadOnly( true ); 1923// e->setReadOnly( true );
1924 1924
1925 } 1925 }
1926} 1926}
1927 1927
1928void MainWindow::confSync() 1928void MainWindow::confSync()
1929{ 1929{
1930 mView->confSync(); 1930 mView->confSync();
1931 fillSyncMenu(); 1931 fillSyncMenu();
1932} 1932}
1933void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1933void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1934{ 1934{
1935 QString question; 1935 QString question;
1936 if ( ask ) { 1936 if ( ask ) {
1937 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1937 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1938 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1938 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1939 question, 1939 question,
1940 i18n("Yes"), i18n("No"), 1940 i18n("Yes"), i18n("No"),
1941 0, 0 ) != 0 ) 1941 0, 0 ) != 0 )
1942 return; 1942 return;
1943 } 1943 }
1944 QString command = prof->getPreSyncCommand(); 1944 QString command = prof->getPreSyncCommand();
1945 int fi; 1945 int fi;
1946 if ( (fi = command.find("$PWD$")) > 0 ) { 1946 if ( (fi = command.find("$PWD$")) > 0 ) {
1947 QString pwd = getPassword(); 1947 QString pwd = getPassword();
1948 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1948 command = command.left( fi )+ pwd + command.mid( fi+5 );
1949 1949
1950 } 1950 }
1951 int maxlen = 30; 1951 int maxlen = 30;
1952 if ( QApplication::desktop()->width() > 320 ) 1952 if ( QApplication::desktop()->width() > 320 )
1953 maxlen += 25; 1953 maxlen += 25;
1954 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1954 setCaption ( i18n( "Copy remote file to local machine..." ) );
1955 int fileSize = 0; 1955 int fileSize = 0;
1956 int result = system ( command ); 1956 int result = system ( command );
1957 // 0 : okay 1957 // 0 : okay
1958 // 256: no such file or dir 1958 // 256: no such file or dir
1959 // 1959 //
1960 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1960 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1961 if ( result != 0 ) { 1961 if ( result != 0 ) {
1962 int len = maxlen; 1962 int len = maxlen;
1963 while ( len < command.length() ) { 1963 while ( len < command.length() ) {
1964 command.insert( len , "\n" ); 1964 command.insert( len , "\n" );
1965 len += maxlen +2; 1965 len += maxlen +2;
1966 } 1966 }
1967 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1967 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1968 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1968 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1969 question, 1969 question,
1970 i18n("Okay!")) ; 1970 i18n("Okay!")) ;
1971 setCaption ("KO/Pi"); 1971 setCaption ("KO/Pi");
1972 return; 1972 return;
1973 } 1973 }
1974 setCaption ( i18n( "Copying succeed." ) ); 1974 setCaption ( i18n( "Copying succeed." ) );
1975 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1975 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1976 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1976 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1977// Event* e = mView->getLastSyncEvent(); 1977// Event* e = mView->getLastSyncEvent();
1978// e->setReadOnly( false ); 1978// e->setReadOnly( false );
1979// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1979// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1980// e->setReadOnly( true ); 1980// e->setReadOnly( true );
1981 if ( KOPrefs::instance()->mWriteBackFile ) { 1981 if ( KOPrefs::instance()->mWriteBackFile ) {
1982 command = prof->getPostSyncCommand(); 1982 command = prof->getPostSyncCommand();
1983 int fi;
1984 if ( (fi = command.find("$PWD$")) > 0 ) {
1985 QString pwd = getPassword();
1986 command = command.left( fi )+ pwd + command.mid( fi+5 );
1987
1988 }
1983 setCaption ( i18n( "Writing back file ..." ) ); 1989 setCaption ( i18n( "Writing back file ..." ) );
1984 result = system ( command ); 1990 result = system ( command );
1985 qDebug("KO: Writing back file result: %d ", result); 1991 qDebug("KO: Writing back file result: %d ", result);
1986 if ( result != 0 ) { 1992 if ( result != 0 ) {
1987 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1993 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1988 return; 1994 return;
1989 } else { 1995 } else {
1990 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1996 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1991 } 1997 }
1992 } 1998 }
1993 } 1999 }
1994 return; 2000 return;
1995} 2001}
1996void MainWindow::syncSSH() 2002void MainWindow::syncSSH()
1997{ 2003{
1998 // not used anymore 2004 // not used anymore
1999 QTime timer; 2005 QTime timer;
2000 timer.start(); 2006 timer.start();
2001 //qDebug("MainWindow::syncssh() "); 2007 //qDebug("MainWindow::syncssh() ");
2002 KOPrefs *p = KOPrefs::instance(); 2008 KOPrefs *p = KOPrefs::instance();
2003 QString localFile = p->mLocalTempFile; 2009 QString localFile = p->mLocalTempFile;
2004 QString remoteIP = p->mRemoteIP; 2010 QString remoteIP = p->mRemoteIP;
2005 QString remoteUser = p->mRemoteUser; 2011 QString remoteUser = p->mRemoteUser;
2006 QString remoteFile = p->mRemoteFile; 2012 QString remoteFile = p->mRemoteFile;
2007 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2013 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2008 remoteUser += ":" + p->mRemotePassWd; 2014 remoteUser += ":" + p->mRemotePassWd;
2009 2015
2010 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2016 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2011 i18n("IP: " ) +remoteIP +"\n" + 2017 i18n("IP: " ) +remoteIP +"\n" +
2012 i18n("User: " ) + remoteUser +"\n" ; 2018 i18n("User: " ) + remoteUser +"\n" ;
2013 int maxlen = 30; 2019 int maxlen = 30;
2014 if ( QApplication::desktop()->width() > 320 ) 2020 if ( QApplication::desktop()->width() > 320 )
2015 maxlen += 25; 2021 maxlen += 25;
2016 if ( remoteFile.length() > maxlen ) 2022 if ( remoteFile.length() > maxlen )
2017 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2023 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2018 else 2024 else
2019 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2025 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2020 if ( localFile.length() > maxlen ) 2026 if ( localFile.length() > maxlen )
2021 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2027 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2022 else 2028 else
2023 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2029 question += i18n("Local temp file:\n " ) + localFile +"\n";
2024 2030
2025 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2031 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2026 question, 2032 question,
2027 i18n("Yes"), i18n("No"), 2033 i18n("Yes"), i18n("No"),
2028 0, 0 ) != 0 ) 2034 0, 0 ) != 0 )
2029 return; 2035 return;
2030 // if ( !p->mUsePassWd ) { 2036 // if ( !p->mUsePassWd ) {
2031 // QString pass = getPassword(); 2037 // QString pass = getPassword();
2032 // if ( pass.length() > 0 ) 2038 // if ( pass.length() > 0 )
2033 // remoteUser += ":" + pass; 2039 // remoteUser += ":" + pass;
2034 // } 2040 // }
2035 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2041 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2036 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2042 setCaption ( i18n( "Copy remote file to local machine..." ) );
2037 int fileSize = 0; 2043 int fileSize = 0;
2038 int result = system ( command ); 2044 int result = system ( command );
2039 // 0 : okay 2045 // 0 : okay
2040 // 256: no such file or dir 2046 // 256: no such file or dir
2041 // 2047 //
2042 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2048 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2043 if ( result != 0 ) { 2049 if ( result != 0 ) {
2044 int len = maxlen; 2050 int len = maxlen;
2045 while ( len < command.length() ) { 2051 while ( len < command.length() ) {
2046 command.insert( len , "\n" ); 2052 command.insert( len , "\n" );
2047 len += maxlen +2; 2053 len += maxlen +2;
2048 } 2054 }
2049 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2055 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2050 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2056 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2051 question, 2057 question,
2052 i18n("Okay!")) ; 2058 i18n("Okay!")) ;
2053 setCaption ("KO/Pi"); 2059 setCaption ("KO/Pi");
2054 return; 2060 return;
2055 } 2061 }
2056 2062
2057 2063
2058 setCaption ( i18n( "Copying succeed." ) ); 2064 setCaption ( i18n( "Copying succeed." ) );
2059 //mView->setSyncDevice("ssh-scp" ); 2065 //mView->setSyncDevice("ssh-scp" );
2060 if ( syncWithFile(localFile , true ) ) { 2066 if ( syncWithFile(localFile , true ) ) {
2061// Event* e = mView->getLastSyncEvent(); 2067// Event* e = mView->getLastSyncEvent();
2062// e->setReadOnly( false ); 2068// e->setReadOnly( false );
2063// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2069// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2064// e->setReadOnly( true ); 2070// e->setReadOnly( true );
2065 if ( KOPrefs::instance()->mWriteBackFile ) { 2071 if ( KOPrefs::instance()->mWriteBackFile ) {
2066 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2072 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2067 setCaption ( i18n( "Writing back file ..." ) ); 2073 setCaption ( i18n( "Writing back file ..." ) );
2068 result = system ( command ); 2074 result = system ( command );
2069 if ( result != 0 ) { 2075 if ( result != 0 ) {
2070 int len = maxlen; 2076 int len = maxlen;
2071 while ( len < command.length() ) { 2077 while ( len < command.length() ) {
2072 command.insert( len , "\n" ); 2078 command.insert( len , "\n" );
2073 len += maxlen +2; 2079 len += maxlen +2;
2074 } 2080 }
2075 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2081 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2076 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2082 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2077 question, 2083 question,
2078 i18n("Okay!")) ; 2084 i18n("Okay!")) ;
2079 setCaption ("KO/Pi"); 2085 setCaption ("KO/Pi");
2080 return; 2086 return;
2081 } else { 2087 } else {
2082 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2088 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2083 } 2089 }
2084 } 2090 }
2085 } 2091 }
2086 return; 2092 return;
2087#if 0 2093#if 0
2088 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2094 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2089 while ( timer.elapsed() < 5000 ) 2095 while ( timer.elapsed() < 5000 )
2090 qApp->processEvents(); 2096 qApp->processEvents();
2091 2097
2092 qDebug("MainWindow::merging) "); 2098 qDebug("MainWindow::merging) ");
2093 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2099 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2094 while ( mBlockSaveFlag ) 2100 while ( mBlockSaveFlag )
2095 qApp->processEvents(); 2101 qApp->processEvents();
2096 save(); 2102 save();
2097 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2103 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2098#endif 2104#endif
2099 2105
2100} 2106}
2101 2107
2102 2108
2103void MainWindow::syncSharp() 2109void MainWindow::syncSharp()
2104{ 2110{
2105 if ( mCalendarModifiedFlag ) 2111 if ( mCalendarModifiedFlag )
2106 save(); 2112 save();
2107 mView->syncSharp(); 2113 mView->syncSharp();
2108 slotModifiedChanged( true ); 2114 slotModifiedChanged( true );
2109 2115
2110} 2116}
2111void MainWindow::syncPhone() 2117void MainWindow::syncPhone()
2112{ 2118{
2113 if ( mCalendarModifiedFlag ) 2119 if ( mCalendarModifiedFlag )
2114 save(); 2120 save();
2115 mView->syncPhone(); 2121 mView->syncPhone();
2116 slotModifiedChanged( true ); 2122 slotModifiedChanged( true );
2117 2123
2118} 2124}
2119 2125
2120void MainWindow::printSel( ) 2126void MainWindow::printSel( )
2121{ 2127{
2122 mView->viewManager()->agendaView()->agenda()->printSelection(); 2128 mView->viewManager()->agendaView()->agenda()->printSelection();
2123} 2129}
2124 2130
2125void MainWindow::printCal() 2131void MainWindow::printCal()
2126{ 2132{
2127 mView->print();//mCp->showDialog(); 2133 mView->print();//mCp->showDialog();
2128} 2134}