summaryrefslogtreecommitdiffstats
path: root/amarok/src/tagguesserconfigdialog.ui.h
blob: 88f5d0b66688420799401258b5f3d4ecc0243455 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
  (c) 2005 Alexandre Oliveira <aleprj@gmail.com>
  (c) 2003 Frerich Raabe <raabe@kde.org>

 ***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/


/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** TQt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/

#include "tagguesser.h"

#include <tqevent.h>

#include <tdeapplication.h>
#include <klineedit.h>
#include <kiconloader.h>


void TagGuesserConfigDialog::init()
{
    setCaption( i18n( "Guess By Filename Configuration" ) );
    lvSchemes->setItemsRenameable( true );
    lvSchemes->setSorting( -1 );
    lvSchemes->setDefaultRenameAction( TQListView::Accept );
    bMoveUp->setIconSet( SmallIconSet( "1uparrow" ) );
    bMoveDown->setIconSet( SmallIconSet( "1downarrow" ) );

    const TQStringList schemes = TagGuesser::schemeStrings();
    TQStringList::ConstIterator it = schemes.begin();
    TQStringList::ConstIterator end = schemes.end();
    for ( ; it != end; ++it ) {
        TDEListViewItem *item = new TDEListViewItem( lvSchemes, *it );
        item->moveItem( lvSchemes->lastItem() );
    }

    connect( lvSchemes, TQT_SIGNAL( currentChanged( TQListViewItem * ) ),
            this, TQT_SLOT( slotCurrentChanged( TQListViewItem * ) ) );
    connect( lvSchemes, TQT_SIGNAL( doubleClicked( TQListViewItem *, const TQPoint &, int ) ),
            this, TQT_SLOT( slotRenameItem( TQListViewItem *, const TQPoint &, int ) ) );
    connect( bMoveUp, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotMoveUpClicked() ) );
    connect( bMoveDown, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotMoveDownClicked() ) );
    connect( bAdd, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotAddClicked() ) );
    connect( bModify, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotModifyClicked() ) );
    connect( bRemove, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotRemoveClicked() ) );
    connect( bOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
    connect( bCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );

    lvSchemes->setSelected( lvSchemes->firstChild(), true );
    slotCurrentChanged( lvSchemes->currentItem() );
    resize( 400, 300 );
}

void TagGuesserConfigDialog::slotCurrentChanged(TQListViewItem *item)
{
    bMoveUp->setEnabled( item != 0 && item->itemAbove() != 0 );
    bMoveDown->setEnabled( item != 0 && item->itemBelow() != 0 );
    bModify->setEnabled( item != 0 );
    bRemove->setEnabled( item != 0 );
}

void TagGuesserConfigDialog::accept()
{
    if(lvSchemes->renameLineEdit()) {
        TQKeyEvent returnKeyPress(TQEvent::KeyPress, Key_Return, 0, 0);
        TDEApplication::sendEvent( lvSchemes->renameLineEdit(), &returnKeyPress );
    }

    TQStringList schemes;
    for ( TQListViewItem *it = lvSchemes->firstChild(); it; it = it->nextSibling() )
        schemes += it->text(0);
    TagGuesser::setSchemeStrings( schemes );
    KDialog::accept();
}


void TagGuesserConfigDialog::reject()
{
    KDialog::reject();
}


void TagGuesserConfigDialog::slotRenameItem(TQListViewItem *item, const TQPoint &, int c)
{
    lvSchemes->rename(item, c);
}

void TagGuesserConfigDialog::slotMoveUpClicked()
{
    TQListViewItem *item = lvSchemes->currentItem();
    if( item->itemAbove() == lvSchemes->firstChild() )
        item->itemAbove()->moveItem(item);
    else
      item->moveItem(item->itemAbove()->itemAbove());
    lvSchemes->ensureItemVisible(item);
    slotCurrentChanged(item);
}

void TagGuesserConfigDialog::slotMoveDownClicked()
{
    TQListViewItem *item = lvSchemes->currentItem();
    item->moveItem( item->itemBelow() );
    lvSchemes->ensureItemVisible(item);
    slotCurrentChanged(item);
}

void TagGuesserConfigDialog::slotAddClicked()
{
    TDEListViewItem *item = new TDEListViewItem( lvSchemes );
    lvSchemes->rename(item, 0);
}

void TagGuesserConfigDialog::slotModifyClicked()
{
    lvSchemes->rename(lvSchemes->currentItem(), 0);
}

void TagGuesserConfigDialog::slotRemoveClicked()
{
    delete lvSchemes->currentItem();
}