-rw-r--r-- | korganizer/mainwindow.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index f2e1bf8..ebe761a 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1686,512 +1686,514 @@ void MainWindow::configureToolBar( int item ) | |||
1686 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1686 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1687 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1687 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1688 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1688 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1689 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1689 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1690 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1690 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1691 | // initActions(); | 1691 | // initActions(); |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | void MainWindow::setCaptionToDates() | 1694 | void MainWindow::setCaptionToDates() |
1695 | { | 1695 | { |
1696 | QString selDates; | 1696 | QString selDates; |
1697 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1697 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1698 | if (mView->startDate() < mView->endDate() ) | 1698 | if (mView->startDate() < mView->endDate() ) |
1699 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1699 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1700 | setCaption( i18n("Dates: ") + selDates ); | 1700 | setCaption( i18n("Dates: ") + selDates ); |
1701 | 1701 | ||
1702 | } | 1702 | } |
1703 | // parameter item == 0: reinit | 1703 | // parameter item == 0: reinit |
1704 | void MainWindow::configureAgenda( int item ) | 1704 | void MainWindow::configureAgenda( int item ) |
1705 | { | 1705 | { |
1706 | 1706 | ||
1707 | KOPrefs *p = KOPrefs::instance(); | 1707 | KOPrefs *p = KOPrefs::instance(); |
1708 | 1708 | ||
1709 | int i; | 1709 | int i; |
1710 | if ( item == 1 ) { | 1710 | if ( item == 1 ) { |
1711 | mView->toggleAllDaySize(); | 1711 | mView->toggleAllDaySize(); |
1712 | return; | 1712 | return; |
1713 | } | 1713 | } |
1714 | // do not allow 4 for widgets higher than 480 | 1714 | // do not allow 4 for widgets higher than 480 |
1715 | // if ( QApplication::desktop()->height() > 480 ) { | 1715 | // if ( QApplication::desktop()->height() > 480 ) { |
1716 | // if ( item == 4 ) | 1716 | // if ( item == 4 ) |
1717 | // item = 6; | 1717 | // item = 6; |
1718 | // } | 1718 | // } |
1719 | for ( i = 4; i <= 18; i= i+2 ) | 1719 | for ( i = 4; i <= 18; i= i+2 ) |
1720 | configureAgendaMenu->setItemChecked( i, false ); | 1720 | configureAgendaMenu->setItemChecked( i, false ); |
1721 | configureAgendaMenu->setItemChecked( item, true ); | 1721 | configureAgendaMenu->setItemChecked( item, true ); |
1722 | if ( p->mHourSize == item ) | 1722 | if ( p->mHourSize == item ) |
1723 | return; | 1723 | return; |
1724 | p->mHourSize=item; | 1724 | p->mHourSize=item; |
1725 | mView->viewManager()->agendaView()->updateConfig(); | 1725 | mView->viewManager()->agendaView()->updateConfig(); |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | void MainWindow::saveCalendar() | 1728 | void MainWindow::saveCalendar() |
1729 | { | 1729 | { |
1730 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1730 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1731 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1731 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1732 | 1732 | ||
1733 | if ( fn == "" ) | 1733 | if ( fn == "" ) |
1734 | return; | 1734 | return; |
1735 | QFileInfo info; | 1735 | QFileInfo info; |
1736 | info.setFile( fn ); | 1736 | info.setFile( fn ); |
1737 | QString mes; | 1737 | QString mes; |
1738 | bool createbup = true; | 1738 | bool createbup = true; |
1739 | if ( info. exists() ) { | 1739 | if ( info. exists() ) { |
1740 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1740 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1741 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1741 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1742 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1742 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1743 | 0, 1 ); | 1743 | 0, 1 ); |
1744 | if ( result != 0 ) { | 1744 | if ( result != 0 ) { |
1745 | createbup = false; | 1745 | createbup = false; |
1746 | } | 1746 | } |
1747 | } | 1747 | } |
1748 | if ( createbup ) { | 1748 | if ( createbup ) { |
1749 | mView->saveCalendar( fn ); | 1749 | mView->saveCalendar( fn ); |
1750 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1750 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1751 | KOPrefs::instance()->mLastSaveFile = fn; | 1751 | KOPrefs::instance()->mLastSaveFile = fn; |
1752 | setCaption(mes); | 1752 | setCaption(mes); |
1753 | } | 1753 | } |
1754 | } | 1754 | } |
1755 | void MainWindow::loadCalendar() | 1755 | void MainWindow::loadCalendar() |
1756 | { | 1756 | { |
1757 | 1757 | ||
1758 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1758 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1759 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1759 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1760 | 1760 | ||
1761 | if ( fn == "" ) | 1761 | if ( fn == "" ) |
1762 | return; | 1762 | return; |
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("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1768 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1769 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1769 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1770 | mess, | 1770 | mess, |
1771 | i18n("Load!"), i18n("Cancel"), 0, | 1771 | i18n("Load!"), i18n("Cancel"), 0, |
1772 | 0, 1 ); | 1772 | 0, 1 ); |
1773 | if ( result != 0 ) { | 1773 | if ( result != 0 ) { |
1774 | loadbup = false; | 1774 | loadbup = false; |
1775 | } | 1775 | } |
1776 | } else { | 1776 | } else { |
1777 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1777 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1778 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1778 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1779 | 0, 1 ); | 1779 | 0, 1 ); |
1780 | 1780 | ||
1781 | return; | 1781 | return; |
1782 | } | 1782 | } |
1783 | if ( loadbup ) { | 1783 | if ( loadbup ) { |
1784 | mView->openCalendar( fn ); | 1784 | mView->openCalendar( fn ); |
1785 | KOPrefs::instance()->mLastLoadFile = fn; | 1785 | KOPrefs::instance()->mLastLoadFile = fn; |
1786 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1786 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1787 | setCaption(mess); | 1787 | setCaption(mess); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | } | 1790 | } |
1791 | void MainWindow::quickImportIcal() | 1791 | void MainWindow::quickImportIcal() |
1792 | { | 1792 | { |
1793 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1793 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1794 | } | 1794 | } |
1795 | void MainWindow::importFile( QString fn, bool quick ) | 1795 | void MainWindow::importFile( QString fn, bool quick ) |
1796 | { | 1796 | { |
1797 | QFileInfo info; | 1797 | QFileInfo info; |
1798 | info.setFile( fn ); | 1798 | info.setFile( fn ); |
1799 | QString mess; | 1799 | QString mess; |
1800 | bool loadbup = true; | 1800 | bool loadbup = true; |
1801 | if ( !info. exists() ) { | 1801 | if ( !info. exists() ) { |
1802 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1802 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1803 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1803 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1804 | mess ); | 1804 | mess ); |
1805 | return; | 1805 | return; |
1806 | } | 1806 | } |
1807 | int result = 0; | 1807 | int result = 0; |
1808 | if ( !quick ) { | 1808 | if ( !quick ) { |
1809 | 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 )); | 1809 | 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 )); |
1810 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1810 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1811 | mess, | 1811 | mess, |
1812 | "Import", "Cancel", 0, | 1812 | "Import", "Cancel", 0, |
1813 | 0, 1 ); | 1813 | 0, 1 ); |
1814 | } | 1814 | } |
1815 | if ( result == 0 ) { | 1815 | if ( result == 0 ) { |
1816 | if ( mView->openCalendar( fn, true )) { | 1816 | if ( mView->openCalendar( fn, true )) { |
1817 | KOPrefs::instance()->mLastImportFile = fn; | 1817 | KOPrefs::instance()->mLastImportFile = fn; |
1818 | setCaption(i18n("Imported file successfully")); | 1818 | setCaption(i18n("Imported file successfully")); |
1819 | } else { | 1819 | } else { |
1820 | setCaption(i18n("Error importing file")); | 1820 | setCaption(i18n("Error importing file")); |
1821 | } | 1821 | } |
1822 | } | 1822 | } |
1823 | } | 1823 | } |
1824 | 1824 | ||
1825 | void MainWindow::importIcal() | 1825 | void MainWindow::importIcal() |
1826 | { | 1826 | { |
1827 | 1827 | ||
1828 | QString fn =KOPrefs::instance()->mLastImportFile; | 1828 | QString fn =KOPrefs::instance()->mLastImportFile; |
1829 | 1829 | ||
1830 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1830 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1831 | if ( fn == "" ) | 1831 | if ( fn == "" ) |
1832 | return; | 1832 | return; |
1833 | importFile( fn, true ); | 1833 | importFile( fn, true ); |
1834 | 1834 | ||
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | void MainWindow::exportVCalendar() | 1837 | void MainWindow::exportVCalendar() |
1838 | { | 1838 | { |
1839 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1839 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1840 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1840 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1841 | if ( fn == "" ) | 1841 | if ( fn == "" ) |
1842 | return; | 1842 | return; |
1843 | QFileInfo info; | 1843 | QFileInfo info; |
1844 | info.setFile( fn ); | 1844 | info.setFile( fn ); |
1845 | QString mes; | 1845 | QString mes; |
1846 | bool createbup = true; | 1846 | bool createbup = true; |
1847 | if ( info. exists() ) { | 1847 | if ( info. exists() ) { |
1848 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1848 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1849 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1849 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1850 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1850 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1851 | 0, 1 ); | 1851 | 0, 1 ); |
1852 | if ( result != 0 ) { | 1852 | if ( result != 0 ) { |
1853 | createbup = false; | 1853 | createbup = false; |
1854 | } | 1854 | } |
1855 | } | 1855 | } |
1856 | if ( createbup ) { | 1856 | if ( createbup ) { |
1857 | if ( mView->exportVCalendar( fn ) ) { | 1857 | if ( mView->exportVCalendar( fn ) ) { |
1858 | KOPrefs::instance()->mLastVcalFile = fn; | 1858 | KOPrefs::instance()->mLastVcalFile = fn; |
1859 | if ( fn.length() > 20 ) | 1859 | if ( fn.length() > 20 ) |
1860 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1860 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1861 | else | 1861 | else |
1862 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1862 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1863 | setCaption(mes); | 1863 | setCaption(mes); |
1864 | } | 1864 | } |
1865 | } | 1865 | } |
1866 | 1866 | ||
1867 | } | 1867 | } |
1868 | #include <qpushbutton.h> | 1868 | #include <qpushbutton.h> |
1869 | QString MainWindow::getPassword( ) | 1869 | QString MainWindow::getPassword( ) |
1870 | { | 1870 | { |
1871 | QString retfile = ""; | 1871 | QString retfile = ""; |
1872 | QDialog dia ( this, "input-dialog", true ); | 1872 | QDialog dia ( this, "input-dialog", true ); |
1873 | QLineEdit lab ( &dia ); | 1873 | QLineEdit lab ( &dia ); |
1874 | lab.setEchoMode( QLineEdit::Password ); | 1874 | lab.setEchoMode( QLineEdit::Password ); |
1875 | QVBoxLayout lay( &dia ); | 1875 | QVBoxLayout lay( &dia ); |
1876 | lay.setMargin(7); | 1876 | lay.setMargin(7); |
1877 | lay.setSpacing(7); | 1877 | lay.setSpacing(7); |
1878 | lay.addWidget( &lab); | 1878 | lay.addWidget( &lab); |
1879 | dia.setFixedSize( 230,50 ); | 1879 | dia.setFixedSize( 230,50 ); |
1880 | dia.setCaption( i18n("Enter password") ); | 1880 | dia.setCaption( i18n("Enter password") ); |
1881 | QPushButton pb ( "OK", &dia); | 1881 | QPushButton pb ( "OK", &dia); |
1882 | lay.addWidget( &pb ); | 1882 | lay.addWidget( &pb ); |
1883 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1883 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1884 | dia.show(); | 1884 | dia.show(); |
1885 | int res = dia.exec(); | 1885 | int res = dia.exec(); |
1886 | if ( res ) | 1886 | if ( res ) |
1887 | retfile = lab.text(); | 1887 | retfile = lab.text(); |
1888 | dia.hide(); | 1888 | dia.hide(); |
1889 | qApp->processEvents(); | 1889 | qApp->processEvents(); |
1890 | return retfile; | 1890 | return retfile; |
1891 | 1891 | ||
1892 | } | 1892 | } |
1893 | 1893 | ||
1894 | void MainWindow::enableQuick() | 1894 | void MainWindow::enableQuick() |
1895 | { | 1895 | { |
1896 | QString retfile = ""; | 1896 | QString retfile = ""; |
1897 | QDialog dia ( this, "input-dialog", true ); | 1897 | QDialog dia ( this, "input-dialog", true ); |
1898 | QLineEdit lab ( &dia ); | 1898 | QLineEdit lab ( &dia ); |
1899 | QVBoxLayout lay( &dia ); | 1899 | QVBoxLayout lay( &dia ); |
1900 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1900 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1901 | lay.setMargin(7); | 1901 | lay.setMargin(7); |
1902 | lay.setSpacing(7); | 1902 | lay.setSpacing(7); |
1903 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1903 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1904 | lay.addWidget( &label); | 1904 | lay.addWidget( &label); |
1905 | lay.addWidget( &lab); | 1905 | lay.addWidget( &lab); |
1906 | dia.setFixedSize( 230,80 ); | 1906 | dia.setFixedSize( 230,80 ); |
1907 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); | 1907 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); |
1908 | QPushButton pb ( "OK", &dia); | 1908 | QPushButton pb ( "OK", &dia); |
1909 | lay.addWidget( &pb ); | 1909 | lay.addWidget( &pb ); |
1910 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1910 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1911 | dia.show(); | 1911 | dia.show(); |
1912 | int res = dia.exec(); | 1912 | int res = dia.exec(); |
1913 | if ( res ) | 1913 | if ( res ) |
1914 | retfile = lab.text(); | 1914 | retfile = lab.text(); |
1915 | else | 1915 | else |
1916 | return; | 1916 | return; |
1917 | dia.hide(); | 1917 | dia.hide(); |
1918 | qApp->processEvents(); | 1918 | qApp->processEvents(); |
1919 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1919 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1920 | bool ok; | 1920 | bool ok; |
1921 | Q_UINT16 port = retfile.toUInt(&ok); | 1921 | Q_UINT16 port = retfile.toUInt(&ok); |
1922 | if ( ! ok ) { | 1922 | if ( ! ok ) { |
1923 | qDebug("no valid port "); | 1923 | qDebug("no valid port "); |
1924 | return; | 1924 | return; |
1925 | } | 1925 | } |
1926 | qDebug("port %d ", port); | 1926 | qDebug("port %d ", port); |
1927 | mServerSocket = new KServerSocket ( port ,1 ); | 1927 | mServerSocket = new KServerSocket ( port ,1 ); |
1928 | qDebug("connected "); | 1928 | qDebug("connected "); |
1929 | if ( !mServerSocket->ok() ) { | 1929 | if ( !mServerSocket->ok() ) { |
1930 | qWarning("Failed to bind to port %d", port); | 1930 | qWarning("Failed to bind to port %d", port); |
1931 | delete mServerSocket; | 1931 | delete mServerSocket; |
1932 | mServerSocket = 0; | 1932 | mServerSocket = 0; |
1933 | return; | 1933 | return; |
1934 | } | 1934 | } |
1935 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | 1935 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); |
1936 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | 1936 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); |
1937 | } | 1937 | } |
1938 | void MainWindow::sendFile(QSocket* socket) | 1938 | void MainWindow::sendFile(QSocket* socket) |
1939 | { | 1939 | { |
1940 | setCaption( i18n("Received request for file") ); | 1940 | setCaption( i18n("Received request for file") ); |
1941 | qDebug("MainWindow::sendFile(QSocket* s) "); | 1941 | qDebug("MainWindow::sendFile(QSocket* s) "); |
1942 | if ( mSyncActionDialog ) | ||
1943 | delete mSyncActionDialog; | ||
1942 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); | 1944 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); |
1943 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); | 1945 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); |
1944 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); | 1946 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); |
1945 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1947 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1946 | lay->addWidget( label); | 1948 | lay->addWidget( label); |
1947 | lay->setMargin(7); | 1949 | lay->setMargin(7); |
1948 | lay->setSpacing(7); | 1950 | lay->setSpacing(7); |
1949 | mSyncActionDialog->setFixedSize( 200,100 ); | 1951 | mSyncActionDialog->setFixedSize( 200,100 ); |
1950 | mSyncActionDialog->show(); | 1952 | mSyncActionDialog->show(); |
1951 | qApp->processEvents(); | 1953 | qApp->processEvents(); |
1952 | qDebug("saving ... "); | 1954 | qDebug("saving ... "); |
1953 | save(); | 1955 | save(); |
1954 | QString fileName = defaultFileName(); | 1956 | QString fileName = defaultFileName(); |
1955 | QFile file( fileName ); | 1957 | QFile file( fileName ); |
1956 | if (!file.open( IO_ReadOnly ) ) { | 1958 | if (!file.open( IO_ReadOnly ) ) { |
1957 | setCaption( i18n("Error open file") ); | 1959 | setCaption( i18n("Error open file") ); |
1958 | delete mSyncActionDialog; | 1960 | delete mSyncActionDialog; |
1959 | mSyncActionDialog = 0; | 1961 | mSyncActionDialog = 0; |
1960 | qDebug("error open cal file "); | 1962 | qDebug("error open cal file "); |
1961 | return ; | 1963 | return ; |
1962 | 1964 | ||
1963 | } | 1965 | } |
1964 | setCaption( i18n("Sending file...") ); | 1966 | setCaption( i18n("Sending file...") ); |
1965 | QTextStream ts( &file ); | 1967 | QTextStream ts( &file ); |
1966 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1968 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1967 | QTextStream os( socket ); | 1969 | QTextStream os( socket ); |
1968 | os.setCodec( QTextCodec::codecForName("utf8") ); | 1970 | os.setCodec( QTextCodec::codecForName("utf8") ); |
1969 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 1971 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
1970 | while ( ! ts.atEnd() ) { | 1972 | while ( ! ts.atEnd() ) { |
1971 | os << ts.readLine() << "\n"; | 1973 | os << ts.readLine() << "\n"; |
1972 | } | 1974 | } |
1973 | //os << ts.read(); | 1975 | //os << ts.read(); |
1974 | socket->close(); | 1976 | socket->close(); |
1975 | file.close(); | 1977 | file.close(); |
1976 | setCaption( i18n("File sent. Waiting to get back synced file") ); | 1978 | setCaption( i18n("File sent. Waiting to get back synced file") ); |
1977 | qDebug("file sent "); | 1979 | qDebug("file sent "); |
1978 | } | 1980 | } |
1979 | void MainWindow::getFile(QSocket* socket) | 1981 | void MainWindow::getFile(QSocket* socket) |
1980 | { | 1982 | { |
1981 | setCaption( i18n("Receiving synced file...") ); | 1983 | setCaption( i18n("Receiving synced file...") ); |
1982 | qDebug("MainWindow::sendFile(QSocket* s) "); | 1984 | qDebug("MainWindow::sendFile(QSocket* s) "); |
1983 | 1985 | ||
1984 | QString fileName = defaultFileName(); | 1986 | QString fileName = defaultFileName(); |
1985 | QFile file( fileName ); | 1987 | QFile file( fileName ); |
1986 | if (!file.open( IO_WriteOnly ) ) { | 1988 | if (!file.open( IO_WriteOnly ) ) { |
1987 | setCaption( i18n("Error open file") ); | 1989 | setCaption( i18n("Error open file") ); |
1988 | delete mSyncActionDialog; | 1990 | delete mSyncActionDialog; |
1989 | mSyncActionDialog = 0; | 1991 | mSyncActionDialog = 0; |
1990 | qDebug("error open cal file "); | 1992 | qDebug("error open cal file "); |
1991 | return ; | 1993 | return ; |
1992 | 1994 | ||
1993 | } | 1995 | } |
1994 | 1996 | ||
1995 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1997 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1996 | QTextStream ts( &file ); | 1998 | QTextStream ts( &file ); |
1997 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1999 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1998 | bool first = true; | 2000 | bool first = true; |
1999 | while ( socket->canReadLine () || first ) { | 2001 | while ( socket->canReadLine () || first ) { |
2000 | first = false; | 2002 | first = false; |
2001 | while ( socket->canReadLine () ) { | 2003 | while ( socket->canReadLine () ) { |
2002 | ts << socket->readLine (); | 2004 | ts << socket->readLine (); |
2003 | } | 2005 | } |
2004 | socket->waitForMore ( 5000 ); | 2006 | socket->waitForMore ( 5000 ); |
2005 | } | 2007 | } |
2006 | setCaption( i18n("File received - reloading calendar...") ); | 2008 | setCaption( i18n("File received - reloading calendar...") ); |
2007 | file.close(); | 2009 | file.close(); |
2008 | socket->close(); | 2010 | socket->close(); |
2009 | mView->watchSavedFile(); | 2011 | mView->watchSavedFile(); |
2010 | mView->openCalendar( defaultFileName() ); | 2012 | mView->openCalendar( defaultFileName() ); |
2011 | setCaption( i18n("Easy-Pi-Sync successful!") ); | 2013 | setCaption( i18n("Easy-Pi-Sync successful!") ); |
2012 | delete mSyncActionDialog; | 2014 | delete mSyncActionDialog; |
2013 | mSyncActionDialog = 0; | 2015 | mSyncActionDialog = 0; |
2014 | 2016 | ||
2015 | 2017 | ||
2016 | } | 2018 | } |
2017 | void MainWindow::endConnect() | 2019 | void MainWindow::endConnect() |
2018 | { | 2020 | { |
2019 | setCaption( i18n("No file received - syncing successful") ); | 2021 | setCaption( i18n("No file received - syncing successful") ); |
2020 | delete mSyncActionDialog; | 2022 | delete mSyncActionDialog; |
2021 | mSyncActionDialog = 0; | 2023 | mSyncActionDialog = 0; |
2022 | } | 2024 | } |
2023 | void MainWindow::performQuick() | 2025 | void MainWindow::performQuick() |
2024 | { | 2026 | { |
2025 | setCaption( i18n("Please input connection settings") ); | 2027 | setCaption( i18n("Please input connection settings") ); |
2026 | QString retfile = ""; | 2028 | QString retfile = ""; |
2027 | QDialog dia ( this, "input-dialog", true ); | 2029 | QDialog dia ( this, "input-dialog", true ); |
2028 | QLineEdit lab ( &dia ); | 2030 | QLineEdit lab ( &dia ); |
2029 | QVBoxLayout lay( &dia ); | 2031 | QVBoxLayout lay( &dia ); |
2030 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2032 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2031 | lay.addWidget( &label); | 2033 | lay.addWidget( &label); |
2032 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2034 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2033 | lay.setMargin(7); | 2035 | lay.setMargin(7); |
2034 | lay.setSpacing(7); | 2036 | lay.setSpacing(7); |
2035 | lay.addWidget( &lab); | 2037 | lay.addWidget( &lab); |
2036 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2038 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2037 | lay.addWidget( &label2); | 2039 | lay.addWidget( &label2); |
2038 | QLineEdit lab2 ( &dia ); | 2040 | QLineEdit lab2 ( &dia ); |
2039 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2041 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2040 | lay.addWidget( &lab2); | 2042 | lay.addWidget( &lab2); |
2041 | dia.setFixedSize( 230,200 ); | 2043 | dia.setFixedSize( 230,200 ); |
2042 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); | 2044 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); |
2043 | QPushButton pb ( "OK", &dia); | 2045 | QPushButton pb ( "OK", &dia); |
2044 | lay.addWidget( &pb ); | 2046 | lay.addWidget( &pb ); |
2045 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2047 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2046 | dia.show(); | 2048 | dia.show(); |
2047 | int res = dia.exec(); | 2049 | int res = dia.exec(); |
2048 | if ( !res ) { | 2050 | if ( !res ) { |
2049 | setCaption( i18n("Syncing cancelled!") ); | 2051 | setCaption( i18n("Syncing cancelled!") ); |
2050 | return; | 2052 | return; |
2051 | } | 2053 | } |
2052 | dia.hide(); | 2054 | dia.hide(); |
2053 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2055 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2054 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2056 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2055 | qApp->processEvents(); | 2057 | qApp->processEvents(); |
2056 | performQuickQuick(); | 2058 | performQuickQuick(); |
2057 | } | 2059 | } |
2058 | 2060 | ||
2059 | void MainWindow::performQuickQuick() | 2061 | void MainWindow::performQuickQuick() |
2060 | { | 2062 | { |
2061 | // setCaption( i18n("") ); | 2063 | // setCaption( i18n("") ); |
2062 | 2064 | ||
2063 | bool ok; | 2065 | bool ok; |
2064 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2066 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2065 | if ( ! ok ) { | 2067 | if ( ! ok ) { |
2066 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2068 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2067 | return; | 2069 | return; |
2068 | } | 2070 | } |
2069 | if ( mCommandSocket ) | 2071 | if ( mCommandSocket ) |
2070 | delete mCommandSocket; | 2072 | delete mCommandSocket; |
2071 | mCommandSocket = new QSocket( this ); | 2073 | mCommandSocket = new QSocket( this ); |
2072 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | 2074 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); |
2073 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2075 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2074 | mCommandSocket->connectToHost( host, port ); | 2076 | mCommandSocket->connectToHost( host, port ); |
2075 | QTextStream os( mCommandSocket ); | 2077 | QTextStream os( mCommandSocket ); |
2076 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2078 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2077 | os << "GET\r\n"; | 2079 | os << "GET\r\n"; |
2078 | setCaption( i18n("Sending request for remote file ...") ); | 2080 | setCaption( i18n("Sending request for remote file ...") ); |
2079 | 2081 | ||
2080 | } | 2082 | } |
2081 | void MainWindow::readFileFromSocket() | 2083 | void MainWindow::readFileFromSocket() |
2082 | { | 2084 | { |
2083 | setCaption( i18n("Receiving remote file ...") ); | 2085 | setCaption( i18n("Receiving remote file ...") ); |
2084 | qDebug("MainWindow::readFileFromSocket() "); | 2086 | qDebug("MainWindow::readFileFromSocket() "); |
2085 | QString fileName; | 2087 | QString fileName; |
2086 | #ifdef _WIN32_ | 2088 | #ifdef _WIN32_ |
2087 | fileName = defaultFileName() +"sync"; | 2089 | fileName = defaultFileName() +"sync"; |
2088 | #else | 2090 | #else |
2089 | fileName = "/tmp/kopitempfile.ics"; | 2091 | fileName = "/tmp/kopitempfile.ics"; |
2090 | #endif | 2092 | #endif |
2091 | QFile file( fileName ); | 2093 | QFile file( fileName ); |
2092 | if (!file.open( IO_WriteOnly ) ) { | 2094 | if (!file.open( IO_WriteOnly ) ) { |
2093 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2095 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2094 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); | 2096 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); |
2095 | return ; | 2097 | return ; |
2096 | } | 2098 | } |
2097 | 2099 | ||
2098 | //QTextStream os2( mCommandSocket ); | 2100 | //QTextStream os2( mCommandSocket ); |
2099 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2101 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2100 | 2102 | ||
2101 | QTextStream ts( &file ); | 2103 | QTextStream ts( &file ); |
2102 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2104 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2103 | bool first = true; | 2105 | bool first = true; |
2104 | while ( mCommandSocket->canReadLine () || first) { | 2106 | while ( mCommandSocket->canReadLine () || first) { |
2105 | first = false; | 2107 | first = false; |
2106 | while ( mCommandSocket->canReadLine () ) { | 2108 | while ( mCommandSocket->canReadLine () ) { |
2107 | ts << mCommandSocket->readLine (); | 2109 | ts << mCommandSocket->readLine (); |
2108 | } | 2110 | } |
2109 | mCommandSocket->waitForMore ( 5000 ); | 2111 | mCommandSocket->waitForMore ( 5000 ); |
2110 | } | 2112 | } |
2111 | file.close(); | 2113 | file.close(); |
2112 | mCommandSocket->close(); | 2114 | mCommandSocket->close(); |
2113 | delete mCommandSocket; | 2115 | delete mCommandSocket; |
2114 | setCaption( i18n("Remote file saved to temp file.") ); | 2116 | setCaption( i18n("Remote file saved to temp file.") ); |
2115 | mCommandSocket = 0; | 2117 | mCommandSocket = 0; |
2116 | mCurrentSyncProfile = 2 ; // last file | 2118 | mCurrentSyncProfile = 2 ; // last file |
2117 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2119 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2118 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2120 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2119 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2121 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2120 | KSyncProfile* temp = new KSyncProfile (); | 2122 | KSyncProfile* temp = new KSyncProfile (); |
2121 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2123 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2122 | temp->readConfig(&config); | 2124 | temp->readConfig(&config); |
2123 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2125 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2124 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2126 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2125 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2127 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2126 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2128 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2127 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2129 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2128 | if ( temp->getWriteBackFuture() ) | 2130 | if ( temp->getWriteBackFuture() ) |
2129 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2131 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2130 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2132 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2131 | 2133 | ||
2132 | setCaption( i18n("Remote file saved to temp file.") ); | 2134 | setCaption( i18n("Remote file saved to temp file.") ); |
2133 | if ( ! syncWithFile( fileName , true ) ) { | 2135 | if ( ! syncWithFile( fileName , true ) ) { |
2134 | setCaption( i18n("Syncing failed.") ); | 2136 | setCaption( i18n("Syncing failed.") ); |
2135 | qDebug("Syncing failed "); | 2137 | qDebug("Syncing failed "); |
2136 | return; | 2138 | return; |
2137 | } | 2139 | } |
2138 | 2140 | ||
2139 | mCommandSocket = new QSocket( this ); | 2141 | mCommandSocket = new QSocket( this ); |
2140 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2142 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2141 | mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2143 | mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2142 | 2144 | ||
2143 | QFile file2( fileName ); | 2145 | QFile file2( fileName ); |
2144 | if (!file2.open( IO_ReadOnly ) ) { | 2146 | if (!file2.open( IO_ReadOnly ) ) { |
2145 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2147 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2146 | qDebug("error open cal file "); | 2148 | qDebug("error open cal file "); |
2147 | return ; | 2149 | return ; |
2148 | 2150 | ||
2149 | } | 2151 | } |
2150 | setCaption( i18n("Sending back synced file...") ); | 2152 | setCaption( i18n("Sending back synced file...") ); |
2151 | QTextStream ts2( &file2 ); | 2153 | QTextStream ts2( &file2 ); |
2152 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2154 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2153 | QTextStream os2( mCommandSocket ); | 2155 | QTextStream os2( mCommandSocket ); |
2154 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2156 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2155 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2157 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2156 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2158 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2157 | os2 << "PUT\r\n"; | 2159 | os2 << "PUT\r\n"; |
2158 | while ( ! ts2.atEnd() ) { | 2160 | while ( ! ts2.atEnd() ) { |
2159 | os2 << ts2.readLine() << "\n"; | 2161 | os2 << ts2.readLine() << "\n"; |
2160 | } | 2162 | } |
2161 | } else { | 2163 | } else { |
2162 | os2 << "STOP\r\n"; | 2164 | os2 << "STOP\r\n"; |
2163 | } | 2165 | } |
2164 | mCommandSocket->close(); | 2166 | mCommandSocket->close(); |
2165 | file.close(); | 2167 | file.close(); |
2166 | delete mCommandSocket; | 2168 | delete mCommandSocket; |
2167 | mCommandSocket = 0; | 2169 | mCommandSocket = 0; |
2168 | qDebug("Syncing succesful! "); | 2170 | qDebug("Syncing succesful! "); |
2169 | setCaption( i18n("Easy-Pi-Sync succesful!") ); | 2171 | setCaption( i18n("Easy-Pi-Sync succesful!") ); |
2170 | 2172 | ||
2171 | 2173 | ||
2172 | } | 2174 | } |
2173 | 2175 | ||
2174 | void MainWindow::syncLocalFile() | 2176 | void MainWindow::syncLocalFile() |
2175 | { | 2177 | { |
2176 | 2178 | ||
2177 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2179 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2178 | 2180 | ||
2179 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2181 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2180 | if ( fn == "" ) | 2182 | if ( fn == "" ) |
2181 | return; | 2183 | return; |
2182 | //mView->setSyncDevice("local-file" ); | 2184 | //mView->setSyncDevice("local-file" ); |
2183 | if ( syncWithFile( fn, false ) ) { | 2185 | if ( syncWithFile( fn, false ) ) { |
2184 | // Event* e = mView->getLastSyncEvent(); | 2186 | // Event* e = mView->getLastSyncEvent(); |
2185 | // e->setReadOnly( false ); | 2187 | // e->setReadOnly( false ); |
2186 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2188 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2187 | // e->setReadOnly( true ); | 2189 | // e->setReadOnly( true ); |
2188 | } | 2190 | } |
2189 | 2191 | ||
2190 | } | 2192 | } |
2191 | 2193 | ||
2192 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2194 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2193 | { | 2195 | { |
2194 | bool ret = false; | 2196 | bool ret = false; |
2195 | QFileInfo info; | 2197 | QFileInfo info; |
2196 | info.setFile( fn ); | 2198 | info.setFile( fn ); |
2197 | QString mess; | 2199 | QString mess; |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 58081f6..9bb2302 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,186 +1,186 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include <libkcal/incidence.h> | 9 | #include <libkcal/incidence.h> |
10 | #include "simplealarmclient.h" | 10 | #include "simplealarmclient.h" |
11 | 11 | ||
12 | class QAction; | 12 | class QAction; |
13 | class CalendarView; | 13 | class CalendarView; |
14 | class KSyncProfile; | 14 | class KSyncProfile; |
15 | #ifdef DESKTOP_VERSION | 15 | #ifdef DESKTOP_VERSION |
16 | 16 | ||
17 | #define QPEToolBar QToolBar | 17 | #define QPEToolBar QToolBar |
18 | #define QPEMenuBar QMenuBar | 18 | #define QPEMenuBar QMenuBar |
19 | #endif | 19 | #endif |
20 | class QPEToolBar; | 20 | class QPEToolBar; |
21 | #include <qserversocket.h> | 21 | #include <qserversocket.h> |
22 | #include <qsocket.h> | 22 | #include <qsocket.h> |
23 | #include <qnetworkprotocol.h> | 23 | #include <qnetworkprotocol.h> |
24 | 24 | ||
25 | class KServerSocket : public QServerSocket | 25 | class KServerSocket : public QServerSocket |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) : | 30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) : |
31 | QServerSocket( port, backlog, parent, name ){;}; | 31 | QServerSocket( port, backlog, parent, name ){;}; |
32 | void newConnection ( int socket ) | 32 | void newConnection ( int socket ) |
33 | { | 33 | { |
34 | qDebug("KServerSocket:New connection %d ", socket); | 34 | qDebug("KServerSocket:New connection %d ", socket); |
35 | QSocket* s = new QSocket( this ); | 35 | QSocket* s = new QSocket( this ); |
36 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | 36 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); |
37 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 37 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
38 | s->setSocket( socket ); | 38 | s->setSocket( socket ); |
39 | } | 39 | } |
40 | 40 | ||
41 | signals: | 41 | signals: |
42 | void sendFile(QSocket*); | 42 | void sendFile(QSocket*); |
43 | void getFile(QSocket*); | 43 | void getFile(QSocket*); |
44 | void endConnect(); | 44 | void endConnect(); |
45 | private slots: | 45 | private slots: |
46 | void discardClient() | 46 | void discardClient() |
47 | { | 47 | { |
48 | QSocket* socket = (QSocket*)sender(); | 48 | QSocket* socket = (QSocket*)sender(); |
49 | delete socket; | 49 | delete socket; |
50 | emit endConnect(); | 50 | //emit endConnect(); |
51 | } | 51 | } |
52 | void readClient() | 52 | void readClient() |
53 | { | 53 | { |
54 | qDebug("readClient() "); | 54 | qDebug("readClient() "); |
55 | QSocket* socket = (QSocket*)sender(); | 55 | QSocket* socket = (QSocket*)sender(); |
56 | if ( socket->canReadLine() ) { | 56 | if ( socket->canReadLine() ) { |
57 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | 57 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); |
58 | if ( tokens[0] == "GET" ) { | 58 | if ( tokens[0] == "GET" ) { |
59 | emit sendFile( socket ); | 59 | emit sendFile( socket ); |
60 | } | 60 | } |
61 | if ( tokens[0] == "PUT" ) { | 61 | if ( tokens[0] == "PUT" ) { |
62 | emit getFile( socket ); | 62 | emit getFile( socket ); |
63 | } | 63 | } |
64 | if ( tokens[0] == "STOP" ) { | 64 | if ( tokens[0] == "STOP" ) { |
65 | emit endConnect(); | 65 | emit endConnect(); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | } | 68 | } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | namespace KCal { | 72 | namespace KCal { |
73 | class CalendarLocal; | 73 | class CalendarLocal; |
74 | } | 74 | } |
75 | 75 | ||
76 | using namespace KCal; | 76 | using namespace KCal; |
77 | 77 | ||
78 | class MainWindow : public QMainWindow | 78 | class MainWindow : public QMainWindow |
79 | { | 79 | { |
80 | Q_OBJECT | 80 | Q_OBJECT |
81 | public: | 81 | public: |
82 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 82 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
83 | ~MainWindow(); | 83 | ~MainWindow(); |
84 | public slots: | 84 | public slots: |
85 | virtual void showMaximized (); | 85 | virtual void showMaximized (); |
86 | void configureAgenda( int ); | 86 | void configureAgenda( int ); |
87 | void recieve( const QCString& msg, const QByteArray& data ); | 87 | void recieve( const QCString& msg, const QByteArray& data ); |
88 | static QString defaultFileName(); | 88 | static QString defaultFileName(); |
89 | static QString resourcePath(); | 89 | static QString resourcePath(); |
90 | protected slots: | 90 | protected slots: |
91 | void setCaptionToDates(); | 91 | void setCaptionToDates(); |
92 | int ringSync(); | 92 | int ringSync(); |
93 | void multiSync( bool askforPrefs = false ); | 93 | void multiSync( bool askforPrefs = false ); |
94 | void about(); | 94 | void about(); |
95 | void licence(); | 95 | void licence(); |
96 | void faq(); | 96 | void faq(); |
97 | void usertrans(); | 97 | void usertrans(); |
98 | void features(); | 98 | void features(); |
99 | void synchowto(); | 99 | void synchowto(); |
100 | void whatsNew(); | 100 | void whatsNew(); |
101 | void keyBindings(); | 101 | void keyBindings(); |
102 | void aboutAutoSaving();; | 102 | void aboutAutoSaving();; |
103 | void aboutKnownBugs(); | 103 | void aboutKnownBugs(); |
104 | 104 | ||
105 | void processIncidenceSelection( Incidence * ); | 105 | void processIncidenceSelection( Incidence * ); |
106 | 106 | ||
107 | void importQtopia(); | 107 | void importQtopia(); |
108 | void importBday(); | 108 | void importBday(); |
109 | void importOL(); | 109 | void importOL(); |
110 | void importIcal(); | 110 | void importIcal(); |
111 | void importFile( QString, bool ); | 111 | void importFile( QString, bool ); |
112 | void quickImportIcal(); | 112 | void quickImportIcal(); |
113 | 113 | ||
114 | void slotModifiedChanged( bool ); | 114 | void slotModifiedChanged( bool ); |
115 | 115 | ||
116 | void save(); | 116 | void save(); |
117 | void configureToolBar( int ); | 117 | void configureToolBar( int ); |
118 | void printSel(); | 118 | void printSel(); |
119 | void printCal(); | 119 | void printCal(); |
120 | void saveCalendar(); | 120 | void saveCalendar(); |
121 | void loadCalendar(); | 121 | void loadCalendar(); |
122 | void exportVCalendar(); | 122 | void exportVCalendar(); |
123 | void fillFilterMenu(); | 123 | void fillFilterMenu(); |
124 | void selectFilter( int ); | 124 | void selectFilter( int ); |
125 | 125 | ||
126 | void slotSyncMenu( int ); | 126 | void slotSyncMenu( int ); |
127 | void syncSSH(); | 127 | void syncSSH(); |
128 | void confSync(); | 128 | void confSync(); |
129 | void syncSharp(); | 129 | void syncSharp(); |
130 | void syncPhone(); | 130 | void syncPhone(); |
131 | void syncLocalFile(); | 131 | void syncLocalFile(); |
132 | bool syncWithFile( QString, bool ); | 132 | bool syncWithFile( QString, bool ); |
133 | void quickSyncLocalFile(); | 133 | void quickSyncLocalFile(); |
134 | 134 | ||
135 | 135 | ||
136 | protected: | 136 | protected: |
137 | void displayText( QString, QString); | 137 | void displayText( QString, QString); |
138 | void displayFile( QString, QString); | 138 | void displayFile( QString, QString); |
139 | 139 | ||
140 | void enableIncidenceActions( bool ); | 140 | void enableIncidenceActions( bool ); |
141 | 141 | ||
142 | private slots: | 142 | private slots: |
143 | void fillSyncMenu(); | 143 | void fillSyncMenu(); |
144 | void sendFile(QSocket* s); | 144 | void sendFile(QSocket* s); |
145 | void getFile(QSocket* socket); | 145 | void getFile(QSocket* socket); |
146 | void readFileFromSocket(); | 146 | void readFileFromSocket(); |
147 | void endConnect(); | 147 | void endConnect(); |
148 | private: | 148 | private: |
149 | QSocket* mCommandSocket; | 149 | QSocket* mCommandSocket; |
150 | KServerSocket * mServerSocket; | 150 | KServerSocket * mServerSocket; |
151 | bool mClosed; | 151 | bool mClosed; |
152 | void saveOnClose(); | 152 | void saveOnClose(); |
153 | int mCurrentSyncProfile; | 153 | int mCurrentSyncProfile; |
154 | void enableQuick(); | 154 | void enableQuick(); |
155 | void performQuick(); | 155 | void performQuick(); |
156 | void performQuickQuick(); | 156 | void performQuickQuick(); |
157 | void syncRemote( KSyncProfile* , bool ask = true); | 157 | void syncRemote( KSyncProfile* , bool ask = true); |
158 | bool mFlagKeyPressed; | 158 | bool mFlagKeyPressed; |
159 | bool mBlockAtStartup; | 159 | bool mBlockAtStartup; |
160 | QPEToolBar *iconToolBar; | 160 | QPEToolBar *iconToolBar; |
161 | void initActions(); | 161 | void initActions(); |
162 | void setDefaultPreferences(); | 162 | void setDefaultPreferences(); |
163 | void keyPressEvent ( QKeyEvent * ) ; | 163 | void keyPressEvent ( QKeyEvent * ) ; |
164 | void keyReleaseEvent ( QKeyEvent * ) ; | 164 | void keyReleaseEvent ( QKeyEvent * ) ; |
165 | QPopupMenu *configureToolBarMenu; | 165 | QPopupMenu *configureToolBarMenu; |
166 | QPopupMenu *selectFilterMenu; | 166 | QPopupMenu *selectFilterMenu; |
167 | QPopupMenu *configureAgendaMenu, *syncMenu; | 167 | QPopupMenu *configureAgendaMenu, *syncMenu; |
168 | CalendarLocal *mCalendar; | 168 | CalendarLocal *mCalendar; |
169 | CalendarView *mView; | 169 | CalendarView *mView; |
170 | QString getPassword(); | 170 | QString getPassword(); |
171 | QAction *mNewSubTodoAction; | 171 | QAction *mNewSubTodoAction; |
172 | 172 | ||
173 | QAction *mShowAction; | 173 | QAction *mShowAction; |
174 | QAction *mEditAction; | 174 | QAction *mEditAction; |
175 | QAction *mDeleteAction; | 175 | QAction *mDeleteAction; |
176 | void closeEvent( QCloseEvent* ce ); | 176 | void closeEvent( QCloseEvent* ce ); |
177 | SimpleAlarmClient mAlarmClient; | 177 | SimpleAlarmClient mAlarmClient; |
178 | QTimer mSaveTimer; | 178 | QTimer mSaveTimer; |
179 | bool mBlockSaveFlag; | 179 | bool mBlockSaveFlag; |
180 | bool mCalendarModifiedFlag; | 180 | bool mCalendarModifiedFlag; |
181 | QPixmap loadPixmap( QString ); | 181 | QPixmap loadPixmap( QString ); |
182 | QDialog * mSyncActionDialog; | 182 | QDialog * mSyncActionDialog; |
183 | }; | 183 | }; |
184 | 184 | ||
185 | 185 | ||
186 | #endif | 186 | #endif |