summaryrefslogtreecommitdiffstats
path: root/kmymoney2/dialogs/kchooseimportexportdlg.cpp
blob: 1038bf13a84597926b2366a90c3201d037cf5e22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************
                          kchooseimportexportdlg.cpp  -  description
                             -------------------
    begin                : Thu Jul 12 2001
    copyright            : (C) 2000-2001 by Michael Edwardes
    email                : mte@users.sourceforge.net
                             Javier Campos Morales <javi_c@users.sourceforge.net>
                             Felix Rodriguez <frodriguez@users.sourceforge.net>
                             John C <thetacoturtle@users.sourceforge.net>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>

#include <tqpixmap.h>

#include <tqlabel.h>
#include <tqcombobox.h>
#include <tqpushbutton.h>

#include <kglobal.h>
#include <kconfig.h>
#include <klocale.h>

#include "kchooseimportexportdlg.h"

KChooseImportExportDlg::KChooseImportExportDlg(int type, TQWidget *tqparent, const char *name )
 : KChooseImportExportDlgDecl(tqparent,name, true)
{
  TQString filename;

  if (type==0) { // import
    topLabel->setText(i18n("Please choose the type of import you wish to perform.  A simple explanation\n"
        "of the import type is available at the bottom of the screen and is updated when\n"
        "you select an item from the choice box."
        "\n\nOnce you have chosen an import type please press the OK button." ));
    promptLabel->setText(i18n("Choose import type:"));
    setCaption(i18n("Choose Import Type Dialog"));
  } else { // export
    topLabel->setText(i18n("Please choose the type of export you wish to perform.  A simple explanation\n"
        "of the export type is available at the bottom of the screen and is updated when\n"
        "you select an item from the choice box."
        "\n\nOnce you have chosen an export type please press the OK button." ));
    promptLabel->setText(i18n("Choose export type:"));
    setCaption(i18n("Choose Export Type Dialog"));
  }

  readConfig();
  slotTypeActivated(m_lastType);
  typeCombo->setCurrentItem(((m_lastType=="TQIF") ? 0 : 1));

  connect(typeCombo, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(slotTypeActivated(const TQString&)));
  connect(okButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()));
  connect(cancelButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(reject()));
}

KChooseImportExportDlg::~KChooseImportExportDlg()
{
  writeConfig();
}

void KChooseImportExportDlg::slotTypeActivated(const TQString& text)
{
  if (text=="TQIF") {
    descriptionLabel->setText(i18n("TQIF files are created by the popular accounting program Quicken.\n"
      "Another dialog will appear, if you choose this type, asking for further\n"
      "information relevant to the Quicken format."));
  } else {
    descriptionLabel->setText(i18n("The CSV type uses a comma delimeted text file that can be used by\n"
      "most popular spreadsheet programs available for Linux and other operating\n"
      "systems."));
  }
}

TQString KChooseImportExportDlg::importExportType(void)
{
  return typeCombo->currentText();
}

void KChooseImportExportDlg::readConfig(void)
{
  KConfig *config = KGlobal::config();
  config->setGroup("Last Use Settings");
  m_lastType = config->readEntry("KChooseImportExportDlg_LastType");
}

void KChooseImportExportDlg::writeConfig(void)
{
  KConfig *config = KGlobal::config();
  config->setGroup("Last Use Settings");
  config->writeEntry("KChooseImportExportDlg_LastType", typeCombo->currentText());
  config->sync();
}

#include "kchooseimportexportdlg.moc"