~neon/juk/master

240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
1
/*
1785 by Michael Pyne
Krazy fix: Fix missing copyright tags. I had to retrieve svn history to add the
2
 * tagguesserconfigdlg.cpp - Copyright (c) 2003 Frerich Raabe <raabe@kde.org>
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 2 of the License, or
7
 * (at your option) any later version.
8
 */
1787 by Michael Pyne
Reorganize headers to fix a ton of Krazy reports. At first I thought it was just
9
#include "tagguesserconfigdlg.h"
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
10
#include "tagguesser.h"
11
1768 by Pino Toscano
less qt3_support
12
#include <kicon.h>
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
13
#include <klocale.h>
14
#include <kpushbutton.h>
1444 by Scott Wheeler
Send a return key press to the listview lineedit on pressing "ok" so that
15
#include <klineedit.h>
16
#include <kapplication.h>
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
17
1530 by Laurent Montel
qt3to4 + my script
18
#include <QKeyEvent>
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
19
#include <QStringListModel>
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
20
21
TagGuesserConfigDlg::TagGuesserConfigDlg(QWidget *parent, const char *name)
1626 by Richard Lärkäng
KDialogBase -> KDialog
22
    : KDialog(parent)
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
23
{
1626 by Richard Lärkäng
KDialogBase -> KDialog
24
    setObjectName(name);
25
    setModal(true);
26
    setCaption(i18n("Tag Guesser Configuration"));
27
    setButtons(Ok | Cancel);
28
    setDefaultButton(Ok);
1635 by Laurent Montel
Port++
29
    showButtonSeparator(true);
1626 by Richard Lärkäng
KDialogBase -> KDialog
30
1692 by Laurent Montel
Port to uic4
31
    m_child = new TagGuesserConfigDlgWidget(this);
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
32
    setMainWidget(m_child);
33
1768 by Pino Toscano
less qt3_support
34
    m_child->bMoveUp->setIcon(KIcon("arrow-up"));
35
    m_child->bMoveDown->setIcon(KIcon("arrow-down"));
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
36
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
37
    m_tagSchemeModel = new QStringListModel(m_child->lvSchemes);
38
    m_child->lvSchemes->setModel(m_tagSchemeModel);
39
    m_child->lvSchemes->setHeaderHidden(true);
40
    m_tagSchemeModel->setStringList(TagGuesser::schemeStrings());
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
41
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
42
    connect(m_child->lvSchemes, SIGNAL(clicked(QModelIndex)), this, SLOT(slotCurrentChanged(QModelIndex)));
253 by Frerich Raabe
- Made the move up / down buttons do something
43
    connect(m_child->bMoveUp, SIGNAL(clicked()), this, SLOT(slotMoveUpClicked()));
44
    connect(m_child->bMoveDown, SIGNAL(clicked()), this, SLOT(slotMoveDownClicked()));
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
45
    connect(m_child->bAdd, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
46
    connect(m_child->bModify, SIGNAL(clicked()), this, SLOT(slotModifyClicked()));
47
    connect(m_child->bRemove, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
242 by Frerich Raabe
- I like it a little bigger
48
49
    resize( 400, 300 );
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
50
}
51
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
52
void TagGuesserConfigDlg::slotCurrentChanged(QModelIndex item)
53
{
54
    m_child->bRemove->setEnabled(m_tagSchemeModel->rowCount() != 0);
55
56
    // Ensure up/down buttons are appropriately enabled.
57
58
    if (!m_tagSchemeModel->rowCount() || item == m_tagSchemeModel->index(0, 0, QModelIndex()))
59
        m_child->bMoveUp->setEnabled(false);
60
    else
61
        m_child->bMoveUp->setEnabled(true);
62
63
    if (!m_tagSchemeModel->rowCount() || item == m_tagSchemeModel->index(m_tagSchemeModel->rowCount(QModelIndex())-1, 0, QModelIndex()))
64
        m_child->bMoveDown->setEnabled(false);
65
    else
66
        m_child->bMoveDown->setEnabled(true);
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
67
}
68
253 by Frerich Raabe
- Made the move up / down buttons do something
69
void TagGuesserConfigDlg::slotMoveUpClicked()
70
{
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
71
    QModelIndex currentItem = m_child->lvSchemes->currentIndex();
72
    int row = currentItem.row();
73
74
    m_tagSchemeModel->insertRow(row - 1); // Insert in front of item above
75
    row++; // Now we're one row down
76
77
    QModelIndex newItem = m_tagSchemeModel->index(row - 2, 0);
78
79
    // Copy over, then delete old item
80
    currentItem = m_tagSchemeModel->index(row, 0);
81
    m_tagSchemeModel->setData(newItem, m_tagSchemeModel->data(currentItem, Qt::DisplayRole), Qt::DisplayRole);
82
    m_tagSchemeModel->removeRow(row);
83
84
    m_child->lvSchemes->setCurrentIndex(newItem);
85
    slotCurrentChanged(newItem);
253 by Frerich Raabe
- Made the move up / down buttons do something
86
}
87
88
void TagGuesserConfigDlg::slotMoveDownClicked()
89
{
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
90
    QModelIndex currentItem = m_child->lvSchemes->currentIndex();
91
    int row = currentItem.row();
92
93
    m_tagSchemeModel->insertRow(row + 2); // Insert in front of 2 items below
94
95
    QModelIndex newItem = m_tagSchemeModel->index(row + 2, 0);
96
97
    // Copy over, then delete old item
98
    currentItem = m_tagSchemeModel->index(row, 0);
99
    m_tagSchemeModel->setData(newItem, m_tagSchemeModel->data(currentItem, Qt::DisplayRole), Qt::DisplayRole);
100
    m_tagSchemeModel->removeRow(row);
101
102
    newItem = m_tagSchemeModel->index(row + 1, 0);
103
    m_child->lvSchemes->setCurrentIndex(newItem);
104
    slotCurrentChanged(newItem);
253 by Frerich Raabe
- Made the move up / down buttons do something
105
}
106
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
107
void TagGuesserConfigDlg::slotAddClicked()
108
{
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
109
    m_tagSchemeModel->insertRow(0, QModelIndex());
110
    m_child->lvSchemes->setCurrentIndex(m_tagSchemeModel->index(0, 0, QModelIndex()));
111
    m_child->lvSchemes->edit(m_child->lvSchemes->currentIndex());
112
    slotCurrentChanged(m_child->lvSchemes->currentIndex());
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
113
}
114
115
void TagGuesserConfigDlg::slotModifyClicked()
116
{
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
117
    m_child->lvSchemes->edit(m_child->lvSchemes->currentIndex());
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
118
}
119
120
void TagGuesserConfigDlg::slotRemoveClicked()
121
{
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
122
    m_tagSchemeModel->removeRow(m_child->lvSchemes->currentIndex().row(), QModelIndex());
123
    slotCurrentChanged(m_child->lvSchemes->currentIndex());
240 by Frerich Raabe
- The filename schemes used by the tag guesser are configurable now
124
}
125
2087 by Michael Pyne
More kde3support-- patches from Georg Grabler. This ports the tag guesser config dialog
126
void TagGuesserConfigDlg::accept()
127
{
128
    TagGuesser::setSchemeStrings(m_tagSchemeModel->stringList());
129
    KDialog::accept();
130
}
1562 by Michael Pyne
Since we're standardizing the source style, figured I'd throw in the Big Huge Vim Modeline
131
132
// vim: set et sw=4 tw=0 sta: