1 /***************************************************************************
2  *   Copyright (C) 2003 by Sébastien Laoût                                 *
3  *   slaout@linux62.org                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 #ifndef SOFTWAREIMPORTERS_H
22 #define SOFTWAREIMPORTERS_H
23 
24 #include <QDialog>
25 
26 class QString;
27 class QGroupBox;
28 class QDomElement;
29 class QRadioButton;
30 class KTextEdit;
31 class QVBoxLayout;
32 
33 class BasketScene;
34 class Note;
35 
36 /** The dialog to ask how to import hierarchical data.
37   * @author Sébastien Laoût
38   */
39 class TreeImportDialog : public QDialog
40 {
41     Q_OBJECT
42 public:
43     TreeImportDialog(QWidget *parent = 0);
44     ~TreeImportDialog();
45     int choice();
46 private:
47     QGroupBox *m_choices;
48     QVBoxLayout* m_choiceLayout;
49     QRadioButton *m_hierarchy_choice;
50     QRadioButton *m_separate_baskets_choice;
51     QRadioButton *m_one_basket_choice;
52 };
53 
54 /** The dialog to ask how to import text files.
55   * @author Sébastien Laoût
56   */
57 class TextFileImportDialog : public QDialog
58 {
59     Q_OBJECT
60 public:
61     TextFileImportDialog(QWidget *parent = 0);
62     ~TextFileImportDialog();
63     QString separator();
64 protected slots:
65     void customSeparatorChanged();
66 private:
67     QGroupBox *m_choices;
68     QVBoxLayout* m_choiceLayout;
69     QRadioButton  *m_emptyline_choice;
70     QRadioButton  *m_newline_choice;
71     QRadioButton  *m_dash_choice;
72     QRadioButton  *m_star_choice;
73     QRadioButton  *m_all_in_one_choice;
74     QRadioButton  *m_anotherSeparator;
75     KTextEdit     *m_customSeparator;
76 };
77 
78 /** Functions that import data from other softwares.
79   * @author Sébastien Laoût
80   */
81 namespace SoftwareImporters
82 {
83 // Useful methods to design importers:
84 QString fromICS(const QString &ics);
85 QString fromTomboy(QString tomboy);
86 //! Get first of the <tags> to be used as basket name. Strip 'system:notebook:' part
87 QString getFirstTomboyTag(const QDomElement& docElem);
88 Note* insertTitledNote(BasketScene *parent, const QString &title, const QString &content, Qt::TextFormat format = Qt::PlainText, Note *parentNote = 0);
89 void finishImport(BasketScene *basket);
90 
91 // The importers in themselves:
92 void importKNotes();
93 void importKJots();
94 void importKnowIt();
95 void importTuxCards();
96 void importStickyNotes();
97 void importTomboy();
98 void importJreepadFile();
99 void importTextFile();
100 
101 //
102 void importTuxCardsNode(const QDomElement &element, BasketScene *parentBasket, Note *parentNote, int remainingHierarchy);
103 }
104 
105 #endif // SOFTWAREIMPORTERS_H
106