~ubuntu-branches/debian/sid/kxstitch/sid

« back to all changes in this revision

Viewing changes to kxstitch/addcolordialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): eric pareja
  • Date: 2005-02-19 12:37:22 UTC
  • Revision ID: james.westby@ubuntu.com-20050219123722-kt3ru1nqvllietee
Tags: upstream-0.6
ImportĀ upstreamĀ versionĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2003 by Stephen Allewell                                *
 
3
 *   stephen@mirramar.fsnet.co.uk                                          *
 
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
 
 
11
#include <qlistbox.h>
 
12
#include <qlabel.h>
 
13
#include <qpushbutton.h>
 
14
#include <kapplication.h>
 
15
#include <klocale.h>
 
16
#include "kxstitch.h"
 
17
#include "addcolordialog.h"
 
18
#include "newcolordialog.h"
 
19
#include "schememanager.h"
 
20
#include "flossscheme.h"
 
21
#include "flosslistboxitem.h"
 
22
 
 
23
AddColorDialog::AddColorDialog(QWidget *parent, QString schemeName)
 
24
  : AddColorDlg(parent,"AddColorDialog",true),
 
25
    m_schemeName(schemeName)
 
26
{
 
27
  setCaption(i18n("Add Colors"));
 
28
  SchemeName->setText(QString(i18n("Add colors from %1 scheme")).arg(schemeName));
 
29
  connect(NewColorButton,SIGNAL(clicked()),this,SLOT(slotNewColor()));
 
30
  connect(HelpButton,SIGNAL(clicked()),this,SLOT(slotContextHelp()));
 
31
}
 
32
 
 
33
AddColorDialog::~AddColorDialog()
 
34
{
 
35
  // nothing to be done
 
36
}
 
37
 
 
38
void AddColorDialog::slotContextHelp()
 
39
{
 
40
  kapp->invokeHelp("AddColorDialog");
 
41
}
 
42
 
 
43
void AddColorDialog::slotNewColor()
 
44
{
 
45
  Floss* floss = NewColorDialog::getFloss(m_schemeName);
 
46
  if (floss)
 
47
  {
 
48
    m_addedColors.append(floss);
 
49
    new FlossListBoxItem(ColorList, floss);
 
50
  }
 
51
}
 
52
 
 
53
void AddColorDialog::accept()
 
54
{
 
55
  FlossScheme* scheme = ((KXStitchApplication*)kapp)->scheme(m_schemeName);
 
56
  if (!m_addedColors.isEmpty())
 
57
  {
 
58
    for (Floss* f = m_addedColors.first() ; f ; f = m_addedColors.next())
 
59
      scheme->addFloss(f);
 
60
    ((KXStitchApplication*)kapp)->writeScheme(m_schemeName);
 
61
  }
 
62
  QDialog::accept();
 
63
}
 
64
 
 
65
void AddColorDialog::reject()
 
66
{
 
67
  m_addedColors.setAutoDelete(true);
 
68
  QDialog::reject();
 
69
}