Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
libkdepim
Commits
5ae27f2c
Commit
5ae27f2c
authored
Sep 09, 2020
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove uistatesaver
parent
c9029dd4
Pipeline
#33641
failed with stage
in 6 minutes and 27 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
165 deletions
+0
-165
src/libkdepim/CMakeLists.txt
src/libkdepim/CMakeLists.txt
+0
-2
src/libkdepim/misc/uistatesaver.cpp
src/libkdepim/misc/uistatesaver.cpp
+0
-112
src/libkdepim/misc/uistatesaver.h
src/libkdepim/misc/uistatesaver.h
+0
-51
No files found.
src/libkdepim/CMakeLists.txt
View file @
5ae27f2c
...
...
@@ -28,7 +28,6 @@ set(kdepim_widgets_LIB_SRCS
)
set
(
kdepim_misc_LIB_SRCS
misc/uistatesaver.cpp
misc/lineeditcatchreturnkey.cpp
)
...
...
@@ -96,7 +95,6 @@ ecm_generate_headers(libkdepim_Camelcasewidgets_HEADERS
ecm_generate_headers
(
libkdepim_Camelcasemisc_HEADERS
HEADER_NAMES
UiStateSaver
LineEditCatchReturnKey
REQUIRED_HEADERS libkdepim_misc_HEADERS
PREFIX Libkdepim
...
...
src/libkdepim/misc/uistatesaver.cpp
deleted
100644 → 0
View file @
c9029dd4
/*
SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "uistatesaver.h"
#include <KConfigGroup>
#include <QComboBox>
#include <QHeaderView>
#include <QSplitter>
#include <QTabWidget>
#include <QTreeView>
using
namespace
KPIM
;
struct
Saver
{
static
void
process
(
QSplitter
*
splitter
,
KConfigGroup
&
config
)
{
if
(
splitter
->
sizes
().
count
(
0
)
==
splitter
->
sizes
().
count
())
{
return
;
}
config
.
writeEntry
(
splitter
->
objectName
(),
splitter
->
sizes
());
}
static
void
process
(
QTabWidget
*
tab
,
KConfigGroup
&
config
)
{
config
.
writeEntry
(
tab
->
objectName
(),
tab
->
currentIndex
());
}
static
void
process
(
QTreeView
*
tv
,
KConfigGroup
&
config
)
{
config
.
writeEntry
(
tv
->
objectName
(),
tv
->
header
()
->
saveState
());
}
static
void
process
(
QComboBox
*
cb
,
KConfigGroup
&
config
)
{
config
.
writeEntry
(
cb
->
objectName
(),
cb
->
currentIndex
());
}
};
struct
Restorer
{
static
void
process
(
QSplitter
*
splitter
,
const
KConfigGroup
&
config
)
{
const
QList
<
int
>
sizes
=
config
.
readEntry
(
splitter
->
objectName
(),
QList
<
int
>
());
if
(
!
sizes
.
isEmpty
()
&&
splitter
->
count
()
==
sizes
.
count
()
&&
sizes
.
count
()
!=
sizes
.
count
(
0
))
{
splitter
->
setSizes
(
sizes
);
}
}
static
void
process
(
QTabWidget
*
tab
,
const
KConfigGroup
&
config
)
{
const
int
index
=
config
.
readEntry
(
tab
->
objectName
(),
-
1
);
if
(
index
>=
0
&&
index
<
tab
->
count
())
{
tab
->
setCurrentIndex
(
index
);
}
}
static
void
process
(
QTreeView
*
tv
,
const
KConfigGroup
&
config
)
{
const
QByteArray
state
=
config
.
readEntry
(
tv
->
objectName
(),
QByteArray
());
if
(
!
state
.
isEmpty
())
{
tv
->
header
()
->
restoreState
(
state
);
}
}
static
void
process
(
QComboBox
*
cb
,
const
KConfigGroup
&
config
)
{
const
int
index
=
config
.
readEntry
(
cb
->
objectName
(),
-
1
);
if
(
index
>=
0
&&
index
<
cb
->
count
())
{
cb
->
setCurrentIndex
(
index
);
}
}
};
#define PROCESS_TYPE(T) \
{ \
T *obj = qobject_cast<T *>(w); \
if (obj) { \
Op::process(obj, config); \
continue; \
} \
}
template
<
typename
Op
,
typename
Config
>
static
void
processWidgets
(
QWidget
*
widget
,
Config
config
)
{
QList
<
QWidget
*>
widgets
=
widget
->
findChildren
<
QWidget
*>
();
widgets
<<
widget
;
for
(
QWidget
*
w
:
qAsConst
(
widgets
))
{
if
(
w
->
objectName
().
isEmpty
())
{
continue
;
}
PROCESS_TYPE
(
QSplitter
);
PROCESS_TYPE
(
QTabWidget
);
PROCESS_TYPE
(
QTreeView
);
PROCESS_TYPE
(
QComboBox
);
}
}
#undef PROCESS_TYPE
void
UiStateSaver
::
saveState
(
QWidget
*
widget
,
KConfigGroup
&
config
)
{
processWidgets
<
Saver
,
KConfigGroup
&>
(
widget
,
config
);
}
void
UiStateSaver
::
restoreState
(
QWidget
*
widget
,
const
KConfigGroup
&
config
)
{
processWidgets
<
Restorer
,
const
KConfigGroup
&>
(
widget
,
config
);
}
src/libkdepim/misc/uistatesaver.h
deleted
100644 → 0
View file @
c9029dd4
/*
SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef UISTATESAVER_H
#define UISTATESAVER_H
#include "kdepim_export.h"
class
QWidget
;
class
KConfigGroup
;
namespace
KPIM
{
/**
* @short Methods to save and restore the UI state of an application.
*
* This namespace provides methods that automatically save and restore
* the state of various UI elements to/from a configuration group.
*
* The following widgets are supported so far:
* - QSplitter
* - QTabWidget
* - QTreeView
* - QComboBox
*
* @note The widgets need to have set an objectName, otherwise they are ignored
* on processing.
*
* @author Volker Krause <vkrause@kde.org>
* @since 4.5
*/
namespace
UiStateSaver
{
/**
* Saves the state of @p widget and all its sub-widgets to @p config.
* @param widget The top-level widget which state should be saved.
* @param config The config group the settings should be written to.
*/
KDEPIM_EXPORT
void
saveState
(
QWidget
*
widget
,
KConfigGroup
&
config
);
/**
* Restores the UI state of @p widget and all its sub-widgets from @p config.
* @param widget The top-level widget which state should be restored.
* @param config The config gorup the settings should be read from.
*/
KDEPIM_EXPORT
void
restoreState
(
QWidget
*
widget
,
const
KConfigGroup
&
config
);
}
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment